/* ─────────────────────────────────────────────────────────────
   文本投递台 · Text Dispatch
   白底 / 黑字 / 一个信号色（克莱因蓝 #002FA7）
   ───────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo-latin-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper:      #ffffff;
  --panel:      #fbfbfa;
  --ink:        #111112;
  --ink-2:      #5c5c59;
  --ink-3:      #9b9b96;
  --line:       #e6e6e2;
  --line-soft:  #f0f0ed;
  --signal:     #002fa7;
  --signal-ink: #00248a;
  --signal-tint:#edf1fb;

  --font-ui:   'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
               'Liberation Mono', monospace;

  --rail-w: 106px;
  --mono-size: 13.5px;
  --mono-lh: 1.72;
  --lh: 23.22px;          /* 行高 */
  --rule-offset: 34.47px; /* 首行基线位置 = 上内边距 18px + 半行距 + 上伸部 */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 顶栏 ────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand__mark {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--signal);
}
.brand__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.brand__latin {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 3px;
  white-space: nowrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.topbar__domain {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--ink-2);
}
.topbar__rule {
  width: 1px;
  height: 11px;
  background: var(--line);
}
.topbar__state {
  letter-spacing: .06em;
  min-width: 4em;
}

/* ── 舞台 ────────────────────────────────────────────────── */

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.work {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  padding: 24px 26px 22px;
}

/* ── 表单纸 ──────────────────────────────────────────────── */

.sheet {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--paper);
}

.sheet__head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet__tag {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.sheet__sub {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sheet__count {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sheet__count b {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.sheet__count i {
  display: inline-block;
  width: 1px;
  height: 10px;
  margin: 0 5px;
  background: var(--line);
  transform: translateY(1px);
}

/* ── 编辑区 ──────────────────────────────────────────────── */

.editor {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.editor__rule {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 46px;
  width: 1px;
  background: var(--line);
  pointer-events: none;
}
.editor__area {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  margin: 0;
  padding: 18px 20px 18px 64px;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--line-soft) 0 1px,
    transparent 1px var(--lh)
  );
  background-position: 0 var(--rule-offset);
  background-attachment: local;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--mono-size);
  line-height: var(--mono-lh);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  tab-size: 2;
}
.editor__area::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
.editor__area:focus-visible {
  outline: none;
}

/* ── 结果条 ──────────────────────────────────────────────── */

.result {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  background: var(--signal-tint);
  padding: 11px 16px 13px;
}
.result__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.result__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--signal);
  letter-spacing: .02em;
}
.result__meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.result__url {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  overflow-x: auto;
}
.result__url:focus {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}

/* ── 说明 ────────────────────────────────────────────────── */

.note {
  flex: 0 0 auto;
  margin: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
}

/* ── 收件正文 ────────────────────────────────────────────── */

.readbody {
  flex: 1 1 auto;
  margin: 0;
  padding: 18px 20px 18px 64px;
  overflow: auto;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--line-soft) 0 1px,
    transparent 1px var(--lh)
  );
  background-position: 0 var(--rule-offset);
  background-attachment: local;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--mono-size);
  line-height: var(--mono-lh);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

/* ── 投递栏（右）─────────────────────────────────────────── */

.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 13px 15px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.rail__group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rbtn {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 11px 5px 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .08s ease;
}
.rbtn__icon {
  width: 19px;
  height: 19px;
  margin-bottom: 1px;
}
.rbtn__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.3;
  white-space: nowrap;
}
.rbtn__cap {
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.rbtn:hover {
  border-color: var(--ink-3);
}
.rbtn:active {
  transform: translateY(1px);
}
.rbtn:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
.rbtn[disabled] {
  opacity: .4;
  cursor: not-allowed;
}
.rbtn[disabled]:hover {
  border-color: var(--line);
}

.rbtn--primary {
  background: var(--signal);
  border-color: var(--signal);
  color: #fff;
}
.rbtn--primary .rbtn__cap {
  color: rgba(255, 255, 255, .6);
}
.rbtn--primary:hover {
  background: var(--signal-ink);
  border-color: var(--signal-ink);
}
.rbtn--primary[disabled]:hover {
  background: var(--signal);
  border-color: var(--signal);
}

.rail__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.rail__led {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: background .2s ease, box-shadow .2s ease;
}
.rail__led.is-on {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-tint);
}
.rail__status {
  font-size: 10.5px;
  letter-spacing: .03em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 提示 ────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: calc(var(--rail-w) + 22px);
  bottom: 22px;
  z-index: 60;
  max-width: min(70vw, 420px);
  padding: 9px 16px;
  background: var(--ink);
  border-left: 3px solid var(--signal);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-on {
  opacity: 1;
  transform: translateY(0);
}

/* ── 响应式 ──────────────────────────────────────────────── */

@media (max-width: 860px) {
  :root { --rail-w: 92px; }
  .work { padding: 16px 16px 14px; }
  .brand__latin { display: none; }
  .editor__area,
  .readbody { padding-left: 56px; }
  .editor__rule { left: 38px; }
}

@media (max-width: 560px) {
  :root { --rail-w: 78px; }
  body { font-size: 14px; }
  .topbar { height: 52px; padding: 0 14px; }
  .topbar__domain { display: none; }
  .work { padding: 10px 10px 10px; }
  .rbtn { padding: 9px 3px 7px; }
  .rbtn__label { font-size: 11px; }
  .rbtn__cap { display: none; }
  .rbtn__icon { width: 17px; height: 17px; }
  .editor__area,
  .readbody { padding: 14px 14px 14px 44px; font-size: 13px; }
  .editor__rule { left: 28px; }
  .sheet__count { font-size: 10.5px; }
  .sheet__sub { display: none; }
  .note { font-size: 11px; }
  .rail__status { font-size: 9.5px; }
  .toast {
    left: 10px;
    right: calc(var(--rail-w) + 10px);
    bottom: 12px;
    max-width: none;
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
