:root {
  --ink: #f7f4ec;
  --muted: #a6a7b7;
  --muted-strong: #d0cfda;
  --bg: #11132a;
  --bg-soft: #181b37;
  --panel: rgba(31, 35, 67, .84);
  --panel-strong: #252a50;
  --line: rgba(246, 244, 234, .13);
  --line-bright: rgba(246, 244, 234, .23);
  --coral: #ff806b;
  --coral-soft: #ffb19e;
  --mint: #a9e8ca;
  --yellow: #f3d88b;
  --lavender: #c8c5ff;
  /* Local/system stacks keep the PWA fully usable offline. */
  --display: 'Iowan Old Style', 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --body: 'PingFang SC', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
  --radius-lg: 24px;
  --radius-md: 14px;
  --shadow: 0 24px 70px rgba(1, 3, 18, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }

.app-noise { position: fixed; inset: 0; pointer-events: none; opacity: .08; z-index: -1; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E"); }
.app-shell { position: relative; max-width: 1440px; min-height: 100vh; margin: 0 auto; padding: 0 56px; overflow: hidden; }
.app-shell::before, .app-shell::after { content: ''; position: absolute; pointer-events: none; border-radius: 50%; filter: blur(2px); }
.app-shell::before { width: 480px; height: 480px; left: -280px; top: 340px; background: radial-gradient(circle, rgba(255, 128, 107, .12), transparent 70%); }
.app-shell::after { width: 540px; height: 540px; right: -320px; top: -170px; background: radial-gradient(circle, rgba(169, 232, 202, .1), transparent 66%); }

.topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; min-height: 96px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--coral); border-radius: 50%; transform: rotate(-18deg); }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ''; position: absolute; border: 1px solid var(--coral); border-radius: 50%; }
.brand-mark::before { width: 24px; height: 10px; transform: rotate(48deg); }
.brand-mark::after { width: 24px; height: 10px; transform: rotate(-48deg); }
.brand-mark span { width: 5px; height: 5px; border: none; background: var(--mint); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 15px; letter-spacing: .08em; font-weight: 700; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .06em; }
.main-nav { display: flex; align-items: center; gap: 10px; margin-left: auto; margin-right: 28px; }
.nav-item { position: relative; border: 0; padding: 11px 15px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; transition: color .2s ease, background .2s ease; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.nav-item.is-active { color: var(--ink); background: rgba(255,255,255,.1); }
.nav-item.is-active::after { content: ''; position: absolute; left: 50%; bottom: -18px; width: 4px; height: 4px; border-radius: 50%; background: var(--coral); transform: translateX(-50%); }
.nav-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 99px; background: rgba(255,255,255,.12); color: var(--muted-strong); font: 10px var(--mono); }
.install-btn { border: 1px solid rgba(169, 232, 202, .45); border-radius: 999px; padding: 9px 14px; background: rgba(169, 232, 202, .08); color: var(--mint); font-size: 12px; }
.install-btn span { font-size: 17px; vertical-align: -1px; }
.ai-settings-btn { display: inline-flex; align-items: center; gap: 7px; margin-left: 8px; border: 1px solid rgba(200,197,255,.4); border-radius: 999px; padding: 9px 13px; background: rgba(200,197,255,.08); color: var(--lavender); font-size: 12px; white-space: nowrap; transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease; }
.ai-settings-btn:hover { border-color: var(--mint); background: rgba(169,232,202,.09); color: var(--mint); transform: translateY(-1px); }
.ai-settings-glyph { color: var(--coral-soft); font-size: 15px; line-height: 1; }

