/* AnkiToPodcast — clean, neutral theme. */
:root {
  --ink: #18181b;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --bg: #f8f9fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --muted: #6b7280;
  --good: #059669;
  --bad: #b42318;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }

/* Layout */
.atp-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.atp-header-inner, .atp-main {
  max-width: 1040px; margin: 0 auto; padding: 0 20px;
}
.atp-header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.atp-brand { font-weight: 800; color: var(--ink); font-size: 1.15rem; letter-spacing: -0.02em; }
.atp-brand span { color: var(--accent); }
.atp-nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.atp-nav a, .atp-nav button.link { color: var(--ink); background: none; border: none; font-size: 0.95rem; }
.atp-account-menu { position: relative; }
.atp-account-toggle { display: inline-flex; align-items: center; gap: 5px; padding: 6px 0; }
.atp-account-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  min-width: 118px; padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; box-shadow: var(--shadow);
}
.atp-account-dropdown .link { width: 100%; padding: 7px 9px; text-align: left; border-radius: 6px; }
.atp-account-dropdown .link:hover { background: #f3f4f6; text-decoration: none; }
.atp-main { padding-top: 32px; padding-bottom: 64px; }
.atp-footer { border-top: 1px solid var(--border); background: #fff; }
.atp-footer-inner { max-width: 1040px; margin: 0 auto; padding: 30px 20px; display: grid; grid-template-columns: 1fr auto; gap: 8px 28px; align-items: center; }
.atp-footer p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.atp-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 18px; }
.atp-footer nav a, .atp-footer small { color: var(--muted); font-size: 0.87rem; }
.atp-footer small { grid-column: 1 / -1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: 0.98rem; background: var(--ink); color: #fff; transition: 0.15s;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: var(--accent-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 0.88rem; }

/* Cards / panels */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #eef2ff; color: var(--accent-dark); font-size: 0.78rem; font-weight: 600; }

/* Hero */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; margin: 0 auto 24px; }
.hero .cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 40px; }
.step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 10px; }

