/* ============================================================
   AirPic — 简单克制 · 科技文艺
   palette: Song dynasty (天水碧 / 墨灰 / 月白 / 竹青 / 明茶褐 / 缃)
   ============================================================ */
:root {
  --paper:      #F4F2EB;   /* 月白偏暖的纸底 */
  --surface:    #FBFAF5;   /* 卡片浮起面 */
  --ink:        #2B2A26;   /* 墨 */
  --ink-2:      #6B675C;   /* 墨灰(次) */
  --ink-3:      #A6A092;   /* 淡墨(弱) */
  --rule:       #E4DFD2;   /* 发丝线 */
  --rule-2:     #D6CFBE;   /* 深发丝线 */
  --accent:     #3F7E87;   /* 深天水碧(主行动) */
  --accent-2:   #5AA4AE;   /* 天水碧(亮点缀) */
  --accent-soft:#E5EDEE;   /* 天水碧晕染 */
  --ok:         #6E8A55;   /* 竹青(连接/成功) */
  --warn:       #9A7B5E;   /* 明茶褐(警示) */
  --gold:       #B08A2E;   /* 缃(沉金,小面积) */

  --serif: 'Newsreader', 'Noto Serif SC', Georgia, 'Times New Roman', serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --maxw: 760px;
  --pad: clamp(20px, 5vw, 40px);
}

/* ---------------- reset / base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }

/* the [hidden] attribute must always win (so the unused role view never leaks) */
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* boot diagnostic banner */
.boot-notice {
  margin: 0;
  padding: 12px var(--pad);
  background: #F3E7D6;
  color: #7A5A2E;
  border-bottom: 1px solid #E6D3B6;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------- top bar ---------------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--pad);
}
.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.02em;
}
.brand::after {            /* a small 天水碧 dot — the only flourish */
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-left: 7px;
  vertical-align: middle;
}
.lang-toggle {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 12px;
  transition: border-color .2s, color .2s;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- layout shell ---------------- */
.view { flex: 1 0 auto; display: flex; }
.view-receiver { align-items: flex-start; }
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(14px, 4vw, 32px) var(--pad) 8px;
}

/* kicker (mono, tech) */
.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}

/* hero — compact, single focal sentence */
.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.7rem, 4.6vw, 2.5rem);
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  max-width: 18ch;
}
.hero-sub {
  font-size: clamp(0.98rem, 2.1vw, 1.08rem);
  color: var(--ink-2);
  margin: 0 0 24px;
  max-width: 46ch;
}