.view { display: none; padding: 76px 0 60px; animation: viewIn .45s ease both; }
.view.is-visible { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 9%; align-items: end; margin-bottom: 68px; }
.eyebrow, .section-index { margin: 0 0 15px; color: var(--coral-soft); font: 500 10px var(--mono); letter-spacing: .18em; }
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px rgba(255,128,107,.1); }
h1, h2, h3, p { margin-top: 0; }
.hero-copy h1 { max-width: 730px; margin-bottom: 23px; font: 600 clamp(45px, 6.2vw, 83px)/1.02 var(--display); letter-spacing: -.045em; }
.hero-copy h1 em { color: var(--coral); font-style: normal; position: relative; }
.hero-copy h1 em::after { content: ''; position: absolute; bottom: 0; left: 4%; width: 94%; height: 6px; border-radius: 6px; background: var(--mint); transform: rotate(-2deg); opacity: .9; }
.hero-lede { max-width: 650px; margin-bottom: 28px; color: var(--muted-strong); font-size: 15px; line-height: 1.9; }
.hero-proof { display: flex; gap: 30px; }
.hero-proof > div { display: flex; align-items: baseline; gap: 9px; }
.hero-proof strong { color: var(--mint); font: 500 21px var(--mono); }
.hero-proof span { color: var(--muted); font-size: 11px; }
.compass-note { position: relative; padding: 28px 24px 25px; border-left: 1px solid var(--line-bright); }
.compass-note::before { content: ''; position: absolute; left: -1px; top: 0; width: 1px; height: 75px; background: var(--coral); }
.compass-rose { position: relative; display: grid; place-items: center; width: 88px; height: 88px; margin: 0 0 21px 2px; border: 1px solid rgba(169,232,202,.5); border-radius: 50%; color: var(--mint); }
.compass-rose::before, .compass-rose::after { content: ''; position: absolute; width: 1px; height: 74px; background: rgba(169,232,202,.32); }
.compass-rose::after { transform: rotate(90deg); }
.compass-rose i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.compass-rose i:nth-child(1) { top: 8px; } .compass-rose i:nth-child(2) { right: 8px; } .compass-rose i:nth-child(3) { bottom: 8px; } .compass-rose i:nth-child(4) { left: 8px; }
.compass-rose b { position: relative; z-index: 1; font: 700 22px var(--display); }
.note-kicker { margin-bottom: 7px; color: var(--mint); font: 500 10px var(--mono); letter-spacing: .14em; }
.note-quote { margin-bottom: 10px; font: 500 19px/1.45 var(--display); }
.note-detail { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }

