@font-face {
  font-family: 'Roboto Condensed';
  src: url('../../assets/fonts/RobotoCondensed-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Roboto Condensed';
  src: url('../../assets/fonts/RobotoCondensed-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0f14;
  --panel: #10171f;
  --panel-2: #0d141b;
  --border: #1e2a37;
  --text: #dbe6f0;
  --muted: #7d8ea3;
  --accent: #19b3b1;
  --accent-strong: #139594;
  --danger: #ff6b6b;
  --warn: #f0b34a;
  --ok: #4ade80;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Roboto Mono',
    Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: #9fb4c9;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- toolbar ---------- */

.toolbar {
  flex: none;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(180deg, #111a23, #0e151d);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #7fe7e5, var(--accent-strong));
  color: #052023;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -1px;
  box-shadow: 0 6px 18px rgba(19, 149, 148, 0.35);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.toolbar-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #0a1118;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.segmented button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: rgba(25, 179, 177, 0.16);
  color: #7fe7e5;
  box-shadow: inset 0 0 0 1px rgba(25, 179, 177, 0.35);
}

.width-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label,
.check {
  font-size: 12px;
  color: var(--muted);
}

.select {
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1118;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.select:hover,
.select:focus {
  border-color: rgba(25, 179, 177, 0.55);
}

.select-compact {
  max-width: 168px;
}

.number-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.number-field input {
  width: 58px;
  padding: 7px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1118;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  text-align: right;
  outline: none;
}

.number-field input:focus {
  border-color: rgba(25, 179, 177, 0.55);
}

.number-field span {
  font-size: 11px;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #17212c;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.button:hover {
  border-color: rgba(25, 179, 177, 0.65);
  color: #fff;
}

.button:active {
  background: #1d2a36;
}

.button-ghost {
  background: transparent;
  color: var(--muted);
}

.button-mini {
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 6px;
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- workspace ---------- */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.pane-editor {
  background: #0b1117;
}

.pane-header {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.pane-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pane-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #a9bacd;
}

.pane-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pane-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
}

.color-control input[type='color'] {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.splitter {
  position: relative;
  background: var(--bg);
  cursor: col-resize;
  touch-action: none;
}

.splitter::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: var(--border);
  transition: background 0.15s;
}

.splitter:hover::after {
  background: var(--accent);
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

/* ---------- editor ---------- */

.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #0b1117;
}

.editor:focus-within {
  box-shadow: inset 0 0 0 1px rgba(25, 179, 177, 0.3);
}

.gutter {
  flex: none;
  width: 52px;
  overflow: hidden;
  background: #0a0f15;
  border-right: 1px solid var(--border);
  color: #43536a;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 20px;
  user-select: none;
}

.gutter-inner {
  padding: 14px 10px 0 0;
  text-align: right;
}

.gutter-line {
  height: 20px;
}

.code-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.code-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 20px;
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

.code-highlight {
  overflow: hidden;
  color: #cfe0f0;
  pointer-events: none;
  user-select: none;
}

.code-input {
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #7fe7e5;
  resize: none;
  outline: none;
}

.code-input::placeholder {
  color: #4b5b70;
}

.code-input::selection {
  background: rgba(25, 179, 177, 0.3);
}

.tok-tag {
  color: #7dd3fc;
}

.tok-attr {
  color: #fbbf24;
}

.tok-string {
  color: #a7f3d0;
}

.tok-punct {
  color: #8b9cb3;
}

.tok-comment {
  color: #5b6b7d;
  font-style: italic;
}

.tok-doctype {
  color: #c4b5fd;
}

/* ---------- processed html ---------- */

.processed {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.processed-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.processed-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.processed-chevron {
  width: 12px;
  color: var(--muted);
}

.processed-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.processed-body {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  border-top: 1px solid var(--border);
}

.processed-body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
}

.processed-code {
  flex: 1;
  margin: 0;
  padding: 0 14px 14px;
  overflow: auto;
  color: #b9cbdd;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- preview ---------- */

.pane-preview {
  background: #080c11;
}

.preview-canvas {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background-color: #080c11;
  background-image: radial-gradient(rgba(120, 160, 200, 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
}

.preview-canvas-failure {
  align-items: center;
}

.device-fit {
  flex: none;
}

.device {
  padding: 10px;
  border-radius: 38px;
  background: #05080c;
  box-shadow: 0 0 0 1px #2a3646, 0 24px 70px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transform-origin: top left;
}

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 620px;
  border-radius: 28px;
  overflow: hidden;
}

.coupon-header {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  letter-spacing: 0.02em;
  padding-top: 4px;
}

.coupon-card {
  margin: 10px 20px 0;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

.coupon-title {
  margin: 2px 0 4px;
  color: #19b3b1;
  font-family: 'Roboto Condensed', 'Arial Narrow', var(--sans);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.15;
  text-align: center;
}

.coupon-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 22px;
  margin: 4px 0 2px;
}

.coupon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #139594;
}

.coupon-html {
  color: #000;
}

.coupon-html.debug-outlines * {
  outline: 1px dashed rgba(255, 80, 90, 0.45);
  outline-offset: -1px;
}

.screen-bottom-space {
  flex: none;
  height: 24px;
}

/* ---------- errors ---------- */

.preview-error {
  width: min(560px, 100%);
  margin: auto;
  padding: 18px 20px;
  border: 1px solid rgba(255, 90, 90, 0.45);
  border-radius: 12px;
  background: rgba(255, 80, 90, 0.06);
  color: #ffd9d9;
}

.preview-error-title {
  margin-bottom: 8px;
  color: #ff8b8b;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-error-message {
  margin: 0 0 8px;
  color: #ffb4b4;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-word;
}

.preview-error-hint {
  margin: 0;
  color: #c98f8f;
  font-size: 12px;
}

/* ---------- diagnostics ---------- */

.diagnostics {
  flex: none;
  max-height: 190px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.diagnostics-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 6px;
}

.diagnostics-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge {
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  white-space: nowrap;
}

.badge-error {
  color: #ffb4b4;
  border-color: rgba(255, 90, 90, 0.4);
  background: rgba(255, 90, 90, 0.08);
}

.badge-warn {
  color: #ffd38a;
  border-color: rgba(240, 179, 74, 0.4);
  background: rgba(240, 179, 74, 0.08);
}

.badge-ok {
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.diagnostics-list {
  margin: 0;
  padding: 0 14px 10px;
  list-style: none;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diag {
  position: relative;
  padding-left: 14px;
  color: #c3d1df;
  font-size: 12px;
  line-height: 1.5;
}

.diag::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.diag-error {
  color: #ff9c9c;
}

.diag-warn {
  color: #f3c273;
}

.diag-info {
  color: #8ec5e8;
}

.diag-ok {
  color: #7fd8a0;
}

/* ---------- status bar / toast ---------- */

.statusbar {
  flex: none;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #0a0f15;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

.status-sep {
  flex: none;
  width: 1px;
  height: 12px;
  background: var(--border);
}

.status-spacer {
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 9px 16px;
  border: 1px solid rgba(25, 179, 177, 0.5);
  border-radius: 10px;
  background: #16303a;
  color: #d9fbfa;
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #22303f;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #2c3e50;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1180px) {
  .brand-sub {
    display: none;
  }

  .status-hint {
    display: none;
  }

  .toolbar {
    gap: 12px;
  }
}
