/* The palette is the device's own LCD palette (src/hw/display.h), so the site
   and the thing in your hand read as one object. */
:root {
  --paper:  #CBD0BC;
  --ink:    #23261E;
  /* The device's mid grey is a 12px-pixel-art tone. On a web page at body size
     it lands near 2:1 against the paper background, which is not readable text
     — so it stays decorative (borders, dots, rules) and secondary TEXT gets its
     own darker tone at ~4.5:1 against both backgrounds we use. */
  --mid:    #8F9680;
  --dim:    #545B48;
  --shadow: #B4BAA4;
  --red:    #D8482E;
  --gold:   #E8B03A;
  --blue:   #4E96C8;
  --white:  #F5F7EA;
  --green:  #6CA84E;
  --pad: clamp(1rem, 4vw, 2.5rem);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* CJK needs a fallback that actually has the glyphs, and the pixel font on
     the device is 12px — unreadable on a phone, so the web uses system faces. */
  font-family: ui-monospace, "SF Mono", Menlo, Consolas,
               "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", monospace;
}

a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--red); }

/* ---------- chrome ---------- */

.top {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.5rem;
  padding: 1rem var(--pad);
  border-bottom: 2px solid var(--ink);
  background: var(--white);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; letter-spacing: 0.02em; }
.top nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--dim); }
.top nav a.on, .top nav a:hover { color: var(--ink); }
.lang { margin-left: auto; font-size: 0.85rem; }
.lang a { color: var(--dim); }
.lang a.on { color: var(--ink); font-weight: 700; }

main { max-width: 54rem; margin: 0 auto; padding: var(--pad); }

footer {
  border-top: 2px solid var(--shadow);
  margin-top: 4rem; padding: 1.5rem var(--pad);
  color: var(--dim); font-size: 0.85rem;
}

/* ---------- type ---------- */

h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.4rem; }
.tagline { font-size: clamp(1rem, 2.5vw, 1.2rem); color: var(--dim); margin: 0 0 2rem; }
.muted { color: var(--dim); }
.lede { font-size: 1.05rem; }

/* ---------- hero ---------- */

.hero { display: grid; gap: 2rem; align-items: center; }
@media (min-width: 46rem) { .hero { grid-template-columns: 1fr auto; } }

.device {
  /* 135x240 at 2x, bezel drawn in CSS so there is no image to load */
  width: 190px; margin: 0 auto;
  background: var(--ink); border-radius: 18px; padding: 22px 14px 34px;
  box-shadow: 0 8px 0 var(--shadow);
}
.device .screen {
  width: 100%; aspect-ratio: 135 / 240;
  background: var(--paper);
  border: 2px solid var(--mid);
  display: grid; place-items: center;
  image-rendering: pixelated;
  overflow: hidden;
}
.device .screen img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }

/* ---------- features ---------- */

.grid { display: grid; gap: 1.25rem; margin: 1.5rem 0; }
@media (min-width: 40rem) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--white); border: 2px solid var(--ink);
  padding: 1rem 1.1rem; box-shadow: 4px 4px 0 var(--shadow);
}
.card h3 { margin-top: 0; }
.card p { margin: 0; color: var(--dim); }

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

.btn {
  display: inline-block; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--ink); color: var(--white);
  border: 2px solid var(--ink); padding: 0.7rem 1.4rem;
  text-decoration: none; box-shadow: 4px 4px 0 var(--shadow);
}
.btn:hover { color: var(--white); background: var(--red); border-color: var(--red); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--shadow); }
.btn[disabled] { background: var(--shadow); border-color: var(--shadow); color: var(--white); cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--white); }

/* ---------- dock ---------- */

.panel {
  background: var(--white); border: 2px solid var(--ink);
  padding: 1.25rem; box-shadow: 6px 6px 0 var(--shadow); margin: 1.5rem 0;
}
.status { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--mid); flex: none; }
.dot.on { background: var(--green); }
.dot.busy { background: var(--gold); }
.dot.err { background: var(--red); }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 1rem 0 0; }
dl.kv dt { color: var(--dim); }
dl.kv dd { margin: 0; }

.bar { height: 1.4rem; border: 2px solid var(--ink); background: var(--paper); margin: 0.75rem 0 0.4rem; }
.bar > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width 0.2s linear; }

.warn { border-left: 6px solid var(--gold); padding-left: 0.9rem; }
.danger { border-left: 6px solid var(--red); padding-left: 0.9rem; }

.chip {
  display: inline-block; font-size: 0.7rem; text-transform: uppercase;
  background: var(--gold); color: var(--ink); padding: 0.1rem 0.45rem;
  margin-left: 0.5rem; vertical-align: middle; letter-spacing: 0.06em;
}

/* ---------- changelog / faq ---------- */

.rel { border-top: 2px solid var(--shadow); padding-top: 1rem; margin-top: 2rem; }
.rel h2 { display: flex; align-items: baseline; gap: 0.75rem; margin: 0 0 0.5rem; }
.rel time { margin-left: auto; color: var(--dim); font-size: 0.85rem; font-weight: 400; }
.rel ul { margin: 0; padding-left: 1.2rem; }

details { border-bottom: 2px solid var(--shadow); padding: 0.9rem 0; }
details summary { cursor: pointer; font-weight: 700; }
details p, details ul { color: var(--dim); }

code {
  background: var(--white); border: 1px solid var(--shadow);
  padding: 0.1rem 0.35rem; font-size: 0.9em;
}

