/* Subscript Generator – main styles (system font stack, no external fonts) */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --radius: 8px;
  --radius-sm: 6px;
}

/* Dark mode (primary) */
body.dark {
  --bg: #111827;
  --surface: #1f2937;
  --input-bg: #1f2937;
  --header-bg: #111827;
  --header-text: #E5E7EB;
  --header-muted: #9CA3AF;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #9ca3af;
  --accent: #2563EB;
  --accent-hover: #1d4ed8;
  --accent-soft: #1e3a8a;
  --chip-text: #e5e7eb;
  --success: #16A34A;
  --success-bg: #052E16;
  --border: #374151;
  --border-soft: #374151;
  --panel-header-bg: #1f2937;
  --output-bg: #1f2937;
  --toggle-on: #2563EB;
}

/* Light mode */
body.light {
  --bg: #f8fafc;
  --surface: #ffffff;
  --input-bg: #ffffff;
  --header-bg: #111827;
  --header-text: #E5E7EB;
  --header-muted: #9CA3AF;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #4b5563;
  --accent: #2563EB;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --chip-text: #1e40af;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --border: #e5e7eb;
  --border-soft: #e5e7eb;
  --panel-header-bg: #f8fafc;
  --output-bg: #ffffff;
  --toggle-on: #2563EB;
}

body.light .panel,
body.light .center-card,
body.light .actions-bar {
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}

.topbar > div { min-width: 0; }
.topbar-left {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 38%;
}
.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
.topbar-center .topbar-logo { pointer-events: auto; }
.topbar-logo {
  width: clamp(64px, 12vw, 150px);
  height: clamp(64px, 12vw, 150px);
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 0;
}
.topbar h1 { margin: 0; font-size: 1.25rem; font-weight: 600; color: var(--header-text); line-height: 1.3; }
.trust-line { margin: 4px 0 0 0; font-size: 0.8125rem; color: var(--header-muted); line-height: 1.4; max-width: 520px; }
@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .topbar-left { max-width: none; order: 2; text-align: center; }
  .topbar-center { position: static; transform: none; order: 1; }
  .topbar .theme-toggle { order: 3; }
  .topbar-logo { width: 80px; height: 80px; }
}
@media (max-width: 480px) {
  .topbar-logo { width: 64px; height: 64px; }
  .topbar h1 { font-size: 1.1rem; }
  .trust-line { font-size: 0.75rem; }
}
.theme-toggle {
  padding: 8px 14px; font-size: 0.875rem; font-weight: 500; font-family: inherit;
  color: var(--header-text); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm); cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tool-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  min-height: calc(100vh - 120px);
}

.quick-try {
  padding: 16px 20px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.quick-try-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}
