:root {
  color-scheme: light;
  --ink: #18263f;
  --muted: #56657c;
  --canvas: #f1f4fa;
  --paper: #fff;
  --line: #d8e1ef;
  --accent: #214ec4;
  --accent-light: #e5edff;
  --warning: #8a3827;
  --shadow: 0 5px 20px #23365b08;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 1rem/1.55 Inter, "Microsoft YaHei UI", sans-serif; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.25; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); letter-spacing: -.035em; }
h2 { font-size: 1.2rem; }
a, button { -webkit-tap-highlight-color: transparent; }
button, input, select { color: inherit; font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner, .shell { width: min(1380px, calc(100% - 48px)); margin-inline: auto; }
.header-inner, .account, .actions { display: flex; align-items: center; gap: 12px; }
.header-inner { justify-content: space-between; min-height: 64px; }
.account { min-width: 0; font-size: .875rem; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 730; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; color: #fff; background: var(--accent); }
.shell { padding: 33px 0 64px; }
.page-heading, .section-heading, .detail-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading { margin-bottom: 23px; }
.breadcrumb { margin-bottom: 7px; color: var(--muted); font-size: .875rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.section-heading { flex-wrap: wrap; padding: 18px 21px; }
.section-heading h2 + p, .login h1 + p { margin-top: 5px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 7px 13px; border: 1px solid transparent; border-radius: 7px; font-size: .875rem; font-weight: 680; text-align: center; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover { background: #163c9e; }
.button.outline { color: var(--accent); background: white; border-color: #c3d0e9; }
.button.quiet { color: var(--accent); background: transparent; }
.button.quiet:hover, .button.outline:hover { background: var(--accent-light); }
.button.danger-quiet { color: var(--warning); background: transparent; }
.button.danger-quiet:hover { background: #fff0ed; }
.button.danger { color: #fff; background: var(--warning); }
.button.danger:hover { background: #713022; }
.button:disabled { cursor: default; opacity: .55; }
.muted, .feedback { color: var(--muted); font-size: .875rem; }
.feedback[data-tone="error"], .page-error { color: var(--warning); }
.feedback:empty, .muted:empty { display: none; }
.login { width: min(435px, 100%); margin: clamp(0px, 8vh, 70px) auto 0; padding: 25px; }
.login h1 { font-size: 1.7rem; }
.login form { display: grid; gap: 6px; margin-top: 21px; }
.login label { margin-top: 7px; font-size: .875rem; font-weight: 650; }
.login input { width: 100%; min-width: 0; }
.login [aria-invalid="true"] { border-color: var(--warning); }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
#submit-login { margin-top: 9px; }
input, select { min-height: 40px; padding: 6px 10px; background: white; border: 1px solid #bfcce1; border-radius: 7px; }
.module-list, .file-list { margin: 0; padding: 0; list-style: none; }
.module { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, .8fr) minmax(0, 1fr) minmax(0, .9fr) auto; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding: 12px 21px; overflow-wrap: anywhere; }
.module.selected { background: #f0f4ff; }
.module-name { display: flex; flex-direction: column; align-items: start; min-width: 0; }
.module-name small { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.meta { display: block; color: var(--muted); font-size: .875rem; }
.saved { color: var(--accent); font-weight: 680; }
.sync { padding: 0 21px 18px; }
.sync .section-heading { padding-inline: 0; }
.file-list { margin: 8px 0; }
.file-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.sync #upload { margin-top: 13px; }
.detail-controls { padding: 0 21px 15px; flex-wrap: wrap; }
.version-picker { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.actions { flex-wrap: wrap; }
.detail .feedback { margin: 0 21px 15px; }
.preview { margin: 0; padding: 19px 21px 25px; background: #f8faff; border-top: 1px solid var(--line); border-radius: 0 0 13px 13px; color: #28364d; font: .92rem/1.75 "Cascadia Mono", Consolas, "Microsoft YaHei UI", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.page-error { margin-bottom: 16px; }
.workspace { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 30px; }
.sidebar { border-right: 1px solid var(--line); padding-right: 16px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar-link { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-weight: 650; }
.sidebar-link.active { background: var(--accent-light); color: var(--accent); }
.upcoming { color: var(--muted); }
.upcoming small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.project-nav { display: flex; gap: 22px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.project-nav > * { padding: 8px 4px 10px; font-size: .9rem; }
.project-nav a { color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.project-nav a[aria-current="page"] { color: var(--accent); border-color: var(--accent); font-weight: 700; }
.overview { padding: 20px; }
.overview h2 { margin-bottom: 5px; }
.overview-modules { margin: 14px 0; padding-left: 24px; }
.ledger-table { width: 100%; border-collapse: collapse; text-align: left; }
.ledger-table th, .ledger-table td { padding: 14px 15px; }
.ledger-table thead th { border-bottom: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.ledger-table small { display: block; color: var(--muted); font-weight: 400; }
.ledger-actions { display: flex; align-items: center; justify-content: end; gap: 3px; }
.delete-dialog { width: min(420px, calc(100% - 32px)); padding: 22px; color: var(--ink); overflow-wrap: anywhere; }
.delete-dialog::backdrop { background: #18263f60; }
.delete-dialog p { margin-top: 10px; }
.delete-dialog .actions { justify-content: end; margin-top: 18px; }
.source-body { padding: 0 21px 19px; }
.path-line { display: flex; align-items: center; gap: 12px; }
.path-line code { flex: 1; min-width: 0; padding: 9px 13px; border: 1px solid var(--line); border-radius: 7px; background: #f5f8ff; overflow-wrap: anywhere; user-select: all; }
.source-steps { margin: 12px 0 6px; padding-left: 23px; font-size: .875rem; color: var(--muted); }
.source-steps li + li { margin-top: 3px; }
.source-body .primary { margin-top: 12px; }
.storage { padding: 4px 9px; border-radius: 6px; background: var(--accent-light); color: #294788; font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ledger-heading { flex-wrap: wrap; }
.settings { padding: 20px; }
.settings h2 + p { margin-top: 6px; }
.settings-form { display: grid; gap: 7px; max-width: 420px; margin-top: 16px; }
.settings-form label { font-size: .875rem; font-weight: 650; margin-top: 5px; }
.settings-form .primary { justify-self: start; }
#approve-connection { margin-top: 12px; }
#ledger-status { margin-bottom: 12px; }
#import-panel { margin-bottom: 16px; }
.import-list label { display: grid; gap: 4px; width: 100%; }
.import-list input { max-width: 100%; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 10px; margin: 10px 0; }
.compare-grid section { min-width: 0; padding: 10px; background: #f8faff; border: 1px solid var(--line); border-radius: 7px; }
.compare-grid h3 { font-size: .9rem; margin: 0; }
.compare-grid pre { overflow: auto; max-height: 17rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 5px 0 0; }
#merge-edit { margin: 10px 0; }
#merged-body { display: block; width: 100%; margin-top: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 7px; font: .9rem/1.55 Consolas, "Microsoft YaHei UI", monospace; resize: vertical; }
#resolve-candidate { margin-top: 8px; }
@media (max-width: 760px) {
  .header-inner, .shell { width: calc(100% - 28px); }
  .module { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 12px; }
  .module-name { grid-column: 1 / -1; }
  .module .button { justify-self: end; }
  .module, .section-heading, .detail-controls, .preview { padding-inline: 14px; }
  .sync { padding-inline: 14px; }
  .detail .feedback { margin-inline: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .sidebar { border-right: 0; padding-right: 0; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar-link { gap: 5px; padding: 7px; font-size: .825rem; }
  .project-nav { gap: 9px; }
  .project-nav > * { font-size: .825rem; }
  .source-body { padding-inline: 14px; }
  .path-line { align-items: flex-start; flex-direction: column; }
  .path-line code { width: 100%; }
  .ledger-table th, .ledger-table td { padding: 8px 6px; font-size: .78rem; overflow-wrap: anywhere; }
  .ledger-table .button { padding-inline: 3px; font-size: .75rem; }
  .ledger-actions { flex-direction: column; align-items: end; }
}
@media (max-width: 420px) {
  .shell { padding-top: 22px; }
  .account { gap: 3px; }
  .account span { max-width: 94px; }
}

.ledger-table thead { background: #f6f8fd; }
.ledger-table tbody tr + tr { border-top: 1px solid var(--line); }
.ledger-table tbody tr:hover { background: #f8faff; }
.row-menu { position: relative; }
.row-menu summary, .source summary { cursor: pointer; }
.row-menu summary { list-style: none; color: var(--muted); padding: .55rem; }
.row-menu[open] > button { position: absolute; z-index: 2; top: 100%; right: 0; background: white; border-color: var(--line); box-shadow: var(--shadow); }
.source { margin-top: 16px; }
.source summary { padding: 15px 21px; font-weight: 650; }
.source summary .storage { margin-left: 8px; }
#module-status:not(:empty) { padding: 0 21px 14px; }
.module { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) auto; padding-block: 16px; }
.module-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.reader:has(#detail:not([hidden])) { display: grid; grid-template-columns: minmax(140px, 20%) minmax(0, 1fr); gap: 16px; align-items: start; }
.reader .detail { margin: 0; }
#reader-nav { padding: 12px; }
#reader-nav h3 { margin: 5px 9px 12px; font-size: .9rem; color: var(--muted); }
.reader-link { width: 100%; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; padding: .65rem; }
.reader-link[aria-current], .reader-link:hover { background: var(--accent-light); color: var(--accent); }
.preview { background: white; font: inherit; line-height: 1.8; white-space: normal; }
.preview p, .preview pre { white-space: pre-wrap; margin: .7em 0; }
.preview h3 { margin: 1.25em 0 .4em; font-size: 1.1rem; }
.preview > :first-child { margin-top: 0; }
.preview pre { padding: 12px; background: var(--canvas); }
@media(max-width: 850px) {
.module { grid-template-columns: minmax(0, 1fr) auto; }
.module-name { grid-column: auto; }
.module-actions { grid-column: 1/-1; }
.reader:has(#detail:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
.reader-link { width: auto; }
}
@media(max-width: 600px) {
.ledger-table, .ledger-table tbody, .ledger-table tr { display: block; }
.ledger-table thead { display: none; }
.ledger-table tr { padding: 10px 12px; }
.ledger-table td, .ledger-table tbody th { display: block; padding: 3px 0; font-size: .9rem; }
.ledger-table .ledger-actions { flex-direction: row; }
.version-picker { flex-wrap: wrap; }
.version-picker select { max-width: 100%; }
.detail-controls, .reader .actions { min-width: 0; }
}

.group-entry { border-top: 1px solid var(--line); }
.group-entry summary { padding: 15px 21px; font-weight: 650; cursor: pointer; }
.group-entry .button.outline { margin-left: 12px; }
.layout-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }

.task-form { display:flex; gap:10px; flex-wrap:wrap; margin:0 20px 18px }
.task-form input { flex:1; min-width:12em }
#task-drawer { box-sizing:border-box; margin:0 0 0 auto; width:min(700px,100%); max-width:100vw; height:100dvh; max-height:100dvh; border:0; color:var(--ink); padding:0 }
#task-drawer::backdrop { background:#172a474d }
.drawer-body { padding:4px 22px 28px }
.drawer-body label[for] { display:block; font-weight:700; margin:20px 0 6px }
.drawer-body select { max-width:100% }
.task-choice { padding:12px 0; border-top:1px solid var(--line) }
.task-choice label { display:flex; align-items:center; gap:8px }
.task-choice input { min-height:0 }
.task-choice details { margin:6px 0 0 22px }
.task-choice summary { cursor:pointer; color:var(--accent) }
.task-choice pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:16em; overflow:auto }
#task-copy { margin-top:12px }
.layout-trees { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:12px; margin:10px 0 }
.layout-trees section { padding:12px; border:1px solid var(--line); border-radius:8px }
.layout-trees ul { padding-inline-start:22px }

#layout-dialog { width:min(850px,94vw); max-height:90vh; border:1px solid var(--line); color:var(--ink); border-radius:12px }
#layout-dialog::backdrop { background:#172a474d }
