/* MAGI SYSTEM — EVA 風格致敬（不使用原作素材） */
:root {
  --bg: #040506;
  --panel: #07090b;
  --orange: #ff8a1e;
  --orange-dim: #a85a14;
  --green: #36ff8a;
  --green-dim: #1a7a45;
  --red: #ff3340;
  --red-dim: #7a1a20;
  --cyan: #4fd8ff;
  --text: #ffd9b0;
  --muted: #a8805a;
  --line: rgba(255, 138, 30, .35);
  --serif: "Noto Serif TC", "Songti TC", serif;
  --mono: "Share Tech Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  background:
    linear-gradient(rgba(255,138,30,.035) 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, rgba(255,138,30,.035) 1px, transparent 1px) 0 0 / 24px 100%,
    var(--bg);
  min-height: 100vh;
}
.mono { font-family: var(--mono); }
.scanlines {
  pointer-events: none; position: fixed; inset: 0; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
a { color: var(--orange); }

/* ---------- 共用元件 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.frame { border: 1px solid var(--line); background: rgba(7,9,11,.85); position: relative; }
.frame::before, .frame::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--orange);
}
.frame::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.frame::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }
.stripe {
  height: 10px;
  background: repeating-linear-gradient(-45deg, var(--orange) 0 10px, #000 10px 20px);
  opacity: .9;
}
.section { margin-top: 22px; }
.section-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--orange); padding-bottom: 4px; margin-bottom: 12px;
}
.section-head h2 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 22px; color: var(--orange); letter-spacing: .08em; }
.section-head .en { color: var(--muted); font-size: 12px; letter-spacing: .2em; }
.section-head .right { margin-left: auto; color: var(--muted); font-size: 12px; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid currentColor; font-size: 12px; line-height: 18px; }
.c-buy { color: var(--green); } .c-avoid { color: var(--red); } .c-hold { color: var(--orange); } .c-none { color: var(--muted); }
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------- 標頭 ---------- */
header.top { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding-top: 6px; }
.brand { font-family: var(--serif); font-weight: 900; font-size: 34px; color: var(--orange); letter-spacing: .12em; line-height: 1; }
.brand small { font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: .3em; margin-left: 10px; }
.top-meta { text-align: right; font-size: 12px; color: var(--muted); }
.top-meta b { color: var(--text); font-weight: normal; }
.top-meta a { margin-left: 10px; }
.proposal {
  margin-top: 10px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 13px;
}
.proposal .k { color: var(--muted); } .proposal .v { color: var(--text); }

/* ---------- MAGI 三角主畫面 ---------- */
.magi {
  position: relative; margin: 18px auto 6px; max-width: 920px; aspect-ratio: 920 / 520;
}
.magi svg.links { position: absolute; inset: 0; width: 100%; height: 100%; }
.magi svg.links line { stroke: var(--orange); stroke-width: 2; opacity: .55; }
.unit {
  position: absolute; width: 36%; height: 40%;
  background: var(--panel); color: #000;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  cursor: default; transition: filter .2s;
}
.unit .face {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 6% 8%;
}
.unit .uname { font-family: var(--serif); font-weight: 900; font-size: clamp(16px, 2.6vw, 28px); letter-spacing: .06em; line-height: 1.1; }
.unit .urole { font-size: clamp(10px, 1.2vw, 13px); letter-spacing: .15em; opacity: .85; }
.unit .uverdict { font-family: var(--serif); font-weight: 900; font-size: clamp(22px, 4vw, 44px); line-height: 1.15; margin-top: 2px; }
.unit .ucounts { font-size: clamp(10px, 1.3vw, 14px); margin-top: 2px; }
.unit.buy { background: var(--green); } .unit.avoid { background: var(--red); } .unit.hold { background: var(--orange); }
.unit.none { background: #2a1a0c; color: var(--muted); }
/* BALTHASAR 上、CASPER 左下、MELCHIOR 右下（原作配置） */
.u-balthasar { left: 32%; top: 2%; clip-path: polygon(0 0, 100% 0, 100% 72%, 78% 100%, 22% 100%, 0 72%); }
.u-casper { left: 2%; top: 56%; clip-path: polygon(0 0, 70% 0, 100% 34%, 100% 100%, 0 100%); }
.u-melchior { right: 2%; top: 56%; clip-path: polygon(30% 0, 100% 0, 100% 100%, 0 100%, 0 34%); }
.core {
  position: absolute; left: 50%; top: 61%; transform: translate(-50%, -50%);
  width: 24%; text-align: center; border: 1px solid var(--orange); background: rgba(0,0,0,.85); padding: 10px 6px;
}
.core .label { font-family: var(--serif); font-weight: 900; color: var(--orange); font-size: clamp(16px, 2.4vw, 26px); letter-spacing: .3em; }
.core .result { font-family: var(--serif); font-weight: 900; font-size: clamp(22px, 4.2vw, 46px); line-height: 1.1; }
.core .sub { font-size: clamp(10px, 1.2vw, 13px); color: var(--muted); }
.magi-legend { text-align: center; font-size: 12px; color: var(--muted); }
.magi-legend span { margin: 0 8px; }

/* ---------- 系統狀態 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.box { padding: 12px 14px; }
.box h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .2em; color: var(--muted); font-weight: normal; }
table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv td { padding: 3px 4px; border-bottom: 1px dashed rgba(255,138,30,.18); }
table.kv td:last-child { text-align: right; }
.ok { color: var(--green); } .ng { color: var(--red); } .run { color: var(--cyan); } .stale { color: var(--red); }

/* ---------- 決議名單 ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button {
  font-family: var(--mono); font-size: 13px; background: transparent; color: var(--orange);
  border: 1px solid var(--orange-dim); padding: 4px 10px; cursor: pointer;
}
.tabs button.on { background: var(--orange); color: #000; border-color: var(--orange); }
.tabs .sep { width: 1px; background: var(--line); margin: 0 4px; }
.list { display: grid; gap: 6px; }
.row { border: 1px solid rgba(255,138,30,.25); background: rgba(7,9,11,.9); }
.row-main { display: grid; grid-template-columns: 74px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 10px; cursor: pointer; }
.row-main:hover { background: rgba(255,138,30,.06); }
.sid { color: var(--orange); }
.sname { font-family: var(--serif); font-weight: 700; color: var(--text); }
.sname small { font-family: var(--mono); color: var(--muted); font-weight: normal; margin-left: 6px; font-size: 11px; }
.lamps { display: flex; gap: 4px; }
.lamp { width: 30px; height: 20px; font-size: 10px; line-height: 20px; text-align: center; color: #000; clip-path: polygon(15% 0, 100% 0, 85% 100%, 0 100%); }
.lamp.buy { background: var(--green); } .lamp.avoid { background: var(--red); } .lamp.hold { background: var(--orange); }
.lamp.skip { background: #3a2a1a; color: var(--muted); } .lamp.none { background: #1a1a1a; color: #555; }
.verdict { font-family: var(--serif); font-weight: 900; font-size: 18px; min-width: 52px; text-align: right; }
.detail { display: none; border-top: 1px dashed rgba(255,138,30,.25); padding: 8px 10px 10px; font-size: 13px; }
.row.open .detail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.agent-col h4 { margin: 0 0 4px; font-size: 13px; letter-spacing: .1em; }
.agent-col ul { margin: 0; padding-left: 16px; }
.agent-col li { margin: 2px 0; color: var(--text); }
.agent-col li.risk { color: #d9a07a; }
.empty { color: var(--muted); padding: 12px; text-align: center; border: 1px dashed var(--line); }

/* ---------- 圖表 / 績效 ---------- */
.chart-box { padding: 10px; height: 300px; overflow: hidden; position: relative; }
.chart-box canvas { max-width: 100%; }
@media (max-width: 700px) { .chart-box { height: 400px; } }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.cd { text-align: center; padding: 14px 8px; }
.cd .h { color: var(--muted); font-size: 12px; letter-spacing: .2em; }
.cd .n { font-family: var(--serif); font-weight: 900; font-size: 44px; color: var(--orange); line-height: 1.1; }
.cd .d { font-size: 12px; color: var(--muted); }
.cd.done .n { color: var(--green); }
table.perf { width: 100%; border-collapse: collapse; font-size: 13px; }
table.perf th, table.perf td { padding: 4px 6px; border-bottom: 1px solid rgba(255,138,30,.18); text-align: right; white-space: nowrap; }
table.perf th { color: var(--muted); font-weight: normal; }
table.perf td:first-child, table.perf th:first-child { text-align: left; }
.pos { color: var(--green); } .neg { color: var(--red); }
.scroll-x { overflow-x: auto; }
footer { margin: 30px 0 10px; text-align: center; color: var(--muted); font-size: 11px; letter-spacing: .15em; }

/* ---------- 登入 ---------- */
body.login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; padding: 0; text-align: center; }
.login-title { font-family: var(--serif); font-weight: 900; font-size: 52px; color: var(--orange); letter-spacing: .15em; margin-top: 22px; }
.login-title span { display: block; font-family: var(--mono); font-size: 14px; letter-spacing: .6em; color: var(--muted); }
.login-sub { color: var(--muted); font-size: 12px; letter-spacing: .3em; margin: 10px 0 18px; }
.login-box input, .login-box button {
  display: block; width: calc(100% - 48px); margin: 0 24px 12px; padding: 10px; font-size: 16px;
  background: #000; color: var(--text); border: 1px solid var(--orange);
}
.login-box button { background: var(--orange); color: #000; cursor: pointer; letter-spacing: .2em; }
.login-box button:disabled, .login-box input:disabled { opacity: .4; cursor: not-allowed; }
.login-msg { color: var(--red); font-size: 13px; margin: 0 24px 16px; }

/* ---------- 手機 ---------- */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .brand { font-size: 26px; }
  header.top { grid-template-columns: 1fr; }
  .top-meta { text-align: left; }
  /* 手機也維持三角配置：改成接近正方形的比例，面板放大、字縮小 */
  .magi { aspect-ratio: 1 / 1.05; margin-top: 12px; }
  .magi svg.links { display: none; }
  .unit { width: 48%; height: 36%; }
  .u-balthasar { left: 26%; top: 0; }
  .u-casper { left: 0; top: 62%; }
  .u-melchior { right: 0; top: 62%; }
  .unit .face { padding: 4px 6px; }
  .unit .uname { font-size: 15px; }
  .unit .urole { font-size: 10px; letter-spacing: .05em; }
  .unit .uverdict { font-size: 26px; }
  .unit .ucounts { font-size: 10px; }
  .core { top: 49%; width: 46%; padding: 6px 4px; }
  .core .label { font-size: 15px; }
  .core .result { font-size: 24px; }
  .core .result.c-avoid { font-size: 16px !important; }
  .core .sub { font-size: 9px; }
  .grid2 { grid-template-columns: 1fr; }
  .row-main { grid-template-columns: 52px 1fr auto; }
  .row-main .verdict { grid-column: 3; grid-row: 1; }
  .row-main .lamps { grid-column: 2 / 4; }
  .row.open .detail { grid-template-columns: 1fr; }
  .countdown { grid-template-columns: 1fr 1fr; }
  .cd .n { font-size: 32px; }
}

/* 成績單（2026-10-28） */
.hbtn { font-family: var(--mono); font-size: 12px; background: transparent; color: var(--orange); border: 1px solid var(--orange-dim); padding: 1px 8px; margin-left: 4px; cursor: pointer; }
.hbtn.on { background: var(--orange); color: #000; }
.warn { border: 1px solid var(--orange); color: var(--orange); padding: 6px 10px; margin: 6px 0 10px; font-size: 13px; }
table.perf.card td:first-child { font-family: var(--serif); font-weight: 700; }
table.perf.card th small { color: var(--muted); font-size: 10px; }
.bar { position: relative; height: 4px; background: rgba(255,138,30,.15); margin-top: 3px; }
.bar span { position: absolute; top: 0; height: 4px; }
.bar .bpos { background: var(--green); } .bar .bneg { background: var(--red); }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
details.more[open] summary { color: var(--orange); }

/* 「！」說明按鈕（2026-10-28） */
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-left: 6px;
  border-radius: 50%; border: 1px solid #ffd23f; background: transparent; color: #ffd23f; font: bold 11px/1 var(--mono);
  cursor: pointer; vertical-align: middle; padding: 0; flex: none; }
.ibtn:hover { background: #ffd23f; color: #000; }
.ipop { display: block; margin: 6px 0 4px; padding: 8px 10px; border-left: 3px solid #ffd23f; background: rgba(255,210,63,.08);
  color: var(--text); font: 13px/1.7 var(--mono); letter-spacing: 0; text-transform: none; font-weight: normal; white-space: normal; }
.section-head .ipop { flex-basis: 100%; }
.legend-info { margin-top: 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.legend-info .ipop { flex-basis: 100%; text-align: left; }
.subhead { margin: 14px 0 6px; font-size: 13px; letter-spacing: .2em; color: var(--muted); font-weight: normal; }
table.perf.card td:first-child .ipop { font-family: var(--mono); }

/* 今日決議搜尋（2026-11-02） */
.search-box { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.search-box input { flex: 1; max-width: 420px; font-family: var(--mono); font-size: 14px; padding: 6px 10px;
  background: #000; color: var(--orange); border: 1px solid var(--orange-dim); outline: none; }
.search-box input:focus { border-color: var(--orange); }
.tabs.dim button { opacity: .35; }
.search-note { font-family: var(--mono); font-size: 12px; color: var(--orange); align-self: center; margin-left: 6px; }

/* 今日摘要（2026-11-10） */
.digest .digest-head { font-size: 15px; color: #ffd9b0; margin-bottom: 8px; line-height: 1.6; }
.digest .digest-sec summary { font-size: 14px; }
.digest ul { margin: 4px 0 8px 18px; padding: 0; }
.digest li { margin: 3px 0; line-height: 1.55; font-size: 13px; }
.digest .digest-dots { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: #c9a27a; margin-bottom: 6px; }