.ask-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 9%; align-items: start; }
.question-card, .rail-card, .reading-panel, .question-item, .history-item { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.question-card { position: relative; padding: 35px 38px 30px; border-radius: var(--radius-lg); overflow: hidden; }
.question-card::before { content: ''; position: absolute; width: 290px; height: 290px; right: -140px; top: -170px; border-radius: 50%; border: 1px solid rgba(255,128,107,.23); box-shadow: 0 0 0 16px rgba(255,128,107,.03), 0 0 0 32px rgba(255,128,107,.025); }
.panel-glow::after { content: ''; position: absolute; left: 35px; right: 35px; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--coral), transparent); opacity: .6; }
.card-heading { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.card-heading h2 { margin: 0; font: 600 clamp(23px, 3vw, 34px)/1.2 var(--display); letter-spacing: -.025em; }
.section-index { margin-bottom: 12px; color: var(--muted); }
.live-pill { display: flex; align-items: center; gap: 7px; margin-top: 5px; color: var(--mint); font: 10px var(--mono); white-space: nowrap; }
.live-pill span { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(169,232,202,.12); }
textarea, input, select { border: 1px solid var(--line); background: rgba(8, 10, 27, .34); color: var(--ink); border-radius: var(--radius-md); }
textarea::placeholder, input::placeholder { color: #70738e; }
#questionInput { display: block; width: 100%; min-height: 148px; padding: 18px 19px; resize: vertical; font-size: 16px; line-height: 1.8; transition: border-color .2s ease, box-shadow .2s ease; }
#questionInput:focus { border-color: rgba(169,232,202,.7); box-shadow: 0 0 0 4px rgba(169,232,202,.08); outline: none; }
.input-meta { display: flex; justify-content: space-between; gap: 16px; margin: 9px 3px 18px; color: var(--muted); font-size: 11px; }
#charCount { color: #7e829e; font-family: var(--mono); }
.category-row, .filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.category-row { margin-bottom: 26px; }
.category-chip, .filter-chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: transparent; color: var(--muted-strong); font-size: 11px; transition: all .2s ease; }
.category-chip:hover, .filter-chip:hover { border-color: var(--line-bright); color: var(--ink); }
.category-chip.is-selected, .filter-chip.is-selected { border-color: var(--coral); background: rgba(255,128,107,.12); color: var(--coral-soft); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; }
.primary-btn, .ghost-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; border-radius: 999px; padding: 0 21px; font-weight: 600; font-size: 13px; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.primary-btn { border: 1px solid var(--coral); background: var(--coral); color: #21152a; box-shadow: 0 8px 22px rgba(255,128,107,.2); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(255,128,107,.3); }
.primary-btn.compact { min-height: 40px; padding: 0 16px; font-size: 12px; }
.btn-arrow { font-size: 19px; line-height: 1; }
.ghost-btn { border: 1px solid var(--line-bright); background: rgba(255,255,255,.03); color: var(--muted-strong); }
.ghost-btn:hover { border-color: var(--mint); color: var(--mint); background: rgba(169,232,202,.07); }
.keyboard-tip { margin: 17px 0 0; color: #737792; font-size: 10px; }
kbd { border: 1px solid var(--line-bright); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--muted-strong); font: 10px var(--mono); }
.side-rail { display: grid; gap: 17px; }
.rail-card { padding: 25px 24px; border-radius: 18px; }
.steps-list { display: grid; gap: 21px; margin: 0; padding: 0; list-style: none; }
.steps-list li { display: flex; gap: 13px; align-items: flex-start; }
.steps-list li > span { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border: 1px solid rgba(169,232,202,.55); border-radius: 50%; color: var(--mint); font: 10px var(--mono); }
.steps-list strong { display: block; margin-bottom: 2px; font-size: 13px; }
.steps-list small { color: var(--muted); font-size: 11px; }
.rail-safety { display: flex; gap: 13px; border-color: rgba(243,216,139,.22); background: rgba(243,216,139,.055); }
.safety-icon { color: var(--yellow); font-size: 22px; line-height: 1; }
.rail-safety strong { display: block; margin-bottom: 5px; color: var(--yellow); font-size: 12px; }
.rail-safety p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

.reading-panel { position: relative; margin-top: 28px; border-radius: var(--radius-lg); padding: 38px; overflow: hidden; }
.reading-panel::before { content: '✦'; position: absolute; right: 34px; top: 20px; color: var(--coral); font-size: 70px; opacity: .14; }
.reading-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 29px; }
.reading-label { margin: 0 0 9px; color: var(--mint); font: 10px var(--mono); letter-spacing: .14em; }
.reading-header h2 { max-width: 720px; margin: 0; font: 600 clamp(25px, 3vw, 40px)/1.2 var(--display); }
.reading-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ai-organize-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; border: 1px solid rgba(200,197,255,.55); border-radius: 999px; padding: 0 13px; background: rgba(200,197,255,.09); color: var(--lavender); font-size: 11px; font-weight: 600; transition: border-color .2s ease, color .2s ease, background .2s ease, transform .2s ease; }
.ai-organize-btn:hover { border-color: var(--mint); color: var(--mint); background: rgba(169,232,202,.09); transform: translateY(-1px); }
.ai-organize-btn.is-loading { border-color: rgba(255,128,107,.65); color: var(--coral-soft); background: rgba(255,128,107,.09); }
.ai-organize-btn:disabled { opacity: .7; cursor: wait; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-bright); border-radius: 50%; background: rgba(255,255,255,.03); color: var(--muted-strong); font-size: 17px; }
.icon-btn:hover, .icon-btn.is-active { border-color: var(--coral); color: var(--coral); background: rgba(255,128,107,.1); }
.match-note { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 24px; padding: 6px 10px; border-radius: 7px; background: rgba(169,232,202,.08); color: var(--mint); font-size: 11px; }
.match-note strong { font-family: var(--mono); }
.cards-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 28px; }
.tarot-card { position: relative; min-height: 190px; padding: 20px 19px 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 15px; background: linear-gradient(145deg, rgba(45,48,91,.9), rgba(25,28,58,.85)); overflow: hidden; }
.tarot-card::after { content: ''; position: absolute; width: 100px; height: 100px; right: -30px; bottom: -42px; border: 1px solid rgba(200,197,255,.2); border-radius: 50%; box-shadow: 0 0 0 13px rgba(200,197,255,.04); }
.tarot-position { margin: 0 0 22px; color: var(--muted); font: 10px var(--mono); letter-spacing: .08em; }
.tarot-glyph { display: grid; place-items: center; width: 41px; height: 41px; margin-bottom: 13px; border: 1px solid var(--coral); border-radius: 11px; color: var(--coral-soft); font: 21px var(--display); }
.tarot-card h3 { margin: 0 0 4px; font: 600 22px var(--display); }
.tarot-card .orientation { color: var(--mint); font: 10px var(--mono); }
.reading-columns { display: grid; grid-template-columns: 1.1fr .9fr; gap: 35px; }
.reading-columns h3 { margin: 0 0 10px; color: var(--coral-soft); font-size: 12px; letter-spacing: .06em; }
.reading-columns p { margin: 0; color: var(--muted-strong); font-size: 13px; line-height: 1.8; }
.action-box { margin-top: 21px; padding: 16px 18px; border-left: 2px solid var(--mint); border-radius: 0 12px 12px 0; background: rgba(169,232,202,.07); }
.action-box strong { display: block; margin-bottom: 4px; color: var(--mint); font-size: 12px; }
.action-box p { color: var(--ink); }
.warning-box { margin-top: 21px; padding: 14px 16px; border: 1px solid rgba(243,216,139,.2); border-radius: 12px; background: rgba(243,216,139,.05); color: var(--yellow); font-size: 11px; line-height: 1.7; }
.followup-wrap { margin-top: 29px; padding-top: 23px; border-top: 1px solid var(--line); }
.followup-wrap > p { margin-bottom: 11px; color: var(--muted); font-size: 11px; }
.followup-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.followup-btn { border: 1px solid var(--line); border-radius: 99px; padding: 8px 12px; background: transparent; color: var(--muted-strong); font-size: 11px; text-align: left; }
.followup-btn:hover { border-color: var(--mint); color: var(--mint); }