.log {
  background: var(--ink); color: var(--paper);
  padding: 0.8rem; font-size: 0.8rem; line-height: 1.5;
  max-height: 12rem; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------- stepped flow ---------- */

.steps {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  list-style: none; margin: 0 0 1.5rem; padding: 0;
  font-size: 0.85rem;
}
.steps li {
  border: 2px solid var(--shadow); padding: 0.25rem 0.7rem;
  color: var(--dim); background: var(--paper);
}
.steps li.past { border-color: var(--mid); color: var(--dim); }
.steps li.on {
  border-color: var(--ink); background: var(--ink); color: var(--white);
  font-weight: 700;
}

/* The pet-safety promise is the one line people look for; give it weight. */
.keep {
  border-left: 6px solid var(--green);
  padding-left: 0.9rem; margin-bottom: 0;
}

/* ---------- version list ---------- */

.rel-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.rel-list > li {
  border-top: 2px solid var(--shadow); padding: 0.9rem 0;
}
.rel-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.rel-list p { margin: 0.3rem 0 0.6rem; }
.warn-inline { color: var(--dim); border-left: 4px solid var(--gold); padding-left: 0.6rem; }
.btn.small { padding: 0.4rem 0.9rem; font-size: 0.85rem; box-shadow: 3px 3px 0 var(--shadow); }

/* ---------- activation (入职办理) ---------- */

/* Keyboard users see where they are. The device palette's ink on paper is the
   high-contrast pair; red is reserved for danger, so focus uses blue. */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 3px; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 10;
  background: var(--ink); color: var(--white); padding: 0.5rem 1rem;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

main:focus { outline: none; }

.panel h2 { margin-top: 0; }
.panel h2:focus { outline: none; }
.panel > :last-child { margin-bottom: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.notice {
  background: var(--white); border: 2px solid var(--ink);
  padding: 0.6rem 0.9rem; display: inline-block;
}

.note { box-shadow: none; border-color: var(--mid); }
.panel.warn { border-left: 6px solid var(--gold); }
.panel.danger { border-left: 6px solid var(--red); padding-left: 1.25rem; }

ul.need, ol.howto, ol.three { padding-left: 1.3rem; }
ul.need li, ol.howto li { margin: 0.3rem 0; }
ol.three { list-style: none; padding: 0; display: grid; gap: 1rem; }
@media (min-width: 46rem) { ol.three { grid-template-columns: repeat(3, 1fr); } }
ol.three li { background: var(--white); border: 2px solid var(--ink); padding: 0.9rem 1rem; }
ol.three h3 { margin-top: 0; }
ol.three p { margin: 0; color: var(--dim); }

.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.shots figure { margin: 0; }
.shots img {
  display: block; width: 100%; height: auto; image-rendering: pixelated;
  border: 6px solid var(--ink); border-radius: 8px; background: var(--paper);
}
.shots figcaption { color: var(--dim); font-size: 0.9rem; margin-top: 0.4rem; }

.ways { display: grid; gap: 1rem; }
@media (min-width: 46rem) { .ways { grid-template-columns: repeat(3, 1fr); } }
.ways h3 { margin-top: 0; }

/* The code field: big, monospaced, one line, never wider than the screen. */
.codeform label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
.codeform .row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.codeform input {
  flex: 1 1 14rem; min-width: 0;
  font: inherit; font-size: 1.25rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.6rem 0.8rem; border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
}
.codeform input::placeholder { color: var(--mid); text-transform: none; }
.codeform input[aria-invalid="true"] { border-color: var(--red); }
.field-msg { min-height: 1.65em; margin: 0.6rem 0 0; font-weight: 700; }

input[type="file"] { font: inherit; max-width: 100%; }
.linkout {
  width: 100%; font: inherit; font-size: 0.85rem; padding: 0.4rem 0.6rem;
  border: 2px solid var(--shadow); background: var(--paper); color: var(--ink);
}

/* A button that reads as a link, for the secondary path in a sentence. */
.linkish {
  font: inherit; color: var(--ink); background: none; border: 0; padding: 0;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
  cursor: pointer;
}
.linkish:hover { color: var(--red); }
.linkish[disabled] { color: var(--dim); cursor: not-allowed; }

.check { display: flex; gap: 0.6rem; align-items: flex-start; }
.check input { width: 1.25rem; height: 1.25rem; flex: none; margin-top: 0.2rem; accent-color: var(--ink); }
.check label { font-weight: 700; cursor: pointer; }

/* The 档案号: the one thing on the confirm screen that must be read correctly. */
.dossier {
  font-size: clamp(1.6rem, 7vw, 2.6rem); font-weight: 700; letter-spacing: 0.08em;
  margin: 0 0 0.25rem; overflow-wrap: anywhere;
}

/* The company seal. Drawn, not an image. */
.seal {
  float: right; margin: 0 0 0.5rem 1rem;
  width: 5.5rem; height: 5.5rem; border-radius: 50%;
  border: 4px solid var(--red); color: var(--red);
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem;
  transform: rotate(-12deg); letter-spacing: 0.1em;
}
@media (max-width: 28rem) { .seal { float: none; margin: 0 0 1rem; } }

.textflow { margin-top: 2rem; }
.textflow ol { padding-left: 1.3rem; }
.textflow h3 { color: var(--ink); }

.steps li { flex: 1 1 auto; text-align: center; }
body.busy .btn[disabled] { cursor: progress; }

@media (max-width: 30rem) {
  .btn { width: 100%; text-align: center; }
  .actions .btn { width: 100%; }
  .top { gap: 0.5rem 1rem; }
  .lang { margin-left: 0; }
}
