:root {
  color-scheme: light;
  --paper: #faf7f1;
  --surface: #fffdfa;
  --ink: #302f2b;
  --muted: #77756e;
  --line: #e7e1d7;
  --accent: #a65334;
  --accent-soft: #f4e7da;
  --green: #377361;
  --danger: #ad3f37;
  --shadow: 0 18px 60px #41372712;
  font-family: Inter,"SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
}

button,input,select,textarea {
  font: inherit;
}

button,.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .4rem;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s,border-color .15s;
}

button:hover,.button:hover {
  background: var(--accent-soft);
  border-color: #d3bba7;
}

button:disabled {
  opacity: .5;
  cursor: wait;
}

button.primary,.button.primary {
  background: var(--ink);
  color: #fffdfa;
  border-color: var(--ink);
}

button.primary:hover,.button.primary:hover {
  background: #514737;
}

button.subtle,.button.subtle {
  background: transparent;
}

button.danger {
  color: var(--danger);
}

button.small,.button.small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

input,select,textarea {
  min-width: 0;
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input[type=checkbox],input[type=radio] {
  width: auto;
  accent-color: var(--accent);
  min-height: 16px;
  min-width: 16px;
}

input:focus,select:focus,textarea:focus {
  border-color: var(--accent);
  outline: 2px solid #a653341a;
  outline-offset: 1px;
}

button:focus-visible,a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label>span:first-child {
  font-size: 12px;
  color: var(--muted);
}

a {
  color: var(--accent);
}

h1,h2,h3,p {
  margin: 0;
}

h1 {
  font-size: clamp(25px,3vw,36px);
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.35;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
}

h3 {
  font-size: 14px;
}

.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;
}

[hidden] {
  display: none!important;
}

.archive-topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px,4vw,64px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  font-size: 19px;
  font-weight: 650;
  white-space: nowrap;
}

.brand>span:last-child {
  font-size: 14px;
  font-weight: 500;
}

.brand .brand-mark {
  width: 28px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #caa286;
  border-radius: 15px 15px 9px 9px;
  color: var(--accent);
  font: italic 25px Georgia,serif;
}

.brand-divider {
  color: #c2bbae;
  padding: 0 3px;
}

.topbar-actions,.intro-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}

.profile-label {
  max-width: 230px;
}

.profile-label select {
  background: transparent;
  border: 0;
}

.archive-shell {
  max-width: 1500px;
  padding: 38px clamp(18px,4vw,64px) 64px;
  margin: auto;
}

.archive-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.archive-intro .muted {
  margin-top: 10px;
}

.search-panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 10px;
  margin-bottom: 24px;
}

.search-field input {
  border: 0;
  background: var(--paper);
  height: 42px;
}

.search-filters {
  grid-column: 1/-1;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.search-filters label {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}

.search-filters label>span {
  white-space: nowrap;
}

.search-filters input,.search-filters select {
  padding: 6px 8px;
  font-size: 12px;
}

.library-layout {
  display: grid;
  grid-template-columns: 290px minmax(0,1fr);
  gap: 26px;
  align-items: start;
}

.library-sidebar {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 13px;
}

.section-heading h2 {
  font-size: 13px;
  color: var(--muted);
  font-weight: 550;
}

.count {
  font-size: 11px;
  min-width: 24px;
  text-align: center;
  background: var(--line);
  border-radius: 12px;
  padding: 1px 6px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.session-card {
  display: block;
  text-align: left;
  width: 100%;
  padding: 15px;
  background: transparent;
  border-color: transparent;
  overflow: hidden;
}

.session-card.active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 3px 12px #41372705;
}

.session-card h3 {
  overflow-wrap: anywhere;
  margin: 7px 0 5px;
  font-size: 14px;
}

.session-card .card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
}

