/* tasteskill · framed sheet (seed 1000162849)
   Chrome tinted from YouTube's own hue; the work sits on a white sheet with a hairline edge and
   no shadow. One face (IBM Plex Sans), Plex Mono for the two keys this screen deals in. */

:root {
  --ground: #f7f2f3;        /* the frame: one low-chroma step of the product's red, a pale stone */
  --surface: #ffffff;       /* the sheet and every panel on it */
  --raised: #f8f4f5;
  --active: #efe8ea;
  --border: #ebe4e6;        /* panel edges, about 1.2:1 on white */
  --rule: #f4eff0;          /* row rules */
  --control: #d3c9cc;       /* control borders, one step stronger */
  --control-strong: #a89da1;
  --text: #141414;
  --muted: #5f5c58;         /* 6:1 on white, 5.6:1 on the frame */
  --link: #c4122f;          /* 6:1 on white */
  --focus: #c4122f;
  --positive: #1e7b4f;
  --negative: #b3202c;
  --pill-positive-bg: #e2f5ea;
  --pill-positive-ink: #0d3d27;

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-title: 22px;
  --fs-section: 16px;
  --fs-kpi: 28px;
  --fs-body: 14px;
  --fs-small: 12px;

  --canvas: 1120px;
  --pad: 24px;
  --sheet-inset: 8px;
  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 32px;
  --gap: 24px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-ui: 150ms;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #ffe0e6; color: var(--text); }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.num, .code, .token, .kpi { font-variant-numeric: tabular-nums; }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-title); line-height: 1.2; }
h2 { font-size: var(--fs-section); line-height: 1.3; }

p { margin: 0; }

/* ---------- chrome: the tinted frame ---------- */

.topbar {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }

.mark { display: block; width: 20px; height: 20px; flex: none; }

.brand-name { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; }

.brand-scope {
  font-size: var(--fs-small);
  color: var(--muted);
  padding-left: 8px;
  border-left: 1px solid var(--control);
  line-height: 1.2;
}

.topbar-note { display: none; font-size: var(--fs-small); color: var(--muted); white-space: nowrap; }

/* ---------- the sheet ---------- */

.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 var(--sheet-inset) var(--sheet-inset);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
}

.canvas {
  flex: 1;
  width: 100%;
  max-width: var(--canvas);
  margin: 0 auto;
  padding: var(--pad) var(--pad) 20px;
  display: flex;
  flex-direction: column;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: var(--gap);
}

.title-text { min-width: 0; }

.subline { margin-top: 6px; color: var(--muted); max-width: 62ch; }

/* ---------- the session block ---------- */