.subpage-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; margin-bottom: 42px; }
.subpage-head h1 { margin: 0 0 13px; font: 600 clamp(36px, 5vw, 62px)/1.08 var(--display); letter-spacing: -.04em; }
.subpage-head > div > p:last-child { max-width: 580px; margin: 0; color: var(--muted-strong); font-size: 14px; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.search-box { display: flex; align-items: center; gap: 9px; min-width: 265px; color: var(--muted); }
.search-box > span { font-size: 23px; line-height: 1; }
.search-box input { width: 100%; border: 0; padding: 9px 0; border-radius: 0; background: transparent; font-size: 13px; }
.search-box input:focus { outline: none; }
.search-box kbd { color: var(--muted); }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.question-item { position: relative; display: flex; flex-direction: column; min-height: 210px; padding: 23px 22px 20px; border-radius: 17px; box-shadow: none; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.question-item:hover { transform: translateY(-3px); border-color: rgba(169,232,202,.43); background: rgba(39,44,82,.9); }
.question-item .item-category { margin-bottom: 19px; color: var(--coral-soft); font: 10px var(--mono); letter-spacing: .08em; }
.question-item h3 { margin: 0 0 9px; font: 600 21px/1.25 var(--display); }
.question-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.question-item .item-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 19px; }
.item-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.item-tag { color: #8589a2; font-size: 10px; }
.item-use { border: 0; color: var(--mint); background: transparent; font-size: 11px; white-space: nowrap; }
.item-use:hover { color: var(--ink); }
.item-favorite { position: absolute; top: 15px; right: 16px; border: 0; color: #777b98; background: transparent; font-size: 18px; }
.item-favorite.is-active { color: var(--coral); }
.empty-state { grid-column: 1 / -1; padding: 65px 20px; border: 1px dashed var(--line-bright); border-radius: 17px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); font: 600 21px var(--display); }

.history-head { margin-bottom: 30px; }
.history-switch { display: flex; gap: 21px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.history-tab { border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 11px 3px 14px; background: transparent; color: var(--muted); font-size: 12px; }
.history-tab.is-active { border-color: var(--coral); color: var(--ink); }
.history-tab span { margin-left: 4px; color: var(--muted); font: 10px var(--mono); }
.history-list { display: grid; gap: 12px; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 20px 22px; border-radius: 16px; box-shadow: none; }
.history-date { margin-bottom: 6px; color: var(--muted); font: 10px var(--mono); }
.history-item h3 { margin: 0 0 6px; font: 500 20px var(--display); }
.history-item p { margin: 0; max-width: 750px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-actions { display: flex; align-items: center; gap: 8px; }
.history-actions .ghost-btn { min-height: 36px; padding: 0 13px; font-size: 11px; }
.history-empty { padding: 76px 20px; border: 1px dashed var(--line-bright); border-radius: 17px; text-align: center; }
.history-empty .empty-symbol { margin-bottom: 15px; color: var(--coral); font-size: 27px; }
.history-empty h2 { margin: 0 0 7px; font: 600 25px var(--display); }
.history-empty p { margin: 0 0 20px; color: var(--muted); font-size: 12px; }

.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.app-footer p { margin: 0; }
.footer-mark { margin-right: 7px; color: var(--coral); font-size: 14px; }
.text-btn { border: 0; padding: 5px 0; background: transparent; color: var(--muted-strong); font-size: 11px; }
.text-btn:hover { color: var(--mint); }

.modal { width: min(540px, calc(100% - 30px)); max-height: calc(100dvh - 30px); padding: 0; border: 0; border-radius: 21px; background: transparent; color: var(--ink); }
.modal::backdrop { background: rgba(3, 5, 17, .77); backdrop-filter: blur(5px); }
.modal-card { position: relative; padding: 34px 35px 31px; border: 1px solid var(--line-bright); border-radius: 21px; background: #1a1d3a; box-shadow: 0 30px 100px rgba(0,0,0,.45); }
.modal-card h2 { margin: 0 0 9px; font: 600 31px/1.2 var(--display); }
.modal-intro { margin: 0 0 24px; color: var(--muted); font-size: 12px; }
.modal-card label { display: block; margin: 14px 0 7px; color: var(--muted-strong); font-size: 11px; }
.modal-card input, .modal-card textarea, .modal-card select { display: block; width: 100%; padding: 12px 13px; font-size: 13px; }
.modal-card textarea { resize: vertical; line-height: 1.65; }
.modal-card select { appearance: auto; }
.modal-card input:focus, .modal-card textarea:focus, .modal-card select:focus { border-color: var(--mint); outline: none; box-shadow: 0 0 0 4px rgba(169,232,202,.08); }
.modal-close { position: absolute; right: 15px; top: 13px; width: 31px; height: 31px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.modal-close:hover { background: rgba(255,255,255,.08); color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.ai-modal { width: min(760px, calc(100% - 30px)); }
.ai-settings-card { max-height: calc(100dvh - 30px); overflow: auto; padding: 34px 35px 28px; }
.ai-security-note { max-width: 680px; line-height: 1.75; }
.ai-connection-manager { margin: 4px 0 23px; padding: 18px 17px 14px; border: 1px solid rgba(200,197,255,.22); border-radius: 15px; background: rgba(200,197,255,.045); }
.ai-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.ai-section-heading .section-index { margin-bottom: 4px; }
.ai-section-heading h3 { margin: 0; font: 600 20px/1.2 var(--display); }
.ai-local-badge { border: 1px solid rgba(169,232,202,.33); border-radius: 99px; padding: 4px 8px; color: var(--mint); font: 9px var(--mono); white-space: nowrap; }
.ai-current-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; }
.ai-current-select { min-width: 0; width: 100%; padding: 11px 12px; }
.ai-current-row .compact { min-height: 42px; padding: 0 13px; font-size: 11px; }
.danger-btn { color: var(--coral-soft); }
.danger-btn:hover { border-color: var(--coral); color: var(--coral); background: rgba(255,128,107,.08); }
.ai-connection-list { display: grid; gap: 6px; margin-top: 12px; }
.ai-connection-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 9px; border: 1px solid transparent; border-radius: 10px; }
.ai-connection-row.is-active { border-color: rgba(169,232,202,.27); background: rgba(169,232,202,.055); }
.ai-connection-row.is-editing { box-shadow: inset 2px 0 var(--coral); }
.ai-connection-select { display: flex; align-items: center; min-width: 0; gap: 9px; border: 0; padding: 2px; background: transparent; color: var(--ink); text-align: left; }
.ai-connection-select:hover .ai-connection-copy strong { color: var(--mint); }
.ai-connection-radio { flex: 0 0 12px; width: 12px; height: 12px; border: 1px solid var(--muted); border-radius: 50%; }
.ai-connection-row.is-active .ai-connection-radio { border-color: var(--mint); background: var(--mint); box-shadow: inset 0 0 0 3px var(--bg-soft); }
.ai-connection-copy { display: flex; flex-direction: column; min-width: 0; }
.ai-connection-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.ai-connection-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.ai-connection-state { color: var(--muted); font-size: 9px; white-space: nowrap; }
.ai-connection-state.has-key { color: var(--mint); }
.ai-enabled-mini { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.ai-enabled-mini input { accent-color: var(--mint); }
.ai-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 15px; }
.ai-field { min-width: 0; }
.ai-field-wide { grid-column: 1 / -1; }
.ai-field label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-hint { color: #8589a2; font-size: 10px; font-weight: 400; }
.ai-key-wrap { position: relative; }
.ai-key-wrap input { padding-right: 95px; }
.ai-clear-key { position: absolute; right: 8px; top: 50%; border: 0; border-radius: 7px; padding: 5px 7px; background: rgba(255,255,255,.06); color: var(--muted); font-size: 10px; transform: translateY(-50%); }
.ai-clear-key:hover { color: var(--coral-soft); background: rgba(255,128,107,.1); }
.ai-field-note { min-height: 17px; margin: 5px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.ai-enabled-toggle { display: flex !important; align-items: flex-start; justify-content: flex-start !important; gap: 9px; margin: 18px 0 0 !important; padding: 11px 12px; border: 1px solid rgba(169,232,202,.2); border-radius: 10px; background: rgba(169,232,202,.04); cursor: pointer; }
.ai-enabled-toggle input { flex: 0 0 auto; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--mint); }
.ai-enabled-toggle span { display: flex; flex-direction: column; gap: 2px; }
.ai-enabled-toggle strong { color: var(--mint); font-size: 12px; }
.ai-enabled-toggle small { color: var(--muted); font-size: 10px; font-weight: 400; }
.ai-test-row { display: flex; align-items: center; gap: 12px; min-height: 43px; margin-top: 12px; }
.ai-test-row .ghost-btn { min-height: 38px; padding: 0 14px; font-size: 11px; }
#aiSettingsStatus { color: var(--muted); font-size: 10px; line-height: 1.5; }
#aiSettingsStatus.is-ok { color: var(--mint); }
#aiSettingsStatus.is-error { color: var(--coral-soft); }
#aiSettingsStatus.is-loading { color: var(--yellow); }
#aiSettingsStatus.is-muted { color: var(--muted); }
.ai-skills-note { margin-top: 12px; padding: 12px 13px; border-top: 1px solid var(--line); color: var(--muted); }
.ai-skills-note summary { cursor: pointer; color: var(--lavender); font-size: 12px; }
.ai-skills-note p { margin: 9px 0 0; font-size: 11px; line-height: 1.7; }
.ai-modal-actions { align-items: center; flex-wrap: wrap; }
.ai-clear-all { margin-right: auto; border-color: rgba(255,128,107,.28); color: var(--coral-soft); }
.ai-clear-all:hover { border-color: var(--coral); color: var(--coral); }
.ai-result { margin-top: 25px; padding: 25px 27px 24px; border: 1px solid rgba(200,197,255,.35); border-radius: 17px; background: linear-gradient(145deg, rgba(44,44,86,.82), rgba(26,29,58,.8)); }
.ai-result.is-error { border-color: rgba(255,128,107,.42); background: rgba(255,128,107,.055); }
.ai-result.is-notice, .ai-result.is-cancelled { border-color: rgba(243,216,139,.32); background: rgba(243,216,139,.045); }
.ai-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.ai-result-head h3 { margin: 0; color: var(--ink); font: 600 23px/1.25 var(--display); }
.ai-result .reading-label { margin-bottom: 8px; }
.ai-result-note { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.ai-result-dismiss { flex: 0 0 auto; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 21px; line-height: 1; }
.ai-result-dismiss:hover { background: rgba(255,255,255,.08); color: var(--ink); }
.ai-spinner { flex: 0 0 auto; width: 20px; height: 20px; border: 2px solid rgba(200,197,255,.25); border-top-color: var(--mint); border-radius: 50%; animation: aiSpin .8s linear infinite; }
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-output { margin-top: 19px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted-strong); font-size: 13px; line-height: 1.85; }
.ai-output h4 { margin: 17px 0 7px; color: var(--coral-soft); font: 600 15px var(--display); }
.ai-output h4:first-child { margin-top: 0; }
.ai-output p { margin: 0 0 9px; }
.ai-output ul { margin: 0 0 11px; padding-left: 20px; }
.ai-output li { margin: 4px 0; }
.ai-output strong { color: var(--ink); }
.ai-output em { color: var(--mint); font-style: normal; }
.ai-output code { padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.2); color: var(--lavender); font: 11px var(--mono); }
.ai-result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.ai-result-actions .compact { min-height: 36px; font-size: 11px; }
.info-modal .modal-card > p:not(.section-index) { color: var(--muted-strong); font-size: 13px; line-height: 1.8; }
.about-points { display: grid; gap: 10px; margin: 22px 0 25px; }
.about-points p { margin: 0; padding: 11px 13px; border-radius: 9px; background: rgba(255,255,255,.04); color: var(--muted); font-size: 12px; }
.about-points b { display: inline-block; min-width: 65px; color: var(--mint); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; max-width: calc(100% - 32px); padding: 11px 17px; border: 1px solid rgba(169,232,202,.35); border-radius: 99px; background: #252b50; color: var(--ink); font-size: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: opacity .25s ease, transform .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .app-shell { padding: 0 30px; }
  .ai-settings-btn { margin-left: 4px; }
  .hero-grid, .ask-layout { grid-template-columns: minmax(0, 1fr); gap: 35px; }
  .hero-grid { margin-bottom: 42px; }
  .compass-note { display: grid; grid-template-columns: auto 1fr; column-gap: 20px; align-items: center; padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--line-bright); }
  .compass-note::before { left: 0; top: -1px; width: 80px; height: 1px; }
  .compass-rose { grid-row: span 2; margin-bottom: 0; }
  .note-kicker { margin-bottom: 4px; }
  .note-quote { margin-bottom: 4px; }
  .side-rail { grid-template-columns: 1fr 1fr; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .app-shell { padding: 0 17px; }
  .topbar { min-height: 74px; align-items: flex-start; padding-top: 15px; }
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 13px; }
  .ai-settings-btn { position: absolute; top: 15px; right: 62px; margin: 0; padding: 7px 9px; font-size: 10px; }
  .ai-settings-btn .ai-settings-glyph { font-size: 13px; }
  .main-nav { position: absolute; top: 67px; left: -5px; right: -5px; justify-content: space-between; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: rgba(17,19,42,.9); }
  .nav-item { flex: 1; padding: 9px 4px; font-size: 11px; }
  .nav-item.is-active::after { bottom: -6px; }
  .install-btn { padding: 7px 9px; font-size: 10px; }
  .view { padding-top: 106px; }
  .hero-copy h1 { font-size: clamp(42px, 14vw, 67px); }
  .hero-lede { font-size: 13px; line-height: 1.8; }
  .hero-proof { gap: 17px; }
  .hero-proof strong { font-size: 17px; }
  .hero-proof span { font-size: 10px; }
  .question-card { padding: 26px 19px 23px; border-radius: 18px; }
  .card-heading { margin-bottom: 20px; }
  .card-heading h2 { font-size: 26px; }
  .live-pill { font-size: 9px; }
  #questionInput { min-height: 138px; font-size: 14px; }
  .input-meta { font-size: 10px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .primary-btn, .ghost-btn { width: 100%; }
  .keyboard-tip { text-align: center; }
  .side-rail { grid-template-columns: 1fr; gap: 12px; }
  .rail-card { padding: 21px 19px; }
  .reading-panel { padding: 25px 19px; border-radius: 18px; }
  .reading-header { display: block; margin-bottom: 22px; }
  .reading-header h2 { font-size: 28px; }
  .reading-actions { margin-top: 15px; }
  .reading-actions { flex-wrap: wrap; }
  .ai-organize-btn { min-height: 36px; }
  .cards-row { grid-template-columns: 1fr; gap: 9px; }
  .tarot-card { min-height: 0; padding: 16px; }
  .tarot-position { margin-bottom: 12px; }
  .tarot-glyph { display: inline-grid; width: 34px; height: 34px; margin: 0 8px 0 0; vertical-align: middle; }
  .tarot-card h3 { display: inline; font-size: 20px; vertical-align: middle; }
  .tarot-card .orientation { display: block; margin: 9px 0 0 43px; }
  .reading-columns { grid-template-columns: 1fr; gap: 20px; }
  .subpage-head { display: block; margin-bottom: 28px; }
  .subpage-head h1 { font-size: 42px; }
  .subpage-head .primary-btn, .subpage-head .ghost-btn { width: auto; margin-top: 20px; }
  .library-toolbar { display: block; margin-bottom: 18px; }
  .search-box { min-width: 0; margin-bottom: 15px; }
  .library-grid { grid-template-columns: 1fr; }
  .question-item { min-height: 190px; }
  .history-item { grid-template-columns: 1fr; gap: 14px; padding: 17px; }
  .history-item p { white-space: normal; }
  .history-actions { justify-content: flex-end; }
  .history-actions .ghost-btn { width: auto; }
  .app-footer { margin-top: 10px; padding-bottom: 22px; }
  .modal-card { padding: 29px 20px 24px; }
  .modal-card h2 { font-size: 27px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .primary-btn, .modal-actions .ghost-btn { width: 100%; }
  .ai-settings-card { padding: 29px 20px 24px; }
  .ai-current-row { grid-template-columns: minmax(0, 1fr) repeat(3, auto); gap: 5px; }
  .ai-current-row .compact { padding: 0 8px; font-size: 10px; }
  .ai-connection-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
  .ai-connection-state { display: none; }
  .ai-enabled-mini { grid-column: 2; justify-self: end; }
  .ai-form-grid { grid-template-columns: 1fr; }
  .ai-field-wide { grid-column: auto; }
  .ai-field label { font-size: 11px; }
  .ai-modal-actions { align-items: stretch; }
  .ai-modal-actions .ai-clear-all { margin-right: 0; }
  .ai-test-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .ai-test-row .ghost-btn { width: auto; }
  .ai-result { padding: 21px 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
