:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #64666f;
  --faint: #70727b;
  --line: #e2e2e5;
  --line-strong: #c9c9ce;
  --canvas: #fbfbfc;
  --sidebar: #f5f5f6;
  --paper: #ffffff;
  --hover: #f2f2f4;
  --accent: #5b59d6;
  --accent-strong: #4947bd;
  --accent-soft: #ebeaff;
  --warning-ink: #764600;
  --warning-bg: #fff5df;
  --warning-line: #e2b85c;
  --success-ink: #17613c;
  --success-bg: #eaf6ee;
  --neutral-ink: #4e5059;
  --neutral-bg: #ededf0;
  --focus: #315efb;
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.35rem, 2.1vw, 1.55rem); font-weight: 650; line-height: 1.3; letter-spacing: -.018em; }
h2 { margin-bottom: 0; font-size: 1rem; font-weight: 650; line-height: 1.4; }
p { color: var(--muted); line-height: 1.55; }
small { color: var(--muted); font-size: .8rem; line-height: 1.45; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.skip-link { position: absolute; left: -9999px; z-index: 20; }
.skip-link:focus { top: 8px; left: 8px; padding: 8px 11px; border-radius: 5px; color: #fff; background: var(--ink); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  background: rgb(251 251 252 / 94%);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  width: 100%;
  gap: 9px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: var(--sidebar);
  font-weight: 650;
  white-space: nowrap;
}
.brand:hover { background: #f0f0f2; }
.brand-mark { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 6px; color: #fff; background: #2f3034; font-size: 12px; font-weight: 700; }
.search-form { position: relative; display: grid; grid-template-columns: minmax(0, 460px) auto; justify-content: end; gap: 7px; padding: 7px 24px; }
.search-form input { min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #f7f7f8; transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease; }
.search-form input:hover { border-color: var(--line-strong); }
.search-form input:focus { border-color: #9d9ce7; background: var(--paper); box-shadow: 0 0 0 3px rgb(91 89 214 / 10%); }
.search-form button, .primary-action, .form-actions button { min-height: 36px; padding: 7px 12px; border: 1px solid var(--accent); border-radius: 6px; color: #fff; background: var(--accent); font-weight: 650; transition: background 120ms ease, border-color 120ms ease, transform 120ms ease; }
.search-form button:hover, .primary-action:hover, .form-actions button:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.search-form button:active, .primary-action:active, .form-actions button:active { transform: translateY(1px); }

.app-main { min-height: calc(100vh - 52px); }
.workspace-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 52px); align-items: stretch; }
.member-rail { position: sticky; top: 52px; align-self: start; min-height: calc(100vh - 52px); padding: 15px 10px 20px; border-right: 1px solid var(--line); background: var(--sidebar); }
.rail-heading, .section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rail-heading { min-height: 30px; padding: 0 8px 6px; }
.rail-heading h2 { color: var(--muted); font-size: .77rem; font-weight: 600; letter-spacing: .02em; }
.text-action, .back-link { padding: 5px 4px; border: 0; color: var(--muted); background: transparent; font-weight: 600; }
.text-action:hover, .back-link:hover { color: var(--ink); }
.member-nav { display: grid; gap: 2px; }
.member-nav-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; color: var(--ink); background: transparent; text-align: left; transition: background 100ms ease, border-color 100ms ease; }
.member-nav-row:hover { background: #ededf0; }
.member-nav-row.is-active { border-color: #dcdbe8; background: var(--paper); box-shadow: 0 1px 2px rgb(20 20 24 / 4%); }
.avatar { display: grid; flex: 0 0 auto; width: 27px; height: 27px; place-items: center; border-radius: 6px; color: #565861; background: #e7e7ea; font-size: .75rem; font-weight: 650; }
.avatar-blue { color: #3f5480; background: #e8edf7; }
.avatar-green { color: #386245; background: #e8f0ea; }
.avatar-orange { color: #75511d; background: #f6eddc; }
.avatar-purple { color: #65507b; background: #eee8f4; }
.member-nav-copy { display: grid; min-width: 0; gap: 0; }
.member-nav-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 600; }
.member-nav-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.member-label { display: inline-flex; width: max-content; max-width: 100%; margin-left: 4px; padding: 0 4px; border: 1px solid #dedee2; border-radius: 4px; color: var(--muted); font-size: .69rem; font-weight: 400; line-height: 1.45; white-space: nowrap; vertical-align: .08em; }
.rail-home { width: calc(100% - 8px); min-height: 34px; margin: 10px 4px 0; padding: 7px 8px; border: 0; border-top: 1px solid var(--line); color: var(--muted); background: transparent; text-align: left; font-size: .82rem; font-weight: 600; }
.rail-home:hover { color: var(--ink); }

.workspace-main { min-width: 0; padding: 26px clamp(22px, 3.1vw, 44px) 48px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; min-height: 72px; padding: 0 0 17px; border-bottom: 1px solid var(--line); }
.page-header > div:first-child { min-width: 0; }
.page-header p { margin-bottom: 0; font-size: .9rem; }
.page-kicker { margin-bottom: 3px; color: var(--faint); font-size: .74rem; font-weight: 600; letter-spacing: .025em; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.secondary-action { min-height: 36px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--paper); font-weight: 600; white-space: nowrap; }
.secondary-action:hover { border-color: #aaaab1; background: var(--hover); }

.list-section { margin-top: 18px; border-top: 1px solid var(--line); background: transparent; }
.section-heading { min-height: 52px; padding: 9px 4px 9px 0; border-bottom: 1px solid var(--line); }
.section-heading > div { min-width: 0; }
.section-heading p { margin: 2px 0 0; font-size: .82rem; }
.section-heading > span, .search-group h2 span { color: var(--muted); font-size: .8rem; font-weight: 400; }
.directory-row { display: grid; grid-template-columns: 30px minmax(150px, 1.3fr) 110px minmax(150px, 1fr) 16px; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 7px 8px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.directory-row:hover { background: var(--hover); }
.directory-name { display: flex; align-items: center; min-width: 0; gap: 4px; }
.directory-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.directory-count, .directory-date { color: var(--muted); font-size: .83rem; }
.row-arrow { color: var(--faint); font-size: 1rem; line-height: 1; text-align: right; }

.attention-band { display: flex; align-items: center; gap: 9px; margin-top: 14px; padding: 9px 11px; border: 1px solid #ecd8ad; border-left: 3px solid var(--warning-line); border-radius: 6px; background: var(--warning-bg); color: var(--warning-ink); font-size: .88rem; line-height: 1.45; }
.attention-band strong { white-space: nowrap; font-weight: 650; }
.record-table { display: grid; }
.record-table-row { display: grid; grid-template-columns: 92px minmax(180px, 1.45fr) minmax(140px, 1fr) 82px 16px; align-items: center; gap: 12px; width: 100%; min-height: 57px; padding: 8px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.record-table-row:hover { background: var(--hover); }
.record-table-row time, .record-source { color: var(--muted); font-size: .82rem; }
.record-title { display: grid; min-width: 0; gap: 1px; }
.record-title strong { font-weight: 600; }
.record-title strong, .record-source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; width: max-content; max-width: 100%; min-height: 24px; padding: 3px 7px; border: 1px solid transparent; border-radius: 5px; font-size: .75rem; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.status-warning { border-color: #eddbb6; color: var(--warning-ink); background: var(--warning-bg); }
.status-success { border-color: #cfe7d7; color: var(--success-ink); background: var(--success-bg); }
.status-neutral { border-color: #dddde1; color: var(--neutral-ink); background: var(--neutral-bg); }
.secondary-section { margin-top: 18px; }
.measurement-list { display: grid; }
.measurement-row { display: grid; grid-template-columns: 92px minmax(150px, 1fr) minmax(120px, 1fr) 82px; align-items: center; gap: 12px; min-height: 52px; padding: 8px; border-bottom: 1px solid var(--line); }
.measurement-row time, .measurement-row > span:not(.status-badge) { color: var(--muted); font-size: .82rem; }
.measurement-row strong { font-weight: 600; }

.action-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; padding: 15px; border: 1px solid #d9d8ef; border-radius: 7px; background: #f8f8ff; }
.panel-heading { grid-column: 1 / -1; align-items: flex-start; padding-bottom: 2px; }
.panel-heading h2 { margin: 0; }
.panel-heading p { margin: 3px 0 0; font-size: .82rem; }
.action-panel label { display: grid; gap: 5px; color: var(--ink); font-size: .82rem; font-weight: 600; }
.action-panel input, .action-panel select { min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink); background: #fff; font-weight: 400; }
.action-panel input[type="file"] { padding: 6px; }
.field-wide { grid-column: span 2; }
.form-actions { display: flex; align-items: end; gap: 8px; }
.session-note { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .78rem; }
.member-editor { grid-template-columns: repeat(2, minmax(0, 280px)); }
.member-editor .panel-heading, .member-editor .session-note { grid-column: 1 / -1; }

.record-page-header { align-items: center; }
.back-link { display: block; margin: -3px 0 5px; font-size: .82rem; }
.record-workbench { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .85fr); gap: 1px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.document-stage, .inspection-panel { background: var(--paper); }
.document-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 43px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.document-toolbar strong { font-weight: 600; }
.document-toolbar span { color: var(--muted); font-size: .8rem; }
.document-canvas { display: grid; min-height: 430px; place-items: center; padding: 22px; background: #f1f1f3; }
.preview-page { display: grid; width: min(90%, 430px); min-height: 310px; gap: 18px; padding: 30px; border: 1px solid #e4e4e6; background: #fff; box-shadow: 0 8px 24px rgb(28 28 32 / 8%); }
.preview-page p { margin: 0; color: var(--muted); font-size: .8rem; }
.preview-page strong { font-size: 1.2rem; font-weight: 650; line-height: 1.5; }
.preview-page span { color: var(--muted); }
.preview-page small { align-self: end; }
.inspection-panel { overflow: hidden; }
.inspection-section { padding: 14px; border-bottom: 1px solid var(--line); }
.inspection-section:last-of-type { border-bottom: 0; }
.inspection-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inspection-heading span { color: var(--muted); font-size: .75rem; }
.inspection-section h2 { margin: 0 0 9px; font-size: .92rem; }
.inspection-section pre { max-height: 330px; overflow: auto; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 5px; background: #f7f7f8; color: var(--ink); font: .86rem/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.meta-grid div { display: grid; gap: 2px; }
.meta-grid dt { color: var(--muted); font-size: .75rem; }
.meta-grid dd { margin: 0; font-size: .86rem; line-height: 1.45; }
.candidate-details { padding: 13px 14px; }
.candidate-details summary { color: var(--ink); font-weight: 600; cursor: pointer; }
.candidate-details ul { margin: 9px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.55; }

.search-results { margin-top: 18px; }
.search-group { margin-bottom: 18px; border-top: 1px solid var(--line); background: transparent; }
.search-group h2 { display: flex; align-items: center; justify-content: space-between; min-height: 46px; margin: 0; padding: 8px 4px 8px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) 16px; align-items: center; gap: 12px; width: 100%; min-height: 53px; padding: 7px 8px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.search-row:hover { background: var(--hover); }
.search-result-copy { display: grid; min-width: 0; gap: 2px; }
.search-result-copy strong { font-weight: 600; }
.search-result-copy strong, .search-result-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { margin: 0; padding: 22px 12px; color: var(--muted); text-align: center; line-height: 1.55; }
.compact-empty { border: 1px dashed var(--line-strong); border-radius: 5px; font-size: .84rem; }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 12; max-width: min(360px, calc(100% - 32px)); border: 1px solid #3d3e43; border-radius: 6px; color: #fff; background: #27282c; box-shadow: 0 8px 24px rgb(0 0 0 / 16%); }
.toast-region:not(:empty) { padding: 9px 11px; }

@media (max-width: 880px) {
  .app-header { grid-template-columns: 1fr; }
  .brand { min-height: 48px; border-right: 0; border-bottom: 1px solid var(--line); }
  .search-form { grid-template-columns: minmax(0, 1fr) auto; padding: 7px 12px; }
  .workspace-shell { grid-template-columns: minmax(0, 1fr); }
  .member-rail { position: static; min-width: 0; max-width: 100%; min-height: 0; overflow: hidden; padding: 9px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-heading { padding: 0 2px 5px; }
  .member-nav { display: flex; width: 100%; overflow-x: auto; gap: 5px; padding-bottom: 2px; }
  .member-nav-row { grid-template-columns: 26px auto; width: max-content; min-width: 132px; min-height: 45px; }
  .member-nav-copy small { display: none; }
  .rail-home { display: none; }
  .workspace-main { padding-top: 20px; }
  .record-workbench { grid-template-columns: 1fr; gap: 1px; }
  .document-canvas { min-height: 360px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .brand { padding: 0 12px; }
  .search-form button { padding: 7px 10px; }
  .workspace-main { padding: 16px 12px 36px; }
  .page-header { flex-direction: column; gap: 11px; min-height: 0; padding-bottom: 14px; }
  .header-actions { width: 100%; justify-content: stretch; }
  .header-actions button { flex: 1; }
  .page-header > .secondary-action { width: 100%; }
  .directory-row { grid-template-columns: 30px minmax(0, 1fr) 16px; gap: 9px; padding: 8px 5px; }
  .directory-count, .directory-date { display: none; }
  .record-table-row { grid-template-columns: 74px minmax(0, 1fr) 16px; gap: 8px; padding: 9px 5px; }
  .record-source { grid-column: 2; }
  .status-badge { grid-column: 2; }
  .record-table-row .row-arrow { grid-column: 3; grid-row: 1 / span 3; }
  .measurement-row { grid-template-columns: 76px minmax(0, 1fr); gap: 7px; padding: 9px 5px; }
  .measurement-row > span:not(.status-badge), .measurement-row .status-badge { grid-column: 2; }
  .section-heading { min-height: 0; padding: 10px 2px 10px 0; align-items: flex-start; }
  .section-heading > span { padding-top: 2px; white-space: nowrap; }
  .action-panel, .member-editor { grid-template-columns: 1fr; padding: 12px; }
  .field-wide { grid-column: auto; }
  .form-actions { align-items: stretch; }
  .form-actions button { width: 100%; }
  .document-canvas { min-height: 300px; padding: 12px; }
  .preview-page { min-height: 250px; padding: 22px; }
  .meta-grid { grid-template-columns: 1fr; gap: 10px; }
  .inspection-section pre { max-height: none; }
  .member-page-header h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
