:root {
  --bg: #0a0f1b;
  --bg-strong: #0f172a;
  --panel: #0f1626;
  --panel-2: #111b2f;
  --border: #1c2940;
  --border-strong: #24334f;
  --text: #d7e2f2;
  --muted: #99a7bf;
  --accent: #4e8ef7;
  --accent-strong: #63a6ff;
  --accent-soft: rgba(99, 166, 255, 0.15);
  --error: #e45b6c;
  --error-soft: rgba(228, 91, 108, 0.12);
  --success: #32d0a7;
  --code: #c8d4ea;
  --shadow: 0 12px 40px rgba(5, 8, 15, 0.55);
  --radius: 12px;
  --line-height: 1.55;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 120% at 15% 20%, rgba(78, 142, 247, 0.06), transparent 40%),
              radial-gradient(120% 120% at 85% 10%, rgba(50, 208, 167, 0.07), transparent 35%),
              var(--bg);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: "SF Pro Text", "Segoe UI", "Source Sans Pro", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(10, 15, 27, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), rgba(50, 208, 167, 0.1));
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 16px;
}

.brand-icon {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.brand-title { font-weight: 600; letter-spacing: 0.2px; }
.brand-subtitle { color: var(--muted); font-size: 12px; letter-spacing: 0.3px; }

.direction-switch {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.direction.option {
  border: none;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.15s ease, background 0.15s ease;
}

.direction.option.active {
  color: var(--text);
  background: linear-gradient(135deg, var(--accent-soft), rgba(99, 166, 255, 0.12));
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

button {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  transition: all 0.15s ease;
}

button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

button.ghost {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

button.ghost:hover { border-color: var(--border-strong); color: #fff; }

button.primary {
  padding: 10px 18px;
  background: linear-gradient(135deg, #4e8ef7, #6aa8ff);
  border: 1px solid #6aa8ff;
  color: #0b1323;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(78, 142, 247, 0.35);
}

button.primary:hover { filter: brightness(1.05); }

.icon-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
}

.icon-btn.copied { color: var(--accent-strong); border-color: var(--accent-strong); }

.status-pill {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--muted);
}

.status-pill.hidden {
  visibility: hidden;
}

.status-pill.valid {
  color: #0c241b;
  background: rgba(50, 208, 167, 0.95);
  border-color: rgba(50, 208, 167, 0.8);
}

.status-pill.error {
  color: #fff;
  background: var(--error);
  border-color: #f07a88;
}

.token-summary {
  padding: 12px 16px 0;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 1fr;
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 12px;
  padding: 12px 16px 16px;
}

.pane {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.file-label { display: flex; align-items: center; gap: 10px; font-weight: 600; color: #f2f5ff; }
.file-meta { color: var(--muted); font-size: 12px; letter-spacing: 0.2px; }
.file-badge {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(99, 166, 255, 0.12);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.4px;
}
.file-badge.muted { background: rgba(255, 255, 255, 0.04); color: var(--muted); }

.editor-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  background: radial-gradient(120% 140% at 20% 15%, rgba(78, 142, 247, 0.05), transparent 45%),
              linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
}

.line-numbers {
  width: 56px;
  padding: 14px 10px 14px 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  text-align: right;
  border-right: 1px solid var(--border);
  font-family: "SFMono-Regular", "JetBrains Mono", "Fira Code", monospace;
  font-size: 14px;
  line-height: var(--line-height);
  user-select: none;
  overflow: hidden;
  position: relative;
  height: 100%;
}

.line-numbers-inner {
  display: flex;
  flex-direction: column;
  transition: transform 0.05s linear;
}

.line-numbers .line { opacity: 0.55; }
.line-numbers .line.error { color: var(--error); font-weight: 700; opacity: 1; }

textarea {
  background: transparent;
  border: none;
  color: var(--code);
  resize: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 14px 16px;
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", monospace;
  font-size: 14px;
  line-height: var(--line-height);
  outline: none;
  caret-color: var(--accent-strong);
  white-space: pre;
  overflow: auto;
}

textarea[readonly] { color: #9fb3d8; }
textarea::selection { background: rgba(99, 166, 255, 0.22); }

.editor-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.output-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 15, 27, 0.8) 0%, rgba(10, 15, 27, 0.35) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 10px;
}

.output-pane.stale .output-overlay { opacity: 0.15; }
.output-pane.stale textarea { filter: grayscale(0.4); }

.output-pane.has-error {
  border-color: rgba(228, 91, 108, 0.4);
  box-shadow: 0 15px 35px rgba(228, 91, 108, 0.16);
}

.output-pane.has-error .pane-header {
  border-bottom-color: rgba(228, 91, 108, 0.4);
}

.output-pane.has-error textarea {
  opacity: 0;
  pointer-events: none;
}

.output-pane.has-error .output-overlay {
  opacity: 0;
}

.output-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border-radius: 10px;
  background: radial-gradient(120% 150% at 15% 20%, rgba(228, 91, 108, 0.25), transparent),
              linear-gradient(180deg, rgba(10, 15, 27, 0.92) 0%, rgba(10, 15, 27, 0.88) 100%);
  border: 1px solid rgba(228, 91, 108, 0.45);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.output-pane.has-error .output-error {
  opacity: 1;
  pointer-events: auto;
}

.output-error .error-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.output-error .error-message {
  font-size: 14px;
  color: #ff97a6;
}

.output-error .error-meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.output-error .error-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(228, 91, 108, 0.12);
  border: 1px solid rgba(228, 91, 108, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
}

.tokens {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.token-block {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.token-block.growth { grid-column: span 1; }

.token-label { color: var(--muted); font-size: 12px; letter-spacing: 0.3px; }
.token-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.token-hint { color: var(--muted); font-size: 11px; letter-spacing: 0.4px; }

.token-meter {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #32d0a7, #4e8ef7);
  transition: width 0.2s ease;
}

.policy-page {
  display: none;
  padding: 32px clamp(16px, 4vw, 64px) 120px;
  gap: 20px;
  color: var(--text);
}

.policy-page h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 40px);
}

.policy-page h2 {
  font-size: 18px;
  margin-bottom: 6px;
  color: #f2f5ff;
}

.policy-page p,
.policy-page li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.policy-page ul {
  padding-left: 20px;
  margin: 0 0 12px;
}

.policy-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.policy-updated {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.3px;
}

.policy-body {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 32px);
  box-shadow: var(--shadow);
}

.policy-body article {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.policy-body article:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.back-btn {
  font-weight: 600;
}

.app-shell.privacy-view .direction-switch,
.app-shell.faq-view .direction-switch,
.app-shell.privacy-view .actions,
.app-shell.faq-view .actions,
.app-shell.privacy-view .token-summary,
.app-shell.faq-view .token-summary,
.app-shell.privacy-view .workspace,
.app-shell.faq-view .workspace,
.app-shell.privacy-view .status-pill,
.app-shell.faq-view .status-pill,
.app-shell.terms-view .direction-switch,
.app-shell.terms-view .actions,
.app-shell.terms-view .token-summary,
.app-shell.terms-view .workspace,
.app-shell.terms-view .status-pill {
  display: none;
}

.app-shell.privacy-view #privacyPolicy,
.app-shell.faq-view #faq,
.app-shell.terms-view #termsPage {
  display: block;
}

.nav-faq {
  padding: 10px 14px;
}

.site-footer {
  padding: 18px 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(10, 15, 27, 0.92);
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  backdrop-filter: blur(6px);
}

.footer-inner {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.footer-divider {
  color: rgba(255, 255, 255, 0.18);
}

.footer-link {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.3px;
  text-decoration: none;
}

.footer-link:hover {
  color: #fff;
  border-color: var(--border);
  text-decoration: none;
}

.footer-link:visited,
.footer-link:focus {
  text-decoration: none;
}

.faq-section {
  padding: 36px clamp(16px, 4vw, 48px) 120px;
  position: relative;
}

/* FAQ uses the same single background as the rest of the app */

.faq-inner {
  max-width: 960px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.faq-header {
  text-align: center;
  margin-bottom: 26px;
}

.faq-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.faq-header h2 {
  margin: 0;
  font-size: clamp(24px, 3.5vw, 36px);
  color: #f5f8ff;
}

.faq-subtitle {
  margin: 8px auto 0;
  max-width: 540px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 22, 38, 0.96), rgba(12, 18, 33, 0.96));
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.faq-item[open] {
  border-color: rgba(99, 166, 255, 0.4);
  box-shadow: 0 20px 40px rgba(5, 8, 15, 0.6);
  transform: translateY(-1px);
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 22px;
  font-weight: 600;
  color: #f1f5ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "▾";
  font-size: 18px;
  color: var(--muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.faq-item[open] summary::after {
  transform: rotate(180deg);
  color: #dbe6ff;
}

.faq-content {
  padding: 0 22px 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.faq-content p {
  margin: 0 0 12px;
}

.faq-content ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.faq-content li {
  margin-bottom: 6px;
}

.faq-label {
  margin: 12px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #b7c7e8;
}

.faq-content pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(99, 166, 255, 0.2);
  background: rgba(8, 13, 24, 0.8);
  color: #dbe7ff;
  overflow-x: auto;
}

.faq-content code {
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", monospace;
  font-size: 13px;
}

.faq-source {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(153, 167, 191, 0.8);
}

.faq-source a {
  color: var(--accent-strong);
  text-decoration: none;
}

.faq-source a:hover {
  text-decoration: underline;
}

.reveal-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .tokens { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .faq-item summary {
    padding: 16px 18px;
    font-size: 14px;
  }
  .faq-content {
    padding: 0 18px 18px;
  }
}