/* Forms */
label.field { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 1rem; background: #fff; color: var(--ink);
}
textarea { padding-top: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* Wizard */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.wizard-steps .ws { flex: 1; min-width: 120px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.wizard-steps .ws.active { border-color: var(--accent); color: var(--accent-dark); background: #eef2ff; }
.wizard-steps .ws.done { color: var(--good); border-color: #a7f3d0; background: #ecfdf5; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; background: #fff; }
.dropzone.drag { border-color: var(--accent); background: #eef2ff; }
.count-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.count-chips .chip { background: #f3f4f6; border-radius: 10px; padding: 8px 12px; font-size: 0.85rem; }
.count-chips .chip b { font-size: 1.1rem; display: block; }
.atp-library-heading { margin: 28px 0 0; }
.mapping-guide { display: grid; gap: 14px; }
.mapping-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mapping-choice {
  min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--ink); text-align: left;
}
.mapping-choice span, .mapping-choice b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-choice span { font-size: 0.8rem; color: var(--muted); }
.mapping-choice b { font-size: 0.9rem; margin-top: 2px; }
.mapping-choice.active { border-color: var(--accent); background: #eef2ff; }
.mapping-choice.chosen { border-color: #a7f3d0; background: #ecfdf5; }
.sample-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fcfcff; }
.sample-card-heading { padding: 16px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.sample-card-heading h3, .sample-card-heading p { margin: 0; }
.sample-card-heading p { margin-top: 4px; }
.sample-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; padding: 14px; }
.sample-field {
  display: grid; gap: 5px; min-height: 108px; padding: 13px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--ink); text-align: left;
}
.sample-field:hover:not(:disabled) { border-color: var(--accent); background: #f7f7ff; }
.sample-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sample-field:disabled { opacity: 0.55; cursor: not-allowed; }
.sample-field.selected { border-color: var(--good); background: #ecfdf5; }
.sample-field-name { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.sample-field-value { overflow-wrap: anywhere; }
.sample-field-role { font-size: 0.76rem; font-weight: 700; color: var(--good); }
.mapping-skip { justify-self: start; color: var(--muted); background: none; border: 0; padding: 0; }
.sample-navigation { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); background: #fff; font-size: 0.86rem; }
.sample-navigation .link { border: 0; background: none; color: var(--accent); }
.sample-navigation .link:disabled { color: var(--muted); }

/* Library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ep-card { cursor: pointer; }
.ep-card:hover { border-color: var(--accent); }
.ep-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.ep-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }

/* Reader */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.reader-back { box-shadow: none; }
.reader-hero { padding-bottom: 20px; }
.reader-audio { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.reader-audio > span { display: block; font-size: 0.86rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.reader-audio audio { margin: 0; accent-color: var(--accent); }
.reader-copy { background: #fff; color: #111827; padding: 28px; }
.reader .transcript { color: #111827; font-size: clamp(1.05rem, 1.6vw, 1.25rem); line-height: 1.72; letter-spacing: 0.005em; overflow-wrap: anywhere; }
.word-token { appearance: none; border: 0; border-radius: 8px; padding: 0 2px; background: transparent; color: inherit; font: inherit; line-height: inherit; cursor: pointer; transition: background 0.15s, color 0.15s; }
.word-token:hover, .word-token:focus-visible { background: #e0e7ff; outline: 0; }
.word-token.active { background: var(--accent); color: #fff; }
.reader-toolbar { position: sticky; top: 60px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.reader-tabs { display: flex; gap: 4px; width: fit-content; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.reader-tab { border: 0; border-radius: 7px; padding: 8px 12px; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 700; }
.reader-tab.active { background: #eef2ff; color: var(--accent-dark); }
.reader-display-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.reader-display { border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; background: #fff; color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 700; }
.reader-display.active { border-color: #c7d2fe; background: #eef2ff; color: var(--accent-dark); }
.episode-script { display: grid; gap: 0; }
.script-line { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.script-line:first-child { padding-top: 0; }
.script-line:last-child { padding-bottom: 0; border-bottom: 0; }
.script-speaker { display: flex; align-items: center; height: fit-content; color: var(--muted); font-size: 0.9rem; font-weight: 800; }
.speaker-mark { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: #eef2ff; color: var(--accent-dark); }
.script-line-copy { position: relative; padding-right: 40px; }
.script-line-actions { position: absolute; top: 2px; right: 0; }
.line-audio, .line-retry { border: 1px solid var(--border); background: #fff; color: var(--accent-dark); font: inherit; font-weight: 800; }
.line-audio { display: grid; width: 30px; height: 30px; place-items: center; padding: 0; border-radius: 50%; font-size: 0.78rem; }
.line-retry { border-radius: 8px; padding: 5px 8px; font-size: 0.78rem; }
.line-audio:hover, .line-retry:hover { border-color: var(--accent); background: #eef2ff; }
.line-learning-aids { display: grid; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.line-learning-aid { margin: 0; color: var(--muted); font-size: 0.94rem; line-height: 1.5; }
.line-learning-aid span { display: inline-block; min-width: 112px; margin-right: 8px; color: #475569; font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.line-learning-aid.romanization { font-style: italic; }
.featured-words { max-width: 760px; }
.featured-word-list { display: grid; margin-top: 20px; border-top: 1px solid var(--border); }
.featured-word { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.featured-word strong { font-size: 1.08rem; }
.featured-romanization { display: block; margin-top: 2px; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.featured-translation { color: var(--muted); text-align: right; }
.lookup { position: sticky; top: 80px; align-self: start; }
.lookup .word { font-size: 1.6rem; font-weight: 700; }
.lookup .rom { color: var(--muted); font-style: italic; }
.lookup .tr { font-size: 1.1rem; margin-top: 6px; }
.lookup .empty { color: var(--muted); }
audio { width: 100%; margin-top: 8px; }

/* Pricing */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.price-card { text-align: center; }
.price-card .amount { font-size: 2.4rem; font-weight: 800; }
.price-card ul { list-style: none; padding: 0; margin: 16px 0; text-align: left; }
.price-card li { padding: 6px 0 6px 26px; position: relative; }
.price-card li:before { content: "✓"; color: var(--good); position: absolute; left: 0; font-weight: 700; }
.price-card.featured { border-color: var(--accent); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); padding: 28px; width: min(100%, 420px); }
.generation-progress { width: min(100%, 460px); }
.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: #e5e7eb; margin-top: 20px; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #7c3aed); transition: width 0.4s ease; }
.progress-value { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* Toast + banners */
.banner { padding: 12px 16px; border-radius: 10px; font-size: 0.92rem; }
.banner.error { background: #fef2f2; color: var(--bad); border: 1px solid #fecaca; }
.banner.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.banner.ok { background: #ecfdf5; color: var(--good); border: 1px solid #a7f3d0; }
.center { text-align: center; }
.spinner { width: 22px; height: 22px; border: 3px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Video placeholder */
.video-embed { max-width: 720px; margin: 0 auto; }
.video-ph { aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: var(--radius); background: #eef0f6; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 2px; }
.video-ph span { font-size: 34px; color: var(--accent); line-height: 1; }
.video-ph p { margin: 6px 0 0; font-weight: 700; color: var(--ink); }

/* Legal pages */
body.atp-legal { min-height: 100vh; display: flex; flex-direction: column; }
body.atp-legal main { flex: 1; width: 100%; max-width: 720px; margin: 40px auto; padding: 0 20px; }

/* Support */
.atp-support-page { display: flex; min-height: 100vh; flex-direction: column; }
.atp-support-card { width: min(calc(100% - 48px), 620px); margin: 48px auto; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.atp-support-form { display: grid; gap: 16px; margin-top: 20px; }
.atp-support-form small { display: block; margin-top: 5px; }

@media (max-width: 640px) {
  .atp-header-inner { height: auto; min-height: 60px; padding-top: 10px; padding-bottom: 10px; align-items: flex-start; }
  .atp-nav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .mapping-choices { grid-template-columns: 1fr; }
  .sample-navigation { align-items: center; }
  .atp-footer-inner { grid-template-columns: 1fr; }
  .atp-footer nav { justify-content: flex-start; }
  .atp-footer small { grid-column: auto; }
  .reader { grid-template-columns: 1fr; }
  .reader-toolbar { top: 52px; align-items: flex-start; flex-direction: column; }
  .reader-display-controls { justify-content: flex-start; }
  .lookup { position: static; }
  .reader-copy { padding: 18px; }
  .script-line { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .script-line-copy { padding-right: 36px; }
  .line-learning-aid span { display: block; margin: 0 0 2px; }
  .featured-word { align-items: flex-start; flex-direction: column; gap: 4px; }
  .featured-translation { text-align: left; }
}
