:root {
  color-scheme: light;
  --color-canvas: #FBF9FD;
  --color-surface: #FFFFFF;
  --color-surface-subtle: #F7F4F9;
  --color-surface-hover: #F5F1F8;
  --color-surface-selected: #F2EDFF;
  --color-border: #E5DFE9;
  --color-border-strong: #C9C0D0;
  --color-text: #18141F;
  --color-text-muted: #68616F;
  --color-text-inverse: #FFFFFF;
  --color-brand: #4A0E78;
  --color-brand-hover: #5B168E;
  --color-brand-pressed: #350858;
  --color-brand-luminous: #6C32D9;
  --color-brand-soft: #F2EDFF;
  --color-focus: #9B59B6;
  --color-focus-dark: #9B74F2;
  --color-info: #1769AA;
  --color-info-soft: #EAF4FB;
  --color-success: #137A5A;
  --color-warning: #A85D00;
  --color-danger: #B3261E;
  --color-danger-soft: #FDECEA;
  --color-warm: #C9A66B;
  --color-role-blue: #168FDC;
  --color-role-blue-soft: #DCE8FB;
  --color-login: #07182D;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --sidebar-width: 228px;
  --control-height: 40px;
  --ease-brand: cubic-bezier(.2, .8, .2, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--font-sans);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--color-canvas); color: var(--color-text); font-size: 14px; line-height: 1.5; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--color-brand); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; }
