:root {
  --bg: #0d0a1e;
  --bg2: #161130;
  --card: rgba(255, 255, 255, 0.045);
  --card-b: rgba(232, 195, 106, 0.16);
  --gold: #e8c36a;
  --gold2: #f6e3a8;
  --text: #ece7f6;
  --muted: #a49bbd;
  --pos: #8fd6a8;
  --neg: #e48a8a;
  --neu: #6f668a;
  --violet: #8b6cf0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100vh; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 108, 240, 0.25), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(232, 195, 106, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
}
.sky::after {
  content: ""; position: absolute; inset: 0; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 72% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 30%, #fff, transparent),
    radial-gradient(1px 1px at 88% 42%, #fff, transparent),
    radial-gradient(1px 1px at 22% 62%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60% 76%, #fff, transparent),
    radial-gradient(1px 1px at 8% 88%, #fff, transparent),
    radial-gradient(1px 1px at 92% 90%, #fff, transparent),
    radial-gradient(1px 1px at 50% 52%, #fff, transparent);
}

.app {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 40px);
}

/* header */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; letter-spacing: .02em; color: var(--gold2); }
.brand .date { color: var(--muted); font-size: 14px; margin-top: 2px; }
.brand .date::first-letter { text-transform: uppercase; }
.chip {
  border: 1px solid var(--card-b); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--card-b); background: var(--card);
  display: grid; place-items: center; font-size: 18px; flex: none;
}

.card {
  background: var(--card); border: 1px solid var(--card-b); border-radius: var(--r);
  padding: 18px; margin-bottom: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* consensus */
.hero { text-align: center; padding: 26px 18px 20px; position: relative; overflow: hidden; }
.orb {
  width: 132px; height: 132px; margin: 6px auto 14px; border-radius: 50%; position: relative;
  display: grid; place-items: center; font-family: var(--serif); font-size: 40px; color: #1a1430;
  background: radial-gradient(circle at 35% 30%, #fff8dc, var(--gold) 45%, #9b6f22 100%);
  box-shadow: 0 0 60px rgba(232, 195, 106, var(--glow, .35)), inset 0 -8px 20px rgba(0,0,0,.25);
}
.orb.dim { background: radial-gradient(circle at 35% 30%, #d9d2ef, #7e74a6 50%, #3b3360 100%); color: #f4f0ff; }
.orb .ring { position: absolute; inset: -10px; border-radius: 50%; border: 1px dashed rgba(232,195,106,.35); animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero h2 { font-family: var(--serif); font-weight: 600; font-size: 28px; margin: 0 0 8px; color: var(--gold2); }
.hero p { margin: 6px 0; line-height: 1.45; }
.hero .best b { color: var(--pos); font-weight: 600; }
.hero .worst b { color: var(--neg); font-weight: 600; }
.agree { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.agree .pips { display: inline-flex; gap: 3px; }
.agree .pips i { width: 14px; height: 4px; border-radius: 2px; background: var(--neu); }
.agree .pips i.on { background: var(--gold); }

/* themes */
.theme { display: grid; grid-template-columns: 88px 1fr; gap: 6px 12px; align-items: center; padding: 9px 0; }
.theme + .theme { border-top: 1px solid rgba(255,255,255,.05); }
.theme .name { font-size: 15px; }
.bar { position: relative; height: 10px; background: rgba(255,255,255,.06); border-radius: 5px; }
.bar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: rgba(255,255,255,.25); }
.bar .fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; transition: all .6s ease; }
.bar .fill.p { left: 50%; background: linear-gradient(90deg, rgba(143,214,168,.5), var(--pos)); }
.bar .fill.n { right: 50%; background: linear-gradient(270deg, rgba(228,138,138,.5), var(--neg)); }
.votes { grid-column: 2; display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--muted); }
.votes .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neu); }
.votes .dot.p { background: var(--pos); }
.votes .dot.n { background: var(--neg); }
.votes .dot.x { background: transparent; border: 1px dashed var(--neu); }
.votes span { margin-left: 4px; }

/* draw */
.draw { text-align: center; }
.draw h3 { font-family: var(--serif); font-size: 20px; margin: 4px 0 8px; color: var(--gold2); font-weight: 600; }
.draw p { color: var(--muted); margin: 0 0 16px; line-height: 1.45; font-size: 15px; }
.btn {
  border: none; border-radius: 999px; padding: 14px 28px; font-weight: 600; font-size: 16px;
  background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1a1430;
  box-shadow: 0 6px 24px rgba(232,195,106,.3);
}
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--card-b); box-shadow: none; font-weight: 500; padding: 10px 18px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--neg); border: 1px solid rgba(228,138,138,.3); box-shadow: none; }
.btn.wide { width: 100%; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* systems */
.sys { display: grid; grid-template-columns: 54px 1fr; gap: 14px; align-items: start; }
.glyph {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center;
  font-size: 28px; font-family: var(--serif); color: var(--gold2);
  background: linear-gradient(160deg, rgba(139,108,240,.35), rgba(139,108,240,.08));
  border: 1px solid rgba(139,108,240,.35);
}
.glyph.rev { transform: rotate(180deg); }
.sys h4 { margin: 2px 0 2px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sys .main { font-family: var(--serif); font-size: 19px; color: var(--gold2); margin-bottom: 4px; }
.sys .txt { font-size: 14.5px; line-height: 1.45; color: var(--text); }
.sys .sub { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.mini { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mini span { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.05); color: var(--muted); }
.mini span.p { color: var(--pos); background: rgba(143,214,168,.1); }
.mini span.n { color: var(--neg); background: rgba(228,138,138,.1); }
.hexlines { display: inline-flex; flex-direction: column-reverse; gap: 3px; }
.hexlines i { display: block; width: 28px; height: 4px; border-radius: 1px; background: var(--gold2); }
.hexlines i.yin { background: linear-gradient(90deg, var(--gold2) 0 40%, transparent 40% 60%, var(--gold2) 60%); }
.hexlines i.chg { box-shadow: 0 0 6px var(--violet); background-color: var(--violet); }
.hexlines i.yin.chg { background: linear-gradient(90deg, #b9a4ff 0 40%, transparent 40% 60%, #b9a4ff 60%); }
.sys.pending { opacity: .45; }

.reveal { animation: reveal .7s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.source { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); }
.source .atom { font-size: 22px; }
.source b { color: var(--text); font-weight: 600; display: block; font-size: 14px; }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 22px 8px 0; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(5, 3, 14, .72); display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg2); border: 1px solid var(--card-b); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 22px 18px calc(env(safe-area-inset-bottom) + 22px);
  max-height: 88vh; overflow-y: auto; animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { font-family: var(--serif); color: var(--gold2); font-size: 22px; margin: 0 0 16px; font-weight: 600; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field small { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--card-b);
  background: rgba(255,255,255,.05); font-size: 16px; color-scheme: dark;
}
.actions { display: flex; gap: 10px; margin-top: 8px; }
.actions .btn { flex: 1; }
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.list button {
  display: flex; justify-content: space-between; align-items: center; text-align: left;
  padding: 13px 14px; border-radius: 12px; border: 1px solid var(--card-b); background: rgba(255,255,255,.04);
}
.list button.active { border-color: var(--gold); }
.list button small { color: var(--muted); }
.seg { display: flex; gap: 6px; margin-bottom: 18px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--card-b); background: transparent; font-size: 14px; }
.seg button.on { background: var(--gold); color: #1a1430; border-color: var(--gold); font-weight: 600; }
.welcome { text-align: center; padding-top: 8vh; }
.welcome .orb { width: 110px; height: 110px; font-size: 34px; }
.welcome h2 { font-family: var(--serif); color: var(--gold2); font-size: 30px; margin: 10px 0; font-weight: 600; }
.welcome p { color: var(--muted); line-height: 1.55; margin: 0 6px 22px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--gold); color: #1a1430; padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 30; font-size: 14px;
}
.toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* written horoscope */
.story p { font-family: var(--serif); font-size: 17px; line-height: 1.6; margin: 12px 0 0; color: var(--text); }
.story p:first-of-type::first-letter { font-size: 2.6em; float: left; line-height: .9; margin: 4px 8px 0 0; color: var(--gold); }
.story p:last-child { color: var(--gold2); font-style: italic; }