/* ---------------- panel (the focal action) ---------------- */
.panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(210px, 250px) 1fr;
  gap: 30px;
  align-items: center;
  padding: 26px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 14px;
}
.panel::before {           /* a thin 天水碧 tab marking the panel */
  content: "";
  position: absolute;
  left: 26px; top: -1px;
  width: 36px; height: 2px;
  background: var(--accent);
}
.panel-qr { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.qr-frame {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
#qr-canvas { display: block; width: 224px; height: 224px; }
.qr-hint { font-size: 12.5px; color: var(--ink-2); }
.qr-url {
  font-size: 11px;
  color: var(--ink-3);
  word-break: break-all;
  max-width: 210px;
  margin: 0 auto;
  line-height: 1.5;
  user-select: all;
  cursor: text;
}
.panel-side { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* buttons */
.btn {
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #356B73; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--rule-2); }
.btn.ghost:hover { border-color: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.folder-name { font-size: 12.5px; color: var(--ink-2); word-break: break-all; }
.received-count { font-size: 11.5px; color: var(--ink-3); min-height: 1em; }

/* status (mono, tech) */
.status {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  transition: color .2s, border-color .2s;
}
.status[data-state="connected"],
.status[data-state="done"] { color: var(--ok); border-color: var(--ok); }
.status[data-state="sending"],
.status[data-state="receiving"] { color: var(--accent); border-color: var(--accent); }
.status[data-state="error"] { color: var(--warn); border-color: var(--warn); }

.unsupported { font-size: 12.5px; color: var(--warn); margin: 10px 0 0; max-width: 48ch; }

/* belief (trust line, sits right under the panel) */
.belief { margin: 22px 0 6px; display: grid; gap: 12px; }
.belief .rule { display: block; width: 34px; height: 1px; background: var(--accent); }
.belief p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  line-height: 1.6;
  color: var(--ink);
  max-width: 40ch;
}

/* steps — demoted below the panel, compact trio on wide screens */
.steps {
  list-style: none;
  margin: 44px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 14px;
}
.steps li {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: baseline;
  gap: 14px;
}
.step-no { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--accent); }
.step-text { font-family: var(--serif); font-size: clamp(1rem, 2.2vw, 1.16rem); line-height: 1.5; }

@media (min-width: 640px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: 22px; }
  .steps li { grid-template-columns: 1fr; gap: 6px; }
  .step-no { color: var(--ink-3); }
}

/* footer */
.foot { margin-top: auto; padding: 26px var(--pad) clamp(22px, 5vw, 42px); text-align: center; }
.foot .mono { font-size: 11px; letter-spacing: 0.06em; color: var(--ink-3); }

/* ============================================================
   sender (phone)
   ============================================================ */
.view-sender { flex-direction: column; justify-content: flex-start; }
.sender-head {
  text-align: center;
  padding: clamp(26px, 8vw, 46px) var(--pad) 20px;
  display: grid;
  gap: 8px;
  justify-items: center;
}
.brand-sm { font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; color: var(--ink-3); }
.sender-title { font-family: var(--serif); font-size: clamp(1.35rem, 4.5vw, 1.8rem); font-weight: 500; }
.sender-status { font-size: 11.5px; color: var(--ink-2); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rule); }
.sender-status[data-state="connected"] { color: var(--ok); border-color: var(--ok); }
.sender-status[data-state="sending"] { color: var(--accent); border-color: var(--accent); }
.sender-status[data-state="error"],
.sender-status[data-state="pcOffline"],
.sender-status[data-state="disconnected"] { color: var(--warn); border-color: var(--warn); }

.sender-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 8px var(--pad) 0;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color .2s, background .2s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.action:active { transform: translateY(1px); border-color: var(--accent); background: var(--accent-soft); }
.action-mark { width: 30px; height: 30px; border: 1.6px solid var(--ink); border-radius: 6px; position: relative; }
.action-mark::after { content: ""; position: absolute; inset: 50% auto auto 50%; width: 9px; height: 9px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--ink); }
.gallery-mark { border: none; border-radius: 0; background:
    linear-gradient(var(--ink), var(--ink)) 0 0/100% 1.6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 100%/100% 1.6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 0/1.6px 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 0/1.6px 100% no-repeat; }
.gallery-mark::after { display: none; }
.gallery-mark::before { content: ""; position: absolute; inset: 6px; border: 1.4px solid var(--ink-2); border-radius: 3px; }
.action-label { font-family: var(--serif); font-size: 1.08rem; }

.sender-hint { text-align: center; color: var(--ink-2); font-size: 13.5px; margin: 20px auto 0; max-width: 30ch; padding: 0 var(--pad); }
.sent-count { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 12px 0 4px; min-height: 1em; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  padding: 12px var(--pad) clamp(32px, 10vw, 64px);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.12); }
.thumb-fill { height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }
.thumb-state { position: absolute; top: 6px; right: 6px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; color: #fff; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 999px; opacity: 0; transition: opacity .2s; }
.thumb.queued .thumb-state { opacity: 1; }
.thumb.done { border-color: var(--ok); }
.thumb.done .thumb-fill { width: 100% !important; background: var(--ok); }
.thumb.done .thumb-state { opacity: 1; background: var(--ok); }

/* ---------------- responsive ---------------- */
@media (max-width: 620px) {
  .panel { grid-template-columns: 1fr; gap: 22px; padding: 22px; }
  .panel-side { align-items: stretch; }
  .panel-side .btn { align-self: stretch; text-align: center; }
  #qr-canvas { width: 208px; height: 208px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