.session-card p {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card .snippet {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 90px;
  color: var(--ink);
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 650;
  background: var(--accent-soft);
  color: #875039;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

.badge.green {
  background: #e8f0e9;
  color: var(--green);
}

.badge.warning {
  background: #f7edce;
  color: #8c681e;
}

.session-detail {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.detail-header {
  padding: 25px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
  margin: 10px 0 7px;
}

.detail-title-row h2 {
  font-size: 23px;
  overflow-wrap: anywhere;
}

.detail-path {
  font-family: ui-monospace,SFMono-Regular,Consolas,monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 17px;
}

.capture-state {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--paper);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.lineage {
  margin-top: 9px;
  font-size: 12px;
  color: var(--muted);
}

.timeline-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 28px;
  background: #faf7f170;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.inline-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
}

.inline-check>span:first-child {
  color: inherit;
  font-size: inherit;
}

.timeline {
  padding: 0 28px 22px;
}

.event {
  padding: 23px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 20px;
}

.event:last-child {
  border-bottom: 0;
}

.event.highlight {
  background: #fbedd3;
  outline: 10px solid #fbedd3;
  border-radius: 2px;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  margin-bottom: 10px;
  color: var(--muted);
}

.event-role {
  font-weight: 650;
  color: var(--ink);
  font-size: 12px;
}

.event-seq {
  margin-left: auto;
  font-family: ui-monospace,monospace;
}

.event-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.85;
  font-size: 13px;
}

.event.tool .event-text {
  font-family: ui-monospace,SFMono-Regular,Consolas,monospace;
  background: var(--paper);
  padding: 13px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.7;
  max-height: 320px;
  overflow: auto;
}

.event details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}

