:root {
  --ink: #142d2b;
  --ink-2: #3f5b56;
  --paper: #f4f0e5;
  --white: #fffdf7;
  --jade: #0e6659;
  --jade-dark: #08473f;
  --red: #d65434;
  --gold: #c79b51;
  --line: rgba(20, 45, 43, 0.14);
  --shadow: 0 30px 90px rgba(20, 45, 43, 0.13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 4%, rgba(199, 155, 81, 0.14), transparent 28rem),
    linear-gradient(135deg, #faf8f0, var(--paper));
  font-family: "Noto Sans CJK TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

.site-header,
main,
footer {
  width: min(1160px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 40px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border-radius: 3px 3px 15px 3px;
  box-shadow: 5px 5px 0 var(--gold);
  font: 700 25px Georgia, serif;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .08em; }
.brand small { margin-top: 3px; color: var(--ink-2); font: 10px Georgia, serif; letter-spacing: .14em; }
.privacy-badge, .user-menu { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12px; }
.privacy-badge span, .session-chip i { width: 8px; height: 8px; border-radius: 50%; background: #2b9c72; box-shadow: 0 0 0 5px rgba(43,156,114,.11); }
.user-menu button { padding: 7px 10px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; }

.auth-view {
  min-height: calc(100vh - 168px);
  padding: 72px 0;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(55px, 9vw, 130px);
  align-items: center;
}
.eyebrow { margin: 0 0 15px; color: var(--red); font: 700 10px Georgia, serif; letter-spacing: .2em; }
.auth-intro h1, .portal-heading h1, .result-topline h2 {
  margin: 0;
  font-family: "Noto Serif CJK TC", "Songti TC", STSong, serif;
  letter-spacing: -.04em;
}
.auth-intro h1 { font-size: clamp(48px, 7vw, 76px); line-height: 1.12; }
.auth-intro h1 em { color: var(--jade); font-style: normal; }
.auth-intro > p:not(.eyebrow) { max-width: 590px; color: var(--ink-2); font-size: 16px; line-height: 1.9; }
.safety-note { max-width: 620px; margin-top: 32px; padding: 20px 23px; background: rgba(14,102,89,.07); border-left: 3px solid var(--jade); }
.safety-note strong, .safety-note span { display: block; }
.safety-note strong { margin-bottom: 6px; }
.safety-note span { color: var(--ink-2); font-size: 12px; line-height: 1.7; }

.auth-card { padding: 34px; background: rgba(255,253,247,.88); border: 1px solid var(--line); border-radius: 4px 4px 30px 4px; box-shadow: var(--shadow); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 30px; padding: 4px; background: var(--paper); border-radius: 5px; }
.auth-tabs button { flex: 1; padding: 10px; color: var(--ink-2); background: transparent; border: 0; border-radius: 3px; cursor: pointer; }
.auth-tabs button.active { color: var(--ink); background: var(--white); box-shadow: 0 3px 12px rgba(20,45,43,.08); font-weight: 700; }
.form-heading span { color: var(--red); font-size: 11px; letter-spacing: .12em; }
.form-heading h2 { margin: 6px 0 24px; font-family: "Noto Serif CJK TC", "Songti TC", STSong, serif; font-size: 28px; }
.auth-form label { display: block; margin-top: 16px; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; margin-top: 8px; padding: 13px 14px; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 3px; outline: 0; }
.auth-form input:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgba(14,102,89,.1); }
.auth-form > small { display: block; margin-top: 9px; color: var(--ink-2); line-height: 1.5; }
.solid-button { min-height: 50px; padding: 0 22px; color: var(--white); background: var(--jade); border: 0; border-radius: 3px 3px 14px 3px; cursor: pointer; font-weight: 700; box-shadow: 6px 6px 0 var(--ink); transition: transform .16s, box-shadow .16s; }
.auth-form .solid-button { width: calc(100% - 6px); margin-top: 25px; }
.solid-button:hover { transform: translate(2px,2px); box-shadow: 4px 4px 0 var(--ink); }
.solid-button:disabled { cursor: wait; opacity: .55; }
.form-notice { min-height: 20px; margin: 17px 0 0; color: var(--red); font-size: 12px; line-height: 1.6; }

.portal-view { padding: 65px 0 90px; }
.portal-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 32px; }
.portal-heading h1 { font-size: clamp(38px, 6vw, 62px); }
.portal-heading > div > p:last-child { margin: 11px 0 0; color: var(--ink-2); }
.session-chip { display: flex; align-items: center; gap: 9px; padding: 10px 14px; color: var(--ink-2); background: rgba(255,253,247,.6); border: 1px solid var(--line); border-radius: 99px; font-size: 11px; }

.guide-panel { padding: 36px; background: rgba(255,253,247,.7); border: 1px solid var(--line); border-radius: 4px 4px 30px 4px; }
.steps { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4,1fr); list-style: none; }
.steps li { min-height: 200px; padding: 8px 25px 20px; border-right: 1px solid var(--line); }
.steps li:first-child { padding-left: 4px; }
.steps li:last-child { border: 0; }
.step-number { display: block; margin-bottom: 32px; color: var(--gold); font: italic 22px Georgia, serif; }
.steps strong { font-size: 16px; }
.steps p { color: var(--ink-2); font-size: 12px; line-height: 1.65; }
.steps a { color: var(--jade); font-size: 12px; font-weight: 700; text-decoration: none; }
.start-button { display: block; margin: 24px auto 5px; }

.connection-panel { padding: clamp(28px,5vw,48px); color: var(--white); background: var(--ink); border-radius: 4px 4px 32px 4px; box-shadow: var(--shadow); }
.connection-heading h2, .connection-heading p { margin: 0; }
.connection-heading h2 { font-family: "Noto Serif CJK TC", "Songti TC", STSong, serif; font-size: 32px; }
.connection-heading > p:last-child { margin-top: 9px; color: rgba(255,255,255,.58); line-height: 1.7; }
.code-control { display: flex; gap: 9px; margin-top: 28px; }
.code-control input { min-width: 0; flex: 1; padding: 14px; color: #efe4c8; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.15); border-radius: 3px; font: 12px Consolas, monospace; }
.code-control button { padding: 0 18px; color: var(--ink); background: var(--gold); border: 0; border-radius: 3px; cursor: pointer; font-weight: 700; }
.waiting-line { display: flex; gap: 15px; align-items: center; margin-top: 27px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.1); }
.pulse { width: 11px; height: 11px; border-radius: 50%; background: #e9b954; box-shadow: 0 0 0 0 rgba(233,185,84,.5); animation: pulse 1.5s infinite; }
.waiting-line strong, .waiting-line small { display: block; }
.waiting-line small { margin-top: 5px; color: rgba(255,255,255,.46); }
.connection-panel .form-notice { color: #f29a82; }

.result-topline { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 25px; }
.result-topline h2 { font-size: 38px; }
.result-topline button, .number-card button { padding: 8px 12px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; }
.number-card { position: relative; overflow: hidden; padding: clamp(32px,5vw,54px); color: var(--white); background: var(--ink); border-radius: 4px 4px 30px 4px; }
.number-card::after { content: "MEEN"; position: absolute; right: -20px; bottom: -40px; color: rgba(255,255,255,.025); font: 700 130px Georgia,serif; }
.number-card > span { display: block; margin-bottom: 15px; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.number-card > strong { position: relative; z-index: 1; display: inline-block; margin-right: 13px; font: 700 clamp(31px,5vw,57px) Georgia,serif; letter-spacing: .04em; word-break: break-word; }
.number-card button { position: relative; z-index: 1; color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.18); }
.number-card p { max-width: 760px; margin: 18px 0 0; color: rgba(255,255,255,.6); font-size: 13px; line-height: 1.75; }
.result-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; margin-top: 20px; background: var(--line); border: 1px solid var(--line); }
.result-grid article { padding: 24px; background: rgba(255,253,247,.85); }
.result-grid span, .result-grid strong, .result-grid small { display: block; }
.result-grid span { color: var(--ink-2); font-size: 11px; }
.result-grid strong { margin-top: 12px; font-size: 17px; word-break: break-word; }
.result-grid small { margin-top: 7px; color: var(--ink-2); font-size: 10px; line-height: 1.5; }
.download-card { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; margin-top: 20px; padding: 30px 32px; color: var(--white); background: var(--jade); border-radius: 3px 3px 25px 3px; }
.download-mark { width: 62px; height: 62px; display: grid; place-items: center; color: var(--gold); border: 1px solid rgba(255,255,255,.24); border-radius: 50%; font: 700 12px Georgia,serif; }
.download-card h2, .download-card p { margin: 0; }
.download-card h2 { font-family: "Noto Serif CJK TC", "Songti TC", STSong,serif; font-size: 22px; }
.download-card > div:nth-child(2) > p:not(.eyebrow) { margin-top: 7px; color: rgba(255,255,255,.72); font-size: 12px; line-height: 1.7; }
.download-card small { display: block; margin-top: 6px; color: #f1cd82; font-size: 10px; }
.download-card a { padding: 13px 16px; color: var(--ink); background: var(--white); border-radius: 3px 3px 12px 3px; text-decoration: none; font-size: 12px; font-weight: 700; }

footer { padding: 28px 0 40px; display: flex; justify-content: space-between; gap: 20px; color: var(--ink-2); border-top: 1px solid var(--line); font-size: 10px; }
:focus-visible { outline: 3px solid rgba(214,84,52,.45); outline-offset: 3px; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(233,185,84,0); } 100% { box-shadow: 0 0 0 0 rgba(233,185,84,0); } }

@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2,1fr); gap: 25px 0; }
  .steps li:nth-child(2) { border-right: 0; }
  .result-grid { grid-template-columns: repeat(2,1fr); }
  .download-card { grid-template-columns: auto 1fr; }
  .download-card a { grid-column: 1/-1; text-align: center; }
}

@media (max-width: 600px) {
  .site-header, main, footer { width: min(100% - 30px,1160px); }
  .site-header { height: 80px; }
  .privacy-badge, .user-menu > span { display: none; }
  .auth-view { padding: 48px 0 65px; }
  .auth-intro h1 { font-size: 44px; }
  .auth-card, .guide-panel { padding: 25px 22px; }
  .portal-heading, .result-topline, footer { align-items: stretch; flex-direction: column; }
  .session-chip { align-self: flex-start; }
  .steps, .result-grid { grid-template-columns: 1fr; }
  .steps li, .steps li:first-child { min-height: 0; padding: 18px 0 25px; border-right: 0; border-bottom: 1px solid var(--line); }
  .step-number { margin-bottom: 14px; }
  .code-control { flex-direction: column; }
  .code-control button { min-height: 46px; }
  .number-card > strong { display: block; margin-bottom: 16px; font-size: 30px; }
  .download-card { grid-template-columns: 1fr; padding: 27px 23px; }
  .download-card a { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
