/* ==========================================================================
   agentlaw · 共享设计令牌与组件（h5 原型）
   --------------------------------------------------------------------------
   视觉立场：法律服务的「稳重 + 可读」。不做渐变/毛玻璃/圆角糖果风。
   - 暖纸底 + 墨色正文，衬线体只用于标题与关键数字（编辑式层级）
   - 单一强调色：铜（bronze）。状态色只用于状态，不用于装饰
   - 用发丝线（hairline）与留白分隔，而不是给每行都套一张卡片
   ========================================================================== */

:root {
  /* 面与墨 */
  --paper: #f7f5f0;
  --surface: #fffdf9;
  --surface-2: #f1eee7;
  --ink: #15181d;
  --ink-2: #3c4350;
  --muted: #5f6673;
  --line: #e3ded4;
  --line-strong: #cec6b6;

  /* 强调与语义 */
  --accent: #8a5a2f;
  --accent-ink: #6d4522;
  --accent-soft: #f3e8da;
  --blue: #2f5d7c;
  --blue-soft: #e7eef3;
  --green: #3c6b4f;
  --green-soft: #e7efe8;
  --danger: #9c3b34;
  --danger-soft: #f7e9e7;

  /* 形状 */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(21, 24, 29, 0.05), 0 10px 30px -22px rgba(21, 24, 29, 0.45);
  --shadow-2: 0 2px 6px rgba(21, 24, 29, 0.07), 0 24px 60px -30px rgba(21, 24, 29, 0.5);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* 节奏 */
  --gap: 16px;
  --pad-x: 18px;
}

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

/* 作者样式里的 display（.topbar{flex} / .auth{grid}）会盖掉 UA 的 [hidden]{display:none}，
   所以显式兜一层，否则 JS 里 el.hidden = true 不起作用。 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

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

.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   外壳
   -------------------------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--pad-x) calc(32px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad-x) 12px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: var(--surface);
  font-family: var(--font-serif); font-size: 17px;
  border-radius: 8px;
  letter-spacing: 0;
}
.brand-name { font-family: var(--font-serif); font-size: 17px; line-height: 1.15; letter-spacing: 0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }

.topbar-spacer { flex: 1; }

.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-meta { text-align: right; line-height: 1.25; min-width: 0; }
.who-name { font-size: 13px; font-weight: 600; }
.who-role { font-size: 11px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 600;
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  --btn-bg: var(--ink);
  --btn-fg: var(--surface);
  --btn-bd: var(--ink);
}
.btn--primary:hover { --btn-bg: #232c3a; }

.btn--accent {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  --btn-bd: var(--accent);
}
.btn--accent:hover { --btn-bg: var(--accent-ink); }

.btn--ghost { --btn-bg: transparent; --btn-bd: var(--line-strong); }
.btn--ghost:hover { --btn-bg: var(--surface-2); }

.btn--danger { --btn-fg: var(--danger); --btn-bd: #e2c4bf; --btn-bg: transparent; }
.btn--danger:hover { --btn-bg: var(--danger-soft); }

.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }

/* --------------------------------------------------------------------------
   标签 / 状态
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.pill[data-status="pending"] { color: var(--accent-ink); background: var(--accent-soft); border-color: #e6d4bf; }
.pill[data-status="processing"] { color: var(--blue); background: var(--blue-soft); border-color: #cfdde7; }
.pill[data-status="done"] { color: var(--green); background: var(--green-soft); border-color: #cfdccf; }

.tag-urgent {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--danger); background: var(--danger-soft);
  border: 1px solid #e8cdc8; border-radius: 4px;
}

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.label .req { color: var(--danger); font-size: 12px; }
.label .hint { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }

.input,
.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font-size: 15px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.input::placeholder,
.textarea::placeholder { color: #9aa1ac; }
.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 90, 47, 0.13);
}
.textarea { min-height: 132px; resize: vertical; line-height: 1.65; }
/* 只读：登录后带入的账号信息，不需要也不允许在表单里改 */
.input[readonly] {
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: default;
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(156, 59, 52, 0.1); }

.field-error {
  display: none;
  font-size: 12px; color: var(--danger);
}
.field-error.is-shown { display: block; }

/* 单选项（咨询类型 / 加急） */
.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  position: relative;
  display: inline-flex; align-items: center;
  min-height: 40px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  font-size: 14px; color: var(--ink-2);
  cursor: pointer;
  transition: all 0.14s ease;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:hover { border-color: var(--ink-2); }
.opt:has(input:checked) {
  background: var(--ink); border-color: var(--ink); color: var(--surface);
}
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 44px; height: 26px; flex: none;
  background: var(--line-strong); border-radius: 999px; position: relative;
  transition: background-color 0.16s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.16s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   卡片 / 分节
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.section-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-serif);
  font-size: 15px; letter-spacing: 0.02em;
}
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* --------------------------------------------------------------------------
   提示条 / 轻提示
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 90;
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   遮罩（移动端抽屉用）
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(21, 24, 29, 0.38);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.scrim.is-shown { opacity: 1; }

.footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: center;
  font-size: 12px; color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.footer a:hover { color: var(--ink); }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-strong);
}
.linkish:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