svg.icon { width: 18px; height: 18px; flex: none; }
.hidden, [hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted, .row-meta, small { color: var(--color-text-muted); }
.danger-link { color: var(--color-danger) !important; }

button, .button {
  min-height: var(--control-height);
  padding: 0 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
}
button:hover { border-color: var(--color-border-strong); background: var(--color-surface-hover); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.primary { border-color: var(--color-brand); background: var(--color-brand); color: var(--color-text-inverse); }
button.primary:hover { border-color: var(--color-brand-hover); background: var(--color-brand-hover); }
button.primary:active { border-color: var(--color-brand-pressed); background: var(--color-brand-pressed); }
button.secondary { background: var(--color-surface); }
button.danger { border-color: var(--color-danger); background: var(--color-danger); color: #fff; }
button.icon-only, summary.icon-only { display: inline-grid; width: 36px; min-width: 36px; height: 36px; min-height: 36px; padding: 0; place-items: center; }
.icon-label-button { display: inline-flex; align-items: center; gap: var(--space-2); }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [contenteditable]:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
input, select { height: var(--control-height); padding: 0 10px; }
textarea { min-height: 92px; padding: 10px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--color-brand); }
.field { display: grid; gap: 6px; }
.field > span { color: var(--color-text-muted); font-size: 12px; font-weight: 600; }

.brand-mark { position: relative; display: inline-block; width: 24px; height: 24px; flex: none; color: var(--color-brand); }
.brand-mark::before { content: ""; position: absolute; top: 5px; left: 8px; width: 8px; height: 1.75px; border-radius: 999px; background: currentColor; }
.brand-mark > span { position: absolute; right: 3px; bottom: 3px; left: 3px; height: 14px; border: 1.75px solid currentColor; border-top: 0; border-radius: 0 0 9px 9px; }

.login-wrap { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; background: var(--color-login); color: #fff; }
.login-canvas-host { position: fixed; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }
.login-three-canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.login-scene { position: relative; z-index: 1; min-height: 100vh; min-height: 100svh; padding: 0; border: 0; }
.login-character-wrap { position: absolute; top: 133.5px; left: 50%; display: grid; width: 320px; height: 373px; margin: 0; place-items: center; transform: translateX(-50%); }
.login-pocket-light { position: absolute; left: 50%; bottom: 50px; width: 150px; height: 62px; transform: translateX(-50%); border-radius: 50%; background: rgba(248, 243, 231, .12); filter: blur(24px); }
.login-character-stack { position: relative; z-index: 1; width: 100%; aspect-ratio: 6 / 7; }
.login-character-source { display: none; }
.login-character-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; background-position: center; background-repeat: no-repeat; background-size: contain; }
.login-character-base { opacity: 1; }
.login-character-raised { opacity: .001; }
.login-arm-raised .login-character-base { opacity: .001; }
.login-arm-raised .login-character-raised { opacity: 1; }
.login-fallback { position: absolute; z-index: 0; display: grid; gap: 14px; place-items: center; color: var(--color-role-blue-soft); }
.login-fallback .brand-mark { width: 72px; height: 72px; color: var(--color-role-blue); }
.login-fallback .brand-mark::before { top: 15px; left: 25px; width: 22px; height: 4px; }
.login-fallback .brand-mark > span { right: 10px; bottom: 9px; left: 10px; height: 42px; border-width: 4px; border-radius: 0 0 28px 28px; }
.character-loaded .login-fallback { display: none; }
.character-error .login-character-stack { display: none; }
.login-character-fallback { opacity: 1; transition: opacity 180ms ease; }
.login-canvas-ready .login-character-fallback { opacity: 0; }
.login-webgl-fallback .login-character-fallback { opacity: 1; }
.login-copy { position: absolute; top: 544px; right: 0; left: 0; height: 31px; text-align: center; }
.login-copy h1 { margin: 0; font-size: 24px; font-weight: 650; line-height: 31px; letter-spacing: 0; }
.gate-field { position: absolute; top: 606px; left: 50%; display: block; width: 168px; height: 44px; transform: translateX(-50%); }
.gate-input { height: 44px; padding: 0 8px; border: 0; border-bottom: 1px solid rgba(255, 255, 255, .24); border-radius: 0; background: transparent; box-shadow: none; color: transparent; caret-color: #fff; text-align: center; }
.gate-code-mask { position: absolute; inset: 0; display: grid; color: #fff; line-height: 44px; pointer-events: none; place-items: center; }
@supports (-webkit-text-security: disc) {
  .gate-input { color: #fff; -webkit-text-security: disc; }
  .gate-code-mask { display: none; }
}
.gate-input:focus-visible { border-bottom: 2px solid var(--color-focus-dark); box-shadow: none; outline: 0; }
.status-line { position: absolute; top: 660px; right: 0; left: 0; height: 22px; min-height: 22px; margin: 0; color: #c8d5e6; line-height: 22px; text-align: center; }
.status-line.error { color: #ff9b8d; }
.login-copy, .gate-field, .status-line { transition: opacity 180ms ease; }
.login-cold-open .login-copy, .login-cold-open .gate-field, .login-cold-open .status-line { opacity: 0; }
.login-checking .gate-input { opacity: .65; }
.login-error-static .gate-input { border-bottom: 2px solid #ff8f83; box-shadow: none; }
.login-error-static .status-line::before { content: "!"; display: inline-grid; width: 16px; height: 16px; margin-right: 6px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 11px; font-weight: 700; }
.login-handoff { background: #FBF9FD; }
.login-handoff .login-scene, .login-handoff .login-canvas-host { opacity: 0; transition: opacity 180ms ease; }

@media (min-width: 768px) and (max-height: 760px) {
  .login-character-wrap { top: 53px; width: 238px; height: 278px; }
  .login-copy { top: 362px; height: 29px; }
  .login-copy h1 { font-size: 22px; line-height: 29px; }
  .gate-field { top: 417px; }
  .status-line { top: 471px; }
}

.app-shell { display: grid; min-height: 100vh; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; height: 100vh; flex-direction: column; border-right: 1px solid var(--color-border); background: var(--color-surface); }
.workbench-menu-wrap { position: relative; padding: 22px 18px 12px; }
.workbench-menu-button { display: flex; width: 100%; height: 44px; padding: 0; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; }
.workbench-menu-button:hover { background: transparent; }
.brand-name { min-width: 0; overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; padding: 14px 18px; gap: 2px; }
.nav-button { position: relative; height: 42px; padding: 0 10px; border: 0; border-radius: 0; background: transparent; color: var(--color-text-muted); text-align: left; }
.nav-button:hover { background: var(--color-surface-hover); color: var(--color-text); }
.nav-button[aria-current="page"] { background: var(--color-surface-selected); color: var(--color-brand); font-weight: 650; }
.nav-button[aria-current="page"]::after { content: ""; position: absolute; right: 10px; bottom: 2px; left: 10px; height: 3px; clip-path: polygon(0 0, calc(100% - 1px) 0, 100% 100%, 0 100%); background: var(--color-brand-luminous); }
.sidebar-foot { margin-top: auto; padding: 16px 18px 20px; border-top: 1px solid var(--color-border); }
.global-search-shell { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); }
.global-search-shell input { min-width: 0; padding: 0; border: 0; background: transparent; }
.global-search-shell input:focus { outline: none; }
.workbench-menu, .file-more-menu, .bookmark-row-menu {
  position: absolute; z-index: 60; min-width: 168px; padding: 6px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: 0 12px 36px rgba(26, 26, 46, .1);
}
.workbench-menu { top: 64px; left: 18px; }
.workbench-menu button, .file-more-menu button, .bookmark-row-menu button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; text-align: left; }
.main { min-width: 0; padding: 40px clamp(28px, 4vw, 64px) 64px; }
.mobile-topbar, .mobile-bottom-nav, .mobile-more-sheet, .mobile-global-search-row { display: none; }

.panel, .workbench-section, .bookmark-quiet-panel, .relay-guide { min-width: 0; border: 0; background: transparent; }
.panel-head, .module-toolbar, .notes-page-head, .bookmark-quiet-head, .relay-history-head { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--color-border); }
.panel-body { padding: 16px 0; }
.panel-actions, .module-actions, .notes-top-actions, .bookmark-page-actions, .row-actions, .upload-actions, .confirm-actions { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 32px; }
.empty { display: grid; min-height: 140px; place-content: center; justify-items: center; gap: 6px; color: var(--color-text-muted); text-align: center; }
.empty svg { width: 28px; height: 28px; }
.compact-empty { min-height: 100px; }
.row { position: relative; display: grid; min-width: 0; min-height: 58px; padding: 10px 4px; align-items: center; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; border-bottom: 1px solid var(--color-border); }
.row-main, .file-name-cell { display: flex; min-width: 0; align-items: center; gap: 12px; }
.row-title { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12px; }
.eyebrow { margin-bottom: 4px; color: var(--color-brand); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; border-radius: var(--radius-md); background: #20252c; color: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); }
.toast.error { background: var(--color-danger); }

.workbench-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); gap: 0 40px; }
.workbench-section { min-height: 0; }
.summary-head { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--color-border); }
.summary-head h2 { font-size: 18px; }
.summary-list { display: grid; }
.summary-note, .summary-row { display: grid; width: 100%; min-width: 0; min-height: 72px; padding: 12px 4px; align-items: center; border: 0; border-bottom: 1px solid var(--color-border); border-radius: 0; background: transparent; text-align: left; }
.summary-note { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.summary-note:hover, .summary-row:hover { background: var(--color-surface-hover); }
.summary-note-title, .summary-file-main strong { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-note-meta { color: var(--color-text-muted); font-size: 12px; }
.summary-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.summary-file-main { display: flex; min-width: 0; overflow: hidden; align-items: center; gap: 12px; }
.summary-file-copy { min-width: 0; flex: 1; overflow: hidden; }
.summary-file-main p { margin: 2px 0 0; }
.summary-file-time { flex: none; color: var(--color-text-muted); font-size: 12px; white-space: nowrap; }
.bookmark-strip { display: flex; min-width: 0; padding: 16px 0; align-items: center; gap: 14px; grid-column: 1 / -1; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.strip-label { display: inline-flex; flex: none; padding: 0; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--color-text-muted); }
.bookmark-strip-items { display: flex; min-width: 0; align-items: center; gap: 8px; overflow: hidden; }
.bookmark-chip { max-width: 160px; padding: 5px 9px; overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-chip:hover { border-color: var(--color-brand); color: var(--color-brand); }
.relay-status-line { display: flex; width: 100%; min-width: 0; min-height: 44px; padding: 8px 0; overflow: hidden; align-items: center; gap: 10px; grid-column: 1 / -1; border: 0; border-bottom: 1px solid var(--color-border); border-radius: 0; background: transparent; text-align: left; }
.relay-status-line strong { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relay-status-line span { margin-left: auto; color: var(--color-warning); font-size: 12px; }

.files-page { max-width: 1120px; }
.module-status { font-weight: 700; }
.breadcrumb-row { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.breadcrumb { display: flex; align-items: center; gap: 4px; }
.breadcrumb button { min-height: 28px; padding: 0 4px; border: 0; background: transparent; color: var(--color-text-muted); }
.file-list { padding-top: 0; }
.file-row { cursor: pointer; grid-template-columns: minmax(0, 1fr) auto auto; }
.file-row:hover { background: var(--color-surface-hover); }
.file-icon { display: grid; width: 34px; height: 34px; flex: none; place-items: center; border-radius: var(--radius-sm); background: var(--color-surface-subtle); color: var(--color-text-muted); }
.file-name-cell, .file-title-wrap { min-width: 0; overflow: hidden; }
.file-title-wrap { width: 0; flex: 1 1 0; }
.file-title-button { display: block; width: 100%; max-width: 100%; height: auto; min-width: 0; min-height: 0; padding: 0; overflow: hidden; border: 0; background: transparent; text-align: left; }
.file-title-button .row-title { display: block; width: 100%; max-width: 100%; }
.file-meta-line { display: flex; min-width: 0; overflow: hidden; align-items: center; gap: 4px; white-space: nowrap; }
.file-meta-details { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-meta-separator, .file-time { flex: none; }
.file-more-menu { top: 48px; right: 0; }
.context-menu { position: fixed; right: auto; }
.upload-queue { display: grid; min-width: 0; max-width: 100%; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.upload-card { display: grid; width: 100%; min-width: 0; max-width: 100%; padding: 12px; align-items: start; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.upload-icon { color: var(--color-brand); }
.upload-main { min-width: 0; max-width: 100%; overflow: hidden; }
.upload-head { display: grid; min-width: 0; max-width: 100%; align-items: start; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; }
.upload-head strong { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-head > span { white-space: nowrap; }
.upload-meta { display: flex; min-width: 0; max-width: 100%; margin-top: 8px; flex-wrap: wrap; justify-content: flex-start; gap: 8px 14px; color: var(--color-text-muted); font-size: 12px; }
.upload-meta > span { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.upload-actions { min-width: 0; max-width: 100%; justify-self: start; }
.upload-error { color: var(--color-danger); }
.upload-meter, .progress { height: 5px; margin-top: 8px; overflow: hidden; border-radius: 3px; background: var(--color-surface-subtle); }
.upload-meter span, .progress span { display: block; height: 100%; background: var(--color-brand); }

.notes-page { display: grid; min-height: calc(100vh - 104px); grid-template-rows: auto minmax(0, 1fr); }
.notes-mobile-back { display: none !important; }
.notes-toolbar-left { display: flex; align-items: center; gap: 14px; }
.segmented-control { display: inline-flex; padding: 2px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-subtle); }
.segmented-control button { min-height: 30px; padding: 0 12px; border: 0; background: transparent; }
.segmented-control button[aria-selected="true"] { background: var(--color-surface); color: var(--color-brand); font-weight: 650; }
.save-state { color: var(--color-text-muted); font-size: 12px; }
.save-state.dirty { color: var(--color-warning); }
.save-state.error { color: var(--color-danger); }
.notes-shell { display: grid; min-height: 0; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); }
.note-list { min-width: 0; overflow: auto; border-right: 1px solid var(--color-border); }
.note-item { display: grid; width: 100%; min-height: 82px; padding: 12px 14px; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; border: 0; border-bottom: 1px solid var(--color-border); border-radius: 0; background: transparent; text-align: left; }
.note-item[aria-current="true"] { background: var(--color-surface-selected); box-shadow: inset 3px 0 var(--color-brand); font-weight: 650; }
.note-card-title { min-width: 0; overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.note-card-meta, .note-card-text { color: var(--color-text-muted); font-size: 12px; }
.note-card-text { overflow: hidden; grid-column: 1 / -1; text-overflow: ellipsis; white-space: nowrap; }
.notes-editor-pane { min-width: 0; padding-left: 24px; }
.note-editor, .editor-body-field, .wysiwyg-shell { height: 100%; }
.wysiwyg-shell { display: grid; min-height: 420px; grid-template-rows: auto minmax(0, 1fr); }
.wysiwyg-toolbar { display: flex; min-height: 44px; padding: 4px 0; align-items: center; gap: 4px; border-bottom: 1px solid var(--color-border); }
.wysiwyg-toolbar button { width: 34px; min-width: 34px; height: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; }
.wysiwyg-toolbar .separator { width: 1px; height: 20px; margin: 0 4px; background: var(--color-border); }
.wysiwyg-editor { min-height: 360px; padding: 24px 8px 80px; overflow: auto; font-size: 16px; line-height: 1.75; outline: 0; }
.wysiwyg-editor:empty::before { content: attr(data-placeholder); color: #9aa3ae; }
.wysiwyg-editor h1, .wysiwyg-editor h2, .wysiwyg-editor h3 { margin: 1.2em 0 .45em; }
.wysiwyg-editor blockquote { margin-left: 0; padding-left: 14px; border-left: 3px solid var(--color-brand); color: var(--color-text-muted); }
.archive-list { padding-top: 8px; }
.archive-row { grid-template-columns: minmax(0, 1fr) 140px auto; }
.archive-row-menu { position: relative; }
.archive-row-menu summary { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--color-border); border-radius: var(--radius-sm); cursor: pointer; list-style: none; }
.archive-row-menu summary::-webkit-details-marker { display: none; }
.archive-row-menu > div { position: absolute; z-index: 60; top: 40px; right: 0; min-width: 160px; padding: 6px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: 0 12px 30px rgba(17, 24, 39, .16); }
.archive-row-menu button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; text-align: left; }

.bookmarks-page { width: 100%; max-width: 920px; }
.bookmark-quiet-head { min-height: 56px; padding: 8px 0; }
.bookmark-search-shell { width: min(420px, calc(100% - 48px)); height: 40px; }
.bookmark-page-actions { flex: none; }
.bookmark-add-button { width: 40px !important; min-width: 40px !important; height: 40px !important; min-height: 40px !important; }
.bookmark-quick-list { display: grid; }
.bookmark-quick-item { position: relative; min-width: 0; min-height: 56px; border-bottom: 1px solid var(--color-border); }
.bookmark-quick-item:hover { background: var(--color-surface-hover); }
.bookmark-quick-item.menu-open { background: var(--color-surface-selected); }
.bookmark-quick-open { display: flex; width: 100%; min-width: 0; min-height: 55px; padding: 0 48px 0 4px; align-items: center; gap: 12px; border: 0; border-radius: 0; background: transparent; text-align: left; }
.bookmark-quick-open:hover { background: transparent; }
.bookmark-quick-copy { display: grid; min-width: 0; flex: 1; }
.bookmark-quick-open strong, .bookmark-quick-open small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-quick-open strong { font-size: 15px; font-weight: 650; line-height: 20px; }
.bookmark-quick-open small { font-size: 12px; line-height: 18px; }
.bookmark-favicon { position: relative; display: grid; width: 28px; height: 28px; flex: none; place-items: center; }
.bookmark-favicon-fallback { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface-subtle); color: var(--color-text-muted); font-size: 12px; font-weight: 600; line-height: 16px; }
.bookmark-favicon img { position: absolute; width: 20px; height: 20px; opacity: 0; object-fit: contain; transition: opacity 120ms var(--ease-brand); }
.bookmark-favicon[data-favicon-state="loaded"] img { opacity: 1; }
.bookmark-favicon[data-favicon-state="loaded"] .bookmark-favicon-fallback { opacity: 0; }
.bookmark-row-menu-trigger { position: absolute; z-index: 2; top: 50%; right: 4px; width: 32px !important; min-width: 32px !important; height: 32px !important; min-height: 32px !important; border: 0; background: transparent; opacity: 0; pointer-events: none; transform: translateY(-50%); transition: opacity 120ms var(--ease-brand); }
.bookmark-quick-item:hover .bookmark-row-menu-trigger, .bookmark-quick-item:focus-within .bookmark-row-menu-trigger, .bookmark-quick-item.menu-open .bookmark-row-menu-trigger { opacity: 1; pointer-events: auto; }
.bookmark-row-menu { top: 46px; right: 0; width: 168px; border-radius: var(--radius-sm); }
.bookmark-row-menu button { min-height: 40px; }
.bookmark-inline-add, .bookmark-inline-row { display: grid; min-height: 56px; padding: 8px 0; align-items: center; gap: 8px; border-bottom: 1px solid var(--color-border); }
.bookmark-inline-add { grid-template-columns: minmax(0, 1fr) auto; }
.bookmark-inline-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
.bookmark-inline-fields { display: grid; min-width: 0; grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr); gap: 8px; }
.bookmark-inline-actions { display: flex; gap: 6px; }
.bookmark-fetch-status, .bookmark-field-error { grid-column: 1 / -1; margin: 0; font-size: 12px; }
.bookmark-fetch-status { color: var(--color-text-muted); }
.bookmark-field-error { color: var(--color-danger); }
.bookmark-empty { min-height: 112px; }

.relay-guide { max-width: 1040px; }
.relay-connection { display: grid; min-height: 58px; margin-bottom: 18px; padding: 10px 0; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--color-border); }
.relay-connection > span { width: 9px; height: 9px; border-radius: 50%; background: var(--color-warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-warning) 14%, transparent); }
.relay-connection-online > span { background: var(--color-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-success) 14%, transparent); }
.relay-connection-offline > span { background: var(--color-danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-danger) 12%, transparent); }
.relay-connection div { display: grid; min-width: 0; gap: 2px; }
.relay-connection small { overflow: hidden; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.relay-pairing-once, .relay-thread-banner { display: flex; margin-bottom: 18px; padding: 12px 14px; align-items: center; gap: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-subtle); }
.relay-pairing-once span, .relay-thread-banner span { min-width: 0; flex: 1; color: var(--color-text-muted); font-size: 12px; }
.relay-primary-tabs { display: inline-flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.relay-primary-tab { border: 0; border-radius: 0; background: transparent; color: var(--color-text-muted); }
.relay-primary-tab.active { color: var(--color-brand); box-shadow: inset 0 -2px var(--color-brand); }
.relay-compose-shell { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; }
.relay-simple-form { display: grid; gap: 16px; padding-top: 0; }
.relay-simple-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.relay-context-details, .relay-history-search, .relay-record-more, .relay-detail-section { border-top: 1px solid var(--color-border); }
.relay-context-details summary, .relay-history-search summary, .relay-record-more summary, .relay-detail-section summary { padding: 10px 0; color: var(--color-text-muted); cursor: pointer; }
.relay-send-row { display: flex; align-items: center; gap: 14px; }
.relay-safety-note { color: var(--color-text-muted); font-size: 12px; }
.relay-recent-status { padding-left: 20px; border-left: 1px solid var(--color-border); }
.relay-recent-status p { color: var(--color-text-muted); }
.relay-status { display: inline-flex; width: fit-content; padding: 2px 7px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-muted); font-size: 11px; }
.relay-status-failed, .relay-status-expired { border-color: #efb3b3; color: var(--color-danger); }
.relay-status-retrying, .relay-status-offline, .relay-status-needs-authorization { border-color: #e8c98a; color: var(--color-warning); }
.relay-status-running, .relay-status-checkpoint, .relay-status-claimed { border-color: #87b9d8; color: #256c99; }
.relay-status-replied, .relay-status-collected, .relay-status-posted { border-color: #9fd2b8; color: var(--color-success); }
.relay-message-list { padding-top: 0; }
.relay-record { border-bottom: 1px solid var(--color-border); }
.relay-record-summary { display: grid; width: 100%; min-height: 78px; padding: 12px 4px; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px 16px; border: 0; border-radius: 0; background: transparent; text-align: left; }
.relay-record-main, .relay-record-meta { display: grid; min-width: 0; }
.relay-record-main strong, .relay-record-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relay-record-meta { color: var(--color-text-muted); font-size: 11px; }
.relay-record-result { display: none; }
.relay-record-detail { padding: 0 16px 18px; }
.relay-compact-kv, .kv { display: grid; gap: 0; }
.relay-compact-kv { grid-template-columns: 110px minmax(0, 1fr); }
.relay-compact-kv > *, .kv > div { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.relay-reply { white-space: pre-wrap; }
.relay-error { color: var(--color-danger); }
.relay-receipt, .relay-packet, .relay-readme, .relay-experience-flow { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.relay-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.relay-recent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.relay-checkpoint { display: grid; margin: 10px 0; padding: 10px 0; gap: 3px; border-block: 1px solid var(--color-border); }
.relay-checkpoint span { color: var(--color-text-muted); font-size: 12px; }
.relay-result-grid { display: grid; margin-top: 12px; gap: 0; }
.relay-result-grid > div { display: grid; padding: 10px 0; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--color-border); }
.relay-result-grid span { overflow-wrap: anywhere; }
.relay-continue-button { margin-top: 14px; }
.relay-experience-inline { display: grid; gap: 12px; }

.settings-grid { max-width: 980px; grid-template-columns: 1fr 1fr; }
.settings-grid .panel { border-top: 1px solid var(--color-border); }
.settings-actions { display: grid; }
.setting-row { display: flex; width: 100%; min-height: 52px; padding: 8px 4px; align-items: center; justify-content: space-between; border: 0; border-bottom: 1px solid var(--color-border); border-radius: 0; background: transparent; text-align: left; }
.setting-row > span { display: flex; align-items: center; gap: 10px; }
.setting-row small { white-space: nowrap; }
.kv > div { display: flex; justify-content: space-between; gap: 20px; }
.kv dt { color: var(--color-text-muted); }
.kv dd { margin: 0; text-align: right; }
.modal-backdrop { position: fixed; z-index: 90; inset: 0; display: grid; padding: 20px; place-items: center; background: rgba(6, 11, 18, .5); }
.confirm-dialog { display: grid; width: min(440px, 100%); padding: 24px; gap: 22px; border-radius: var(--radius-md); background: var(--color-surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .28); }
.confirm-dialog h2 { margin-bottom: 8px; }
.confirm-actions { justify-content: flex-end; }
.dialog-field { margin-top: 16px; }

@media (max-width: 1100px) {
  .workbench-grid { gap: 0 24px; }
  .main { padding-right: 28px; padding-left: 28px; }
  .relay-compose-shell { grid-template-columns: minmax(0, 1fr) 240px; }
}

@media (max-width: 900px) {
  .app-shell { --control-height: 44px; display: block; }
  body { background: var(--color-surface); }
  html { scroll-padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { padding: 52px 16px calc(96px + env(safe-area-inset-bottom)); }
  .mobile-topbar { position: fixed; z-index: 40; top: 0; right: 0; left: 0; display: grid; height: 52px; padding: 0 10px 0 14px; align-items: center; grid-template-columns: 36px minmax(0, 1fr) 44px; gap: 8px; border-bottom: 1px solid var(--color-border); background: rgba(255, 255, 255, .98); }
  .mobile-topbar .brand-mark { width: 24px; height: 24px; }
  .mobile-topbar strong { overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar .icon-only { width: 44px; height: 44px; border: 0; }
  .mobile-global-search-row { position: sticky; z-index: 25; top: 8px; display: flex; height: 44px; margin: 8px 0 14px; }
  .mobile-bottom-nav { position: fixed; z-index: 50; right: 0; bottom: 0; left: 0; display: grid; height: calc(60px + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom); grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--color-border); background: rgba(255, 255, 255, .98); }
  .mobile-bottom-nav button { position: relative; display: grid; min-width: 0; height: 52px; padding: 4px 0; place-items: center; align-content: center; gap: 1px; border: 0; background: transparent; color: var(--color-text-muted); font-size: 10px; }
  .mobile-bottom-nav button[aria-current="page"] { background: var(--color-surface-selected); color: var(--color-brand); font-weight: 650; }
  .mobile-bottom-nav button[aria-current="page"]::after { content: ""; position: absolute; right: 12px; bottom: 1px; left: 12px; height: 3px; clip-path: polygon(0 0, calc(100% - 1px) 0, 100% 100%, 0 100%); background: var(--color-brand-luminous); }
  .mobile-bottom-nav svg { width: 20px; height: 20px; }
  .mobile-more-sheet { position: fixed; z-index: 49; right: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); display: grid; width: min(240px, calc(100vw - 20px)); padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: 0 16px 40px rgba(26, 26, 46, .12); }
  .mobile-more-sheet button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; text-align: left; }
  button.icon-only { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .workbench-grid { display: block; }
  .workbench-section { min-height: 0; padding-bottom: 18px; }
  .workbench-secondary { border-top: 1px solid var(--color-border); }
  .summary-head { min-height: 56px; }
  .summary-note, .summary-row { min-height: 64px; }
  .summary-row { align-items: start; grid-template-columns: minmax(0, 1fr) auto; }
  .summary-file-time { align-self: end; padding-bottom: 12px; }
  .bookmark-strip { align-items: flex-start; }
  .bookmark-strip-items { flex-wrap: wrap; overflow: visible; }
  .bookmark-chip:nth-child(n+4) { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .file-row { grid-template-columns: minmax(0, 1fr) auto; }
  .file-meta-line { grid-column: 1; padding-left: 46px; }
  .file-row .row-actions { grid-row: 1 / span 2; grid-column: 2; }
  .upload-card { grid-template-columns: 28px minmax(0, 1fr); }
  .upload-actions { grid-column: 2; }
  .notes-page { min-height: calc(100vh - 148px); }
  .notes-page-head { position: sticky; z-index: 20; top: 52px; padding: 8px 0; background: var(--color-surface); }
  .notes-shell { display: block; }
  .notes-page[data-mobile-view="list"] .notes-editor-pane { display: none; }
  .notes-page[data-mobile-view="editor"] .note-list { display: none; }
  .notes-page[data-mobile-view="editor"] .segmented-control,
  .notes-page[data-mobile-view="editor"] .notes-new-button { display: none; }
  .notes-page[data-mobile-view="editor"] .notes-mobile-back { display: inline-grid !important; }
  .notes-page[data-mobile-view="list"] .save-state,
  .notes-page[data-mobile-view="list"] .notes-save-button,
  .notes-page[data-mobile-view="list"] .notes-archive-button,
  .notes-page[data-mobile-view="list"] .notes-delete-button { display: none !important; }
  .note-list { max-height: none; min-height: calc(100vh - 174px); border-right: 0; border-bottom: 0; }
  .note-item { min-height: 70px; padding: 10px 8px; }
  .notes-editor-pane { padding-left: 0; }
  .wysiwyg-shell { min-height: 430px; }
  .wysiwyg-toolbar { position: sticky; z-index: 10; top: 104px; overflow-x: auto; background: var(--color-surface); }
  .wysiwyg-editor { min-height: 360px; padding: 20px 4px 80px; }
  .archive-row { grid-template-columns: minmax(0, 1fr) auto; }
  .archive-list .row > .row-meta { display: none; }
  .bookmark-quiet-head { min-height: 52px; padding: 4px 0; align-items: center; gap: 8px; }
  .bookmark-search-shell { width: auto; min-width: 0; height: 44px; flex: 1; }
  .bookmark-add-button { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; }
  .bookmark-quick-item { min-height: 64px; }
  .bookmark-quick-open { min-height: 63px; padding-right: 48px; padding-left: 0; }
  .bookmark-row-menu-trigger { right: 0; width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; }
  .bookmark-row-menu { top: 58px; width: 200px; max-width: calc(100vw - 32px); border-radius: var(--radius-sm); }
  .bookmark-row-menu button { min-height: 44px; }
  .bookmark-inline-add { min-height: 112px; grid-template-columns: 1fr; }
  .bookmark-inline-add > input, .bookmark-inline-add > .bookmark-inline-actions, .bookmark-inline-add > p { grid-column: 1; }
  .bookmark-inline-add .bookmark-inline-actions { justify-content: flex-end; }
  .bookmark-inline-row { min-height: 176px; align-items: start; grid-template-columns: 28px minmax(0, 1fr); }
  .bookmark-inline-row > .bookmark-favicon { margin-top: 8px; }
  .bookmark-inline-fields { grid-template-columns: 1fr; }
  .bookmark-inline-row .bookmark-inline-actions { grid-column: 2; justify-content: flex-end; }
  .relay-compose-shell { display: block; }
  .relay-recent-status { margin-top: 24px; padding: 18px 0 0; border-top: 1px solid var(--color-border); border-left: 0; }
  .relay-simple-fields { grid-template-columns: 1fr; }
  .relay-send-row, .relay-continue-button { scroll-margin-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .relay-send-row { padding-bottom: 4px; align-items: stretch; flex-direction: column; }
  .relay-pairing-once, .relay-thread-banner { align-items: flex-start; flex-direction: column; }
  .relay-pairing-once button, .relay-thread-banner button { width: 100%; }
  .relay-result-grid > div { grid-template-columns: 1fr; gap: 4px; }
  .relay-record-summary { grid-template-columns: minmax(0, 1fr) auto; }
  .relay-record-meta { grid-column: 1; }
  .settings-grid { grid-template-columns: 1fr; gap: 24px; }
  .toast { top: calc(6px + env(safe-area-inset-top)); right: 64px; bottom: auto; left: 64px; padding: 8px 12px; overflow: hidden; line-height: 24px; text-align: center; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
}

@media (max-width: 520px) {
  .login-character-wrap { top: 124.5px; width: 220px; height: 257px; }
  .login-copy { top: 414px; height: 28px; }
  .login-copy h1 { font-size: 21px; line-height: 28px; }
  .gate-field { top: 470px; width: 168px; }
  .status-line { top: 524px; }
  .main { padding-right: 14px; padding-left: 14px; }
  .bookmarks-page { width: calc(100% - 4px); margin-right: 2px; margin-left: 2px; }
  .notes-page-head { gap: 8px; }
  .notes-toolbar-left { gap: 8px; }
  .segmented-control button { padding: 0 9px; }
  .notes-top-actions { gap: 4px; }
  .notes-save-button { padding: 0 10px; }
  .archive-list .row-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .bookmark-favicon img, .bookmark-row-menu-trigger { transition: none !important; }
  .login-copy { transform: none !important; }
  .login-character-base { opacity: 1 !important; }
  .login-character-raised { opacity: 0 !important; }
}

@media (max-height: 639px) {
  .login-wrap, .login-scene { min-height: 520px; overflow-y: auto; }
}