.session {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.stage { padding: var(--pad); min-width: 0; }

/* one divided strip: what this login is made of (not a row of cards) */
.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: var(--gap) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.meta-cell { padding: 14px 16px; min-width: 0; }
.meta-cell + .meta-cell { border-left: 1px solid var(--border); }

.meta-value { margin-top: 4px; font-size: var(--fs-body); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.meta-value a { font-weight: 500; }

.rail {
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  border-left: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}

/* state blocks */
.s-loading, .s-pending, .s-done, .s-error { display: none; }

body[data-state="loading"] .stage .s-loading { display: block; }
body[data-state="pending"] .stage .s-pending { display: block; }
body[data-state="done"] .stage .s-done { display: block; }
body[data-state="error"] .stage .s-error { display: block; }

body[data-state="loading"] .rail .s-loading,
body[data-state="pending"] .rail .s-pending,
body[data-state="done"] .rail .s-done { display: flex; flex-direction: column; flex: 1; }

body[data-state="error"] .session { grid-template-columns: minmax(0, 1fr); }
body[data-state="error"] .rail { display: none; }

#btn-check { display: none; flex: none; }
body[data-state="pending"] #btn-check { display: inline-flex; }

/* ---------- pending: the pairing plate ---------- */

.stage-split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.qr-frame {
  width: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.qr { width: 100%; }
.qr svg { display: block; width: 100%; height: auto; }

.code-block { display: flex; flex-direction: column; gap: 8px; padding-top: 2px; }

.label { font-size: var(--fs-small); color: var(--muted); letter-spacing: 0; }

.code {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.06em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.hint { font-size: 13px; line-height: 1.6; color: var(--muted); max-width: 44ch; }

/* ---------- done: the credential ---------- */

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--raised);
  flex: none;
  object-fit: cover;
}

.account-lines { min-width: 0; }
.account-name { font-size: var(--fs-section); font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.account-sub { font-size: var(--fs-small); color: var(--muted); margin-top: 2px; }

.well {
  display: flex;
  align-items: stretch;
  margin-top: 6px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  overflow: hidden;
}

.well:focus-within { border-color: var(--control-strong); }

.token {
  flex: 1;
  min-width: 0;
  border: 0;
  resize: vertical;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  font: 400 13px/1.6 var(--mono);
  overflow-wrap: anywhere;
}

.token:focus-visible { outline: none; }

.btn-joined {
  height: auto;
  border: 0;
  border-left: 1px solid var(--control);
  border-radius: 0;
  background: var(--raised);
  padding: 0 16px;
}

.btn-joined:hover { background: var(--active); }

/* ---------- error ---------- */

.error-line { font-size: var(--fs-body); color: var(--text); max-width: 56ch; }
.s-error .hint { margin-top: 6px; }
.s-error .btn { margin-top: 16px; }

/* ---------- rail ---------- */

.steps {
  margin: 14px 0 0;
  padding-left: 1.35em;
  display: grid;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.steps li { padding-left: 2px; }
.steps li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.steps li[aria-current="step"] { color: var(--text); font-weight: 500; }
.steps li[aria-current="step"]::marker { color: var(--text); font-weight: 600; }

.rail-foot { margin-top: auto; padding-top: 28px; }

.kpi {
  font-family: var(--mono);
  font-size: var(--fs-kpi);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

.meter {
  height: 4px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--text);
  transition: width 900ms linear;
}

.fine { margin-top: 12px; font-size: var(--fs-small); line-height: 1.55; color: var(--muted); }

.kv { margin: 14px 0 0; }

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}

.kv-row:first-child { border-top: 0; padding-top: 0; }

.kv dt { font-size: 13px; color: var(--muted); flex: none; }

.kv dd {
  margin: 0;
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}

/* ---------- buttons ---------- */

.btn {
  height: var(--control-height);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 500 13px/1 var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: background var(--t-ui) var(--ease), border-color var(--t-ui) var(--ease);
}

.btn:hover { background: var(--raised); border-color: var(--control-strong); }
.btn:active { background: var(--active); }
.btn:disabled { color: var(--muted); border-color: var(--border); cursor: default; }

.btn-primary {
  background: #141414;
  border-color: #141414;
  color: #ffffff;
}

.btn-primary:hover { background: #2b2b2b; border-color: #2b2b2b; }
.btn-primary:active { background: #000000; }

/* ---------- skeleton (loading, at the real sizes) ---------- */

.skel { display: block; border-radius: 4px; background: var(--raised); }

.skel-qr { width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: var(--radius-card); }

.skel-lines { display: grid; gap: 12px; }
.skel-xs { width: 64px; height: 12px; }
.skel-sm { width: 42%; height: 14px; }
.skel-md { width: 68%; height: 16px; }
.skel-lg { width: 78%; height: 30px; }

/* ---------- footer ---------- */

.sheet-foot {
  margin-top: 28px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 4px;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--muted);
}

.sheet-foot p { max-width: 78ch; }

/* ---------- 700–1199: sheet still framed, session stacks ---------- */

@media (max-width: 999px) {
  .session { grid-template-columns: minmax(0, 1fr); }
  .rail { border-left: 0; border-top: 1px solid var(--border); }
  .rail-foot { margin-top: 0; padding-top: 20px; }
  .stage-split { grid-template-columns: 288px minmax(0, 1fr); }
}

@media (min-width: 700px) {
  .topbar { padding: 0 28px; }
  .canvas { padding: 24px 20px 20px; }
}

@media (min-width: 1200px) {
  .topbar { padding: 0 max(28px, calc((100% - 1120px) / 2 + 24px)); }
}

/* ---------- phone: the frame disappears, the sheet is the screen ---------- */

@media (max-width: 699px) {
  :root { --pad: 16px; --gap: 18px; }

  .sheet {
    margin: 0;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    min-height: calc(100vh - 48px);
  }

  .canvas { padding: 18px 16px 16px; }

  .title-row { flex-direction: column; align-items: stretch; gap: 12px; }
  #btn-check { align-self: flex-start; height: 40px; padding: 0 16px; }

  h1 { font-size: 20px; }
  .code { font-size: 24px; }

  .stage-split { grid-template-columns: minmax(0, 1fr); }
  .qr-frame { width: min(100%, 320px); }

  .meta { grid-template-columns: minmax(0, 1fr); }
  .meta-cell + .meta-cell { border-left: 0; border-top: 1px solid var(--border); }
  .meta-cell { padding: 12px 16px; }

  .rail { padding: 18px 16px; }
  .stage { padding: 16px; }

  .steps { gap: 8px; }
  .kpi { font-size: 26px; }

  .token { font-size: 12px; }

  .btn-joined { padding: 0 14px; }
  .btn, .btn-joined { min-height: 40px; }
  .btn-joined { min-height: 0; }

  .sheet-foot { margin-top: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .meter i { transition: none; }
  .btn { transition: none; }
}
