/* =========================================================================
   DaltonApps — Format.
   Self-contained. Same tokens as the dashboard.
   ========================================================================= */

:root {
  --bg:        #0b0b0e;
  --bg-soft:   #14141a;
  --bg-card:   #15161c;
  --bg-card-2: #1a1b22;
  --fg:        #f4f1ea;
  --fg-muted:  #9aa0a8;
  --fg-dim:    #6b7079;
  --accent:    #ffb454;
  --accent-soft: rgba(255, 180, 84, 0.14);
  --good:      #6fd49a;
  --bad:       #f3756c;
  --border:    rgba(244, 241, 234, 0.08);
  --border-strong: rgba(244, 241, 234, 0.16);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: ui-serif, Georgia, "Iowan Old Style", "Apple Garamond", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --s-1: 0.5rem;
  --s-2: 1rem;
  --s-3: 1.5rem;
  --s-4: 2rem;
  --s-5: 3rem;

  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 220ms;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
a:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- topbar (same as dashboard) --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-weight: 600;
}
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.back {
  font-size: 0.9rem;
  color: var(--fg-muted);
  transition: color var(--dur) var(--ease);
}
.back:hover { color: var(--fg); }

/* --- main --- */
.fmt {
  flex: 1;
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.fmt-head { margin-bottom: var(--s-2); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 0.35rem;
}
.fmt-head h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.015em;
  line-height: 1.05;
}
.lede {
  margin: 0;
  color: var(--fg-muted);
  font-size: 1.05rem;
}

/* --- toolbar --- */
.fmt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
  justify-content: space-between;
}
.pills {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pill:hover { color: var(--fg); }
.pill.is-active {
  background: var(--accent);
  color: #1a1206;
}

.actions {
  display: inline-flex;
  gap: 0.5rem;
}
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              background var(--dur) var(--ease);
  border: 1px solid transparent;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg-muted);
}
.btn-ghost:hover { color: var(--fg); border-color: var(--fg-dim); }
.btn-ghost.is-flash { color: var(--good); border-color: var(--good); }

/* --- panes --- */
.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  min-height: 24rem;
}
@media (max-width: 720px) {
  .panes { grid-template-columns: 1fr; }
}
.pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.pane-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.pane textarea {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--fg);
  background: transparent;
  border: none;
  resize: vertical;
  padding: 0.85rem;
  min-height: 22rem;
  tab-size: 2;
}
.pane textarea::placeholder { color: var(--fg-dim); }
.pane textarea:focus { outline: none; }

/* --- status line --- */
.status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin: 0;
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.status-detected.is-error { color: var(--bad); }
.status-detected.is-ok { color: var(--good); }
.status-meta { color: var(--fg-dim); }

/* --- footer --- */
.fmt-footer {
  text-align: center;
  padding: var(--s-3);
  color: var(--fg-dim);
  font-size: 0.85rem;
}

/* --- reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