.example-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--chip-text);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.example-chip:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--accent-soft);
  filter: brightness(0.97);
}
.example-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tool-panels {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  gap: 16px;
  min-height: 300px;
  padding: 16px 20px 20px;
}
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-header-bg);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}
.panel-header--secondary {
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
}
.panel-header--secondary .upload-btn-wrap { margin-left: auto; }
.panel-header-actions { display: flex; gap: 6px; }
.panel-header-actions button {
  padding: 8px 12px;
  min-height: 44px;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.panel-header-actions button:hover { background: var(--border); color: var(--text); }
.panel-header-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.panel-stats span { margin-left: 10px; }
.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.textarea {
  flex: 1;
  width: 100%;
  min-height: 200px;
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  border: none;
  resize: none;
  background: var(--input-bg);
  color: var(--text);
}
.input-area,
.output-area {
  min-height: 200px;
}
.textarea::placeholder { color: var(--text-muted); }
.textarea:focus { outline: none; }
.output-area { background: var(--output-bg); }
.output-area.style-normal,
.output-area.style-bold,
.output-area.style-italic,
.output-area.style-bold-italic { font-size: inherit; }
.output-area.style-normal { font-weight: normal; font-style: normal; }
.output-area.style-bold { font-weight: 700; }
.output-area.style-italic { font-style: italic; }
.output-area.style-bold-italic { font-weight: 700; font-style: italic; }

.input-col,
.output-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.input-col .panel,
.output-col .panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.input-col .panel .panel-body,
.output-col .panel .panel-body {
  flex: 1;
  min-height: 0;
}
.input-col-footer {
  flex-shrink: 0;
  min-height: 72px;
}
.center-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.center-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.upload-btn-wrap { position: relative; }
.upload-btn-wrap input[type="file"] {
  position: absolute; width: 0; height: 0; opacity: 0;
}
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent-hover);
  cursor: pointer;
}
.btn-upload:hover { background: var(--accent-soft); filter: brightness(0.97); }
.btn-upload:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.center-card .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 12px;
}
.center-card .toggle-row:last-of-type { margin-bottom: 0; }
.center-card .mode-radios {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.center-card .mode-radios label { display: inline-flex; align-items: center; gap: 6px; }
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}
.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 24px;
  transition: background .2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s;
}
.toggle-input:checked + .toggle-slider {
  background: var(--toggle-on);
}
.toggle-input:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.toggle-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  min-width: 24px;
}
.toggle-input:checked ~ .toggle-label { color: var(--toggle-on); font-weight: 500; }
.btn-generate {
  width: 100%;
  padding: 12px 16px;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-generate:hover { background: var(--accent-hover); }
.btn-generate:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.micro-assurance {
  margin: 10px 0 0;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.conversion-type-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.conversion-type-layout {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conversion-type-row {
  display: flex;
  gap: 8px;
}
.conversion-type-row--two .conv-btn { flex: 1; }
.conversion-type-row--full .conv-btn { width: 100%; }
.conversion-type-row .conv-btn {
  padding: 11px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.conversion-type-row .conv-btn:hover { background: var(--accent-soft); border-color: var(--border); }
.conversion-type-row .conv-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.conversion-type-row .conv-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bold-italic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
}
.bold-italic-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.bold-italic-label input { cursor: pointer; accent-color: var(--accent); }
.ignore-row {
  margin-top: 14px;
}
.ignore-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.ignore-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.ignore-input::placeholder { color: var(--text-muted); }
.ignore-input:focus {
  outline: none;
  border-color: var(--accent);
}
.unicode-hint {
  margin: 12px 0 0;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.unicode-hint strong { color: var(--text); }
.unicode-hint a { color: var(--accent); text-decoration: none; }
.unicode-hint a:hover { text-decoration: underline; }

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.btn {
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s ease;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-copy.copied,
.copy-feedback { animation: copyFeedback 0.3s ease; }
@keyframes copyFeedback {
  0% { transform: scale(1); }
  50% { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.btn-copy, .btn-download {
  background: var(--success);
  color: #fff;
}
.btn-copy:hover:not(:disabled), .btn-download:hover { background: #15803d; }
.btn-copy:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sample, .btn-reset {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sample:hover, .btn-reset:hover { background: var(--border-soft); }

.clipboard-hint {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
}
.clipboard-hint[hidden] { display: none !important; }
.clipboard-hint-title { margin: 0 0 6px; font-weight: 600; color: var(--chip-text); }
.clipboard-hint-text { margin: 0 0 10px; line-height: 1.5; color: var(--text-secondary); }
.clipboard-hint-dismiss {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}
.clipboard-hint-dismiss:hover { background: var(--border-soft); }
.clipboard-hint-dismiss:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.content-below {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  width: 100%;
}
.content-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.intro-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 0;
}
.intro-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0;
  text-align: center;
}
.content-section h2 { margin: 0 0 10px; font-size: 1.1rem; font-weight: 600; color: var(--text); }
.content-section h3 { margin: 16px 0 8px; font-size: 1rem; font-weight: 600; color: var(--text); }
.content-section p { margin: 0 0 12px; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; }
.content-section p:last-child { margin-bottom: 0; }
.content-section ul { margin: 10px 0; padding-left: 20px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.8; }
.content-section li { margin-bottom: 6px; }
.use-case-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.use-case-chip {
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.footer {
  padding: 14px 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer p { margin: 4px 0; }
.footer-disclaimer {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .tool-panels { grid-template-columns: 1fr; }
  .center-col { order: 3; }
}
