@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+TC:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;1,600;1,700&display=swap');

:root {
  --paper: #f5f3ed;
  --paper-deep: #ebe8df;
  --ink: #1f2421;
  --muted: #737972;
  --line: #d9d7ce;
  --forest: #1d4938;
  --forest-deep: #14352a;
  --lime: #d4f05d;
  --orange: #fa754d;
  --cream: #fffdf7;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
  --sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'PingFang TC', sans-serif;
  --serif: 'Playfair Display', 'Songti TC', serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
.app-shell { width: min(100%, 720px); margin: 0 auto; padding: 20px 20px calc(30px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 11px; padding: 3px 0 25px; }
.brand-mark { display: flex; align-items: center; justify-content: center; width: 49px; height: 49px; gap: 1px; border-radius: 15px; background: var(--forest); color: var(--lime); font: 500 13px var(--mono); letter-spacing: -2px; transform: rotate(-4deg); }
.brand-mark span:nth-child(2) { color: var(--cream); }
.brand-copy { flex: 1; }
.eyebrow, .section-kicker, .hero-label { margin: 0; color: var(--muted); font: 500 10px var(--mono); letter-spacing: .11em; }
.brand-copy h1 { margin: 2px 0 0; font-size: 17px; letter-spacing: .02em; }
.privacy-pill { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font: 10px var(--mono); white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #56a276; box-shadow: 0 0 0 3px #dceee2; }
.hero { position: relative; overflow: hidden; padding: 29px 25px 27px; border-radius: 24px; background: var(--forest); color: var(--cream); box-shadow: 0 14px 30px rgba(20, 53, 42, .13); }
.hero::after { position: absolute; right: -38px; bottom: -58px; width: 195px; height: 195px; border: 1px solid rgba(212, 240, 93, .28); border-radius: 50%; content: ''; box-shadow: 0 0 0 22px rgba(212, 240, 93, .05), 0 0 0 48px rgba(212, 240, 93, .035); }
.hero-label { color: var(--lime); }
.hero h2 { position: relative; z-index: 1; margin: 15px 0 12px; font-size: clamp(34px, 9vw, 52px); line-height: 1.12; letter-spacing: -.045em; }
.hero h2 em { color: var(--lime); font-family: var(--serif); font-weight: 600; letter-spacing: -.04em; }
.hero p { position: relative; z-index: 1; max-width: 390px; margin: 0; color: rgba(255, 253, 247, .72); font-size: 13px; line-height: 1.8; }
.hero-rule { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; margin-top: 25px; color: rgba(255, 253, 247, .55); font: 10px var(--mono); }
.hero-rule span { display: block; width: 38px; height: 1px; background: var(--lime); }
.latest-panel { position: relative; margin-top: 14px; padding: 21px 18px 16px; border: 1px solid #d8d6ca; border-radius: 22px; background: var(--cream); }
.latest-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.latest-kicker { color: var(--forest); }
.latest-heading h3 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.04em; }
.live-badge { display: flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 99px; background: #e6f2dd; color: #2d5b33; font: 10px var(--mono); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #56a276; box-shadow: 0 0 0 3px #dceee2; }
.latest-state { min-height: 17px; margin-top: 13px; color: var(--muted); font-size: 11px; }
.latest-state.is-ready { color: #4b6a28; }
.latest-state.is-error { color: #9a4c36; }
.latest-balls { display: flex; justify-content: center; gap: clamp(5px, 2.2vw, 12px); margin: 13px 0 16px; }
.latest-ball { display: grid; place-items: center; width: clamp(46px, 13vw, 60px); height: clamp(46px, 13vw, 60px); border: 1px solid var(--forest); border-radius: 50%; background: var(--lime); color: var(--forest-deep); font: 500 clamp(16px, 4.2vw, 21px) var(--mono); box-shadow: inset 0 -3px 0 rgba(20, 53, 42, .12); }
.latest-footer { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink); font: 11px var(--mono); }
.latest-source { margin: 9px 0 0; color: #9b9d94; font-size: 10px; }
.panel, .compute-panel, .results-panel { margin-top: 14px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 253, 247, .55); }
.input-panel { padding: 23px 18px 18px; }
.section-heading, .result-header, .ranking-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.section-heading h3, .result-header h3, .compute-copy h3 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.04em; }
.auto-source-note { margin: 12px 1px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.step-number { color: var(--forest); font: 500 12px var(--mono); }
.step-number.muted { color: var(--muted); }
.upload-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 157px; margin-top: 20px; border: 1px dashed #a9aaa0; border-radius: 16px; background: rgba(245, 243, 237, .72); transition: border-color .2s, background .2s, transform .2s; }
.upload-zone:active { transform: scale(.99); background: var(--cream); }
.upload-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 9px; border-radius: 50%; background: var(--lime); color: var(--forest-deep); font-size: 22px; line-height: 1; }
.upload-title { font-weight: 700; font-size: 15px; }
.upload-caption { margin-top: 4px; color: var(--muted); font-size: 11px; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 16px 0 11px; color: #a1a39a; font: 10px var(--mono); }
.or-line::before, .or-line::after { flex: 1; height: 1px; background: var(--line); content: ''; }
.button { min-height: 48px; border: 0; border-radius: 13px; font-weight: 700; letter-spacing: .01em; transition: transform .15s, filter .15s; }
.button:active { transform: scale(.98); }
.button:focus-visible, .text-button:focus-visible, .upload-zone:focus-within { outline: 3px solid rgba(212, 240, 93, .65); outline-offset: 3px; }
.button-secondary { width: 100%; border: 1px solid #c9c8bd; background: transparent; color: var(--ink); font-size: 13px; }
.button-secondary span { color: var(--forest); margin-right: 6px; font-size: 16px; }
.button-pilio { margin-top: 9px; background: rgba(212, 240, 93, .2); border-color: #bfcf86; }
.button-arclink { margin-top: 9px; background: rgba(29, 73, 56, .06); border-color: #9bb0a4; }
.button:disabled { cursor: wait; opacity: .6; }
.format-note { display: flex; align-items: flex-start; gap: 9px; margin: 16px 1px 0; padding-top: 14px; border-top: 1px solid var(--line); }
.note-icon { display: grid; place-items: center; flex: 0 0 auto; width: 17px; height: 17px; border: 1px solid #a8aaa0; border-radius: 50%; color: var(--muted); font: 11px Georgia, serif; }
.format-note p { margin: -2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.format-note strong { color: var(--ink); font-weight: 600; }
.message { display: none; margin-top: 13px; padding: 11px 12px; border-radius: 10px; font-size: 12px; line-height: 1.55; }
.message.is-visible { display: block; }
.message.success { background: #e6f2dd; color: #2d5b33; }
.message.error { background: #fee9e2; color: #913f2e; }
.summary-strip { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 10px; margin-top: 14px; padding: 15px 16px; border-radius: 16px; background: var(--paper-deep); }
.summary-strip div { display: flex; flex-direction: column; gap: 3px; }
.summary-strip span { color: var(--muted); font-size: 10px; }
.summary-strip strong { font: 500 17px var(--mono); }
.text-button { padding: 7px 0; border: 0; background: none; color: #9a4c36; font-size: 11px; white-space: nowrap; }
.preview-panel { padding: 20px 16px 14px; }
.compact-heading { margin-bottom: 15px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 390px; font: 11px var(--mono); }
th { color: var(--muted); font-weight: 400; text-align: left; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td:not(:first-child) { color: var(--forest); font-weight: 600; }
.compute-panel { padding: 16px; background: var(--lime); border-color: var(--lime); }
.compute-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.quantity-selects { display: flex; gap: 7px; }
.method-select-label { display: flex; flex-direction: column; gap: 4px; color: var(--forest-deep); font: 9px var(--mono); }
.method-select-label select { min-height: 34px; padding: 0 8px; border: 1px solid rgba(20, 53, 42, .3); border-radius: 8px; background: rgba(255, 255, 255, .55); color: var(--forest-deep); font: 10px var(--mono); }
.button-primary { flex: 0 0 auto; padding: 0 15px; background: var(--forest); color: var(--cream); box-shadow: 0 7px 14px rgba(20, 53, 42, .18); font-size: 12px; }
.button-primary span { margin-left: 7px; color: var(--lime); font-size: 17px; }
.button-risk { min-height: 35px; padding: 0 12px; border: 1px solid rgba(20, 53, 42, .35); background: transparent; color: var(--forest-deep); font-size: 11px; }
.results-panel { padding: 23px 18px 18px; border: 0; background: var(--forest); color: var(--cream); box-shadow: 0 16px 35px rgba(20, 53, 42, .14); }
.result-header .section-kicker { color: var(--lime); }
.result-header h3 { color: var(--cream); }
.success-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--lime); color: var(--forest); font-weight: 700; }
.result-message { margin: 9px 0 22px; color: rgba(255, 253, 247, .6); font-size: 11px; }
.recommendation-block { padding: 17px 0 18px; border-top: 1px solid rgba(255, 253, 247, .18); }
.recommendation-label { display: flex; align-items: center; justify-content: center; gap: 9px; color: rgba(255, 253, 247, .68); font-size: 11px; }
.label-line { width: 25px; height: 1px; background: rgba(255, 253, 247, .35); }
.ball-row { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(5px, 2.2vw, 12px); margin-top: 14px; }
.ball { display: grid; place-items: center; align-content: center; gap: 2px; width: clamp(46px, 13vw, 60px); height: clamp(46px, 13vw, 60px); border-radius: 50%; background: var(--lime); color: var(--forest-deep); font: 500 clamp(16px, 4.2vw, 21px) var(--mono); box-shadow: inset 0 -3px 0 rgba(20, 53, 42, .12); }
.ball strong { font: inherit; line-height: 1; }
.ball small { font: 8px var(--mono); line-height: 1; }
.backup-recommendation { padding-bottom: 20px; }
.backup-recommendation .ball { background: transparent; border: 1px solid rgba(255, 253, 247, .45); color: var(--cream); box-shadow: none; }
.nohit-recommendation { padding-top: 15px; }
.nohit-note { margin: 8px 0 0; color: rgba(255, 253, 247, .52); font-size: 10px; line-height: 1.5; text-align: center; }
.nohit-recommendation .ball { width: 42px; height: 42px; background: rgba(255, 253, 247, .08); border: 1px solid rgba(255, 253, 247, .25); color: rgba(255, 253, 247, .82); box-shadow: none; font-size: 15px; }
.nohit-groups { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, .12); }
.nohit-group-row { display: grid; grid-template-columns: 38px 1fr; gap: 9px; padding: 6px 0; border-bottom: 1px solid rgba(255, 253, 247, .1); color: rgba(255, 253, 247, .7); font: 10px/1.45 var(--mono); }
.nohit-group-row:last-child { border-bottom: 0; }
.nohit-group-row strong { color: var(--lime); }
.ranking-card { padding: 17px 14px 13px; border-radius: 15px; background: rgba(0, 0, 0, .13); }
.method-card { margin-top: 12px; padding: 17px 14px 13px; border-radius: 15px; background: rgba(0, 0, 0, .08); }
.method-breakdown { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.method-row { display: grid; grid-template-columns: 45px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255, 253, 247, .12); color: rgba(255, 253, 247, .76); font: 10px/1.4 var(--mono); }
.method-row:last-child { border-bottom: 0; padding-bottom: 0; }
.method-code { color: var(--lime); font-weight: 700; letter-spacing: .08em; }
.ranking-heading { align-items: center; padding-bottom: 11px; border-bottom: 1px solid rgba(255, 253, 247, .15); }
.ranking-heading h4 { margin: 4px 0 0; font-size: 15px; }
.ranking-heading > span { color: var(--lime); font: 10px var(--mono); }
.ranking-list { margin-top: 4px; }
.rank-item { display: grid; grid-template-columns: 25px 31px 1fr 52px; align-items: center; gap: 7px; min-height: 34px; border-bottom: 1px solid rgba(255, 253, 247, .09); }
.rank-item:last-child { border-bottom: 0; }
.rank-index, .rank-score { color: rgba(255, 253, 247, .48); font: 10px var(--mono); }
.rank-ball { color: var(--lime); font: 500 13px var(--mono); }
.rank-bar-wrap { height: 4px; overflow: hidden; border-radius: 99px; background: rgba(255, 253, 247, .12); }
.rank-bar { height: 100%; border-radius: inherit; background: var(--lime); }
.rank-score { text-align: right; }
.disclaimer { margin: 17px 0 13px; color: rgba(255, 253, 247, .52); font-size: 10px; line-height: 1.6; text-align: center; }
.full-button { color: var(--cream); border-color: rgba(255, 253, 247, .28); }
.full-button span { color: var(--lime); }
.footer { display: flex; justify-content: space-between; margin: 24px 2px 0; color: #9b9d94; font: 9px var(--mono); letter-spacing: .08em; }
.is-hidden { display: none !important; }
.risk-panel { margin-top: 14px; padding: 22px 18px 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--cream); }
.risk-header { display: flex; align-items: flex-start; justify-content: space-between; }
.risk-header h3 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.04em; }
.risk-level { padding: 7px 9px; border-radius: 99px; background: #fff0dc; color: #87552f; font: 10px var(--mono); white-space: nowrap; }
.risk-message { margin: 12px 0 15px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.risk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.risk-card { display: flex; flex-direction: column; gap: 5px; padding: 11px; border-radius: 12px; background: var(--paper-deep); }
.risk-card span, .risk-detail span { color: var(--muted); font-size: 10px; }
.risk-card strong { color: var(--forest); font: 500 16px var(--mono); }
.risk-detail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.risk-detail div { display: flex; flex-direction: column; gap: 5px; }
.risk-detail strong { color: var(--ink); font: 500 12px var(--mono); }
.tail-recommendation { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.tail-heading { display: flex; align-items: center; justify-content: space-between; }
.tail-heading h4 { margin: 4px 0 0; font-size: 15px; }
.tail-heading > span { color: var(--forest); font: 10px var(--mono); }
.tail-balls { display: flex; gap: 8px; margin: 13px 0; }
.tail-ball { display: grid; place-items: center; min-width: 53px; height: 39px; border-radius: 11px; background: var(--forest); color: var(--lime); font: 500 13px var(--mono); }
.tail-ranking { display: flex; flex-direction: column; gap: 7px; }
.tail-row { display: grid; grid-template-columns: 35px 1fr 38px; align-items: center; gap: 8px; color: var(--muted); font: 10px var(--mono); }
.tail-row > span:last-child { text-align: right; }
.tail-bar-wrap { height: 5px; overflow: hidden; border-radius: 99px; background: #dfe0d7; }
.tail-bar { display: block; height: 100%; border-radius: inherit; background: var(--forest); }
.risk-disclaimer { margin: 14px 0 0; color: #9b9d94; font-size: 10px; line-height: 1.6; }

@media (min-width: 600px) {
  .app-shell { padding: 28px 36px 45px; }
  .input-panel, .results-panel { padding: 28px 24px 22px; }
  .hero { padding: 37px 33px 33px; }
  .latest-panel { padding: 24px 23px 18px; }
  .upload-zone { min-height: 174px; }
  .summary-strip { padding: 17px 20px; }
  .preview-panel { padding: 24px 20px 17px; }
}