.event-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.event-controls button {
  font-size: 10px;
  min-height: 26px;
  padding: 3px 7px;
  background: transparent;
  color: var(--muted);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.code-anchor {
  font-size: 10px;
  color: var(--muted);
  font-family: ui-monospace,monospace;
  margin-top: 9px;
  overflow-wrap: anywhere;
}

.empty-card {
  padding: 35px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

.empty-card h2 {
  color: var(--ink);
  margin: 12px 0 8px;
}

.empty-card .button {
  margin-top: 16px;
}

.empty-card.spacious {
  border: 0;
  padding: 100px 25px;
  min-height: 420px;
}

.empty-glyph {
  font: 48px Georgia,serif;
  color: #b09e88;
}

.notice {
  padding: 12px 16px;
  border: 1px solid #d7dfcf;
  border-radius: 9px;
  background: #f0f4e8;
  overflow-wrap: anywhere;
  margin-bottom: 18px;
  font-size: 13px;
}

.notice.error {
  background: #fbebe6;
  border-color: #e8c3b9;
  color: #84382e;
}

.notice.info {
  background: var(--accent-soft);
  border-color: #e3cfbb;
  color: #654e3c;
}

.load-more {
  display: block;
  margin: 18px auto;
}

.action-dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 760px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 48px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.action-dialog::backdrop {
  background: #27252170;
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.dialog-heading h2 {
  font-size: 18px;
}

#dialog-content {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.dialog-help {
  font-size: 13px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-grid .wide {
  grid-column: 1/-1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 16px;
  max-height: 340px;
  overflow: auto;
}

.preview .event {
  padding: 12px 0;
}

.raw-json {
  font: 11px/1.7 ui-monospace,SFMono-Regular,Consolas,monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
}

.facts-list {
  font-size: 12px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 7px 12px;
  margin: 0;
}

.facts-list dt {
  color: var(--muted);
}

.facts-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.share-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 12px;
}

.share-link {
  font: 12px ui-monospace,monospace;
  resize: none;
  min-height: 68px;
}

.share-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-result .notice {
  margin: 0;
}

.approval-section {
  border-bottom: 1px solid var(--line);
  padding: 20px 28px;
  background: #fffaf0;
}

.approval-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.approval-heading h3 {
  font-size: 13px;
}

.approval-status {
  font-size: 11px;
  color: var(--muted);
}

.approval-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.approval-card {
  padding: 15px;
  border: 1px solid #e2cfb4;
  border-radius: 10px;
  background: var(--surface);
}

.approval-card h3 {
  margin-bottom: 5px;
}

.approval-card .request-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 10px;
}

.approval-card pre {
  font: 11px/1.7 ui-monospace,monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 12px;
  background: var(--paper);
  max-height: 260px;
  overflow: auto;
}

.approval-card label {
  margin: 10px 0;
}

.approval-options {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.approval-options label {
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.approval-options small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.approval-audit {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

.approval-audit summary {
  cursor: pointer;
}

.approval-audit p {
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.comparison-grid .preview {
  max-height: 420px;
}

.shared-shell {
  max-width: 840px;
  margin: 48px auto;
  padding: 0 25px;
}

.shared-shell>h1 {
  margin-bottom: 10px;
}

.share-access {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin: 26px 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.share-access label {
  flex: 1;
}

.shared-events {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 28px;
}

.shared-events:empty {
  display: none;
}

.share-footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 25px 0 40px;
}

.omitted {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

@media(min-width:1450px) {
  .library-layout {
    grid-template-columns: 320px minmax(0,1fr);
    gap: 32px;
  }
  .timeline,.detail-header,.approval-section {
    padding-left: 36px;
    padding-right: 36px;
  }
}

@media(max-width:1000px) {
  .search-filters {
    grid-template-columns: 1fr 1fr;
  }
  .library-layout {
    grid-template-columns: 230px minmax(0,1fr);
    gap: 16px;
  }
  .archive-intro {
    align-items: flex-start;
  }
  .intro-actions {
    flex-shrink: 0;
    flex-direction: column;
    align-items: stretch;
  }
  .detail-header,.timeline,.approval-section {
    padding-left: 20px;
    padding-right: 20px;
  }
  .timeline-bar {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media(max-width:720px) {
  .archive-topbar {
    height: 66px;
    padding: 0 16px;
    gap: 8px;
  }
  .brand {
    font-size: 17px;
    gap: 7px;
  }
  .brand>span:last-child {
    font-size: 12px;
  }
  .brand-divider {
    padding: 0;
  }
  .topbar-actions .button {
    display: none;
  }
  .profile-label {
    max-width: 125px;
  }
  .profile-label select {
    font-size: 12px;
    padding: 6px;
  }
  .archive-shell {
    padding: 27px 16px 40px;
  }
  .archive-intro {
    display: block;
    margin-bottom: 22px;
  }
  .archive-intro h1 {
    font-size: 26px;
    letter-spacing: -.5px;
  }
  .archive-intro .muted {
    font-size: 12px;
  }
  .intro-actions {
    flex-direction: row;
    margin-top: 18px;
  }
  .search-panel {
    padding: 11px;
    margin-bottom: 20px;
    gap: 7px;
  }
  .search-panel>button {
    padding: 7px 10px;
  }
  .search-field input {
    font-size: 12px;
    padding: 8px;
  }
  .search-filters {
    gap: 9px;
  }
  .search-filters label {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .search-filters label>span {
    font-size: 10px;
  }
  .library-layout {
    display: block;
  }
  .library-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 18px;
    overflow: visible;
  }
  .session-list {
    flex-direction: row;
    overflow: auto;
    padding-bottom: 5px;
    scroll-snap-type: x proximity;
  }
  .session-card {
    flex: 0 0 230px;
    scroll-snap-align: start;
    border: 1px solid var(--line);
    border-radius: 10px;
    max-height: 180px;
  }
  .session-card.active {
    border-color: #bb977b;
    background: #fff9ec;
  }
  .section-heading {
    padding-bottom: 8px;
  }
  .detail-header {
    padding: 18px 17px 14px;
  }
  .detail-title-row h2 {
    font-size: 20px;
  }
  .detail-actions {
    gap: 6px;
  }
  .detail-actions button {
    font-size: 11px;
    padding: 6px 9px;
    min-height: 32px;
  }
  .timeline,.approval-section {
    padding-left: 17px;
    padding-right: 17px;
  }
  .timeline-bar {
    padding: 10px 17px;
    font-size: 11px;
  }
  .event {
    padding: 20px 0;
  }
  .event-text {
    font-size: 13px;
  }
  .event-header {
    gap: 6px;
  }
  .event-header time {
    font-size: 10px;
  }
  .form-grid,.comparison-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .wide {
    grid-column: auto;
  }
  .action-dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 20px);
  }
  .dialog-heading {
    padding: 14px 16px;
  }
  #dialog-content {
    padding: 17px 16px;
  }
  .facts-list {
    grid-template-columns: 85px 1fr;
  }
  .shared-shell {
    padding: 0 17px;
    margin-top: 30px;
  }
  .shared-events {
    padding: 0 17px;
  }
  .share-access {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }
  .share-row {
    align-items: flex-start;
  }
  .notice {
    font-size: 12px;
  }
  .empty-card.spacious {
    min-height: 260px;
    padding: 50px 20px;
  }
}

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