:root {
  color-scheme: light dark;
  --bg: #fbf7ef;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --text: #18202a;
  --muted: #5b6675;
  --accent: #0f5bd8;
  --accent-soft: rgba(15, 91, 216, 0.1);
  --border: rgba(24, 32, 42, 0.12);
  --shadow: 0 16px 48px rgba(24, 32, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: "Charter", "Iowan Old Style", "Palatino Linotype", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.14 0.012 55);
    --panel: oklch(0.18 0.014 55 / 0.85);
    --panel-strong: oklch(0.21 0.015 55);
    --text: oklch(0.93 0.006 55);
    --muted: oklch(0.66 0.018 55);
    --accent: oklch(0.705 0.165 55);
    --accent-soft: oklch(0.705 0.165 55 / 0.14);
    --border: oklch(0.27 0.018 55);
    --shadow: 0 16px 48px oklch(0.08 0.02 55 / 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  transition: color-scheme 0.4s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.28), transparent 34%),
    radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.22), transparent 30%),
    linear-gradient(180deg, #eef6ff 0%, #dbeafe 100%);
  transition:
    color 0.35s ease,
    background 0.55s ease;
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(circle at top left, oklch(0.24 0.04 55 / 0.45), transparent 36%),
      radial-gradient(circle at bottom right, oklch(0.20 0.035 50 / 0.35), transparent 32%),
      linear-gradient(180deg, oklch(0.12 0.012 55) 0%, oklch(0.14 0.012 55) 100%);
  }
}

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

code {
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(238, 246, 255, 0.92);
  backdrop-filter: blur(12px);
}

.site-header__inner,
.site-main {
  width: 100%;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 1rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}

.site-brand img {
  display: block;
  width: auto;
  height: 2.5rem;
  max-width: min(12rem, 42vw);
  object-fit: contain;
}

.site-nav {
  display: flex;
  gap: 0.5rem;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s;
}

.site-nav a:hover {
  background: rgba(0, 0, 0, 0.06);
}

.site-nav a svg {
  display: block;
}

.site-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 320px;
  margin: 0 1rem;
}

.site-search__icon {
  position: absolute;
  left: 0.6rem;
  z-index: 1;
  color: var(--muted);
  pointer-events: none;
}

.site-search input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  font: inherit;
  font-size: 0.825rem;
  transition: border-color 0.15s, background 0.15s;
}

.site-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-strong);
}

.site-main {
  padding: 0;
  height: calc(100vh - 64px);
}

.auth-shell,
.account-shell {
  min-height: 100%;
  overflow: auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.auth-shell {
  display: grid;
  align-items: start;
  justify-items: center;
}

.auth-panel,
.account-section {
  width: min(100%, 920px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: clamp(1rem, 3vw, 2rem);
}

.auth-panel__header,
.account-header {
  margin-bottom: 1.25rem;
}

.auth-panel h1,
.account-header h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font: 700 0.72rem/1.2 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-grid,
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.auth-form h2,
.account-section h2 {
  margin: 0;
  font-size: 1.05rem;
}

.auth-form label,
.scope-grid {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-form .auth-choice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.auth-choice input {
  width: auto;
}

.auth-form input,
.auth-form select,
.user-row select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
}

.auth-form button,
.account-header button,
.token-list button,
.user-row button {
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn-primary,
.auth-form button[type="submit"],
.account-header button {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--accent);
  color: white;
  padding: 0.85rem 1.75rem;
  min-height: 3rem;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover,
.auth-form button[type="submit"]:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn-primary:active,
.auth-form button[type="submit"]:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent);
}

.auth-details {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.auth-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.form-status {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.form-status[data-state="error"] {
  color: #b42318;
}

.form-status[data-state="ok"] {
  color: #067647;
}

.auth-note {
  margin: 1rem 0 0;
  color: var(--muted);
}

/* Auth tabs */
.auth-tabs {
  margin-bottom: 1.5rem;
}

.auth-tab-list {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.auth-tab {
  padding: 0.5rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.auth-tab-panel {
  display: none;
}

.auth-tab-panel.is-active {
  display: block;
}

/* Register CTA */
.auth-register-cta {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 2rem;
  min-height: 3.5rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-cta:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
}

.btn-cta:active {
  transform: translateY(2px);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}

.auth-register-panel {
  padding: 0;
  border: none;
  background: transparent;
}

.auth-register-cancel {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  min-height: 2.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--panel);
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 1120px);
}

.account-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.account-grid {
  width: min(100%, 1120px);
}

.account-section {
  padding: 1rem;
}

.account-section--danger {
  border-color: color-mix(in srgb, #b42318 40%, var(--border));
}

.scope-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.scope-grid legend {
  padding: 0 0.25rem;
  color: var(--text);
}

.scope-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.token-output {
  max-width: 100%;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.token-list,
.user-list {
  display: grid;
  gap: 0.6rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.token-list li,
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: var(--panel-strong);
}

.user-row {
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 10rem) auto;
}

.user-row span {
  display: grid;
  gap: 0.15rem;
}

.user-row small {
  color: var(--muted);
}

/* Workspace layout - adaptive grid */
.workspace-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr);
  gap: 0;
  align-items: stretch;
  height: 100%;
  max-width: 100%;
}

/* Document view: sidebar gets reasonable fixed proportion */
.workspace-shell--document {
  grid-template-columns: minmax(260px, 0.38fr) minmax(0, 1fr);
}

/* Empty state: more balanced 50/50 feel */
.workspace-shell--empty {
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
}

/* Miller browser - flex layout so all columns are visible as vertical slices */
.miller-browser {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  min-height: 100%;
  max-height: 100%;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 0;
  background: var(--panel);
}

.miller-browser + .document-shell {
  border-left: 1px solid var(--border);
}

.miller-column {
  flex: 0 0 auto;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 180ms ease, min-width 180ms ease, box-shadow 180ms ease;
}

/* Root column - fixed width for top-level navigation */
.miller-column:first-child {
  width: 160px;
  border-left: 0;
}

/* Middle columns - narrow slices (48px shows ~32px of content) */
.miller-column:not(:first-child):not(:last-child) {
  width: 48px;
}

.miller-column:not(:first-child):not(:last-child):hover,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded {
  width: var(--expanded-column-width, max-content);
  min-width: 12rem;
  max-width: 24rem;
  box-shadow: 8px 0 24px rgba(24, 32, 42, 0.08);
}

.miller-column:not(:first-child):not(:last-child):hover {
  transition-delay: 1s;
}

/* Active/last column - grows to fill remaining sidebar space */
.miller-column:last-child {
  flex: 1 1 auto;
  min-width: 200px;
}

.miller-column h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font: 700 0.72rem/1.2 ui-monospace, SFMono-Regular, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Middle column headers - show just first couple chars */
.miller-column:not(:first-child):not(:last-child) h2 {
  padding: 0.7rem 0.3rem;
  text-align: center;
}

.miller-column:not(:first-child):not(:last-child) h2 .miller-column-title-text {
  display: inline-block;
  max-width: 2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.miller-column:not(:first-child):not(:last-child):hover h2,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded h2 {
  padding: 0.7rem 0.8rem;
  text-align: left;
}

.miller-column:not(:first-child):not(:last-child):hover h2 .miller-column-title-text,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded h2 .miller-column-title-text {
  max-width: min(20rem, calc(var(--expanded-column-width, 14rem) - 2rem));
}

.miller-column ul {
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.miller-column a {
  display: flex;
  min-height: 2.1rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.94rem;
}

/* Middle column items - icon + truncated text */
.miller-column:not(:first-child):not(:last-child) a {
  padding: 0.4rem 0.2rem;
  justify-content: center;
}

.miller-column:not(:first-child):not(:last-child) .browser-item-label {
  justify-content: center;
  gap: 0.15rem;
}

.miller-column:not(:first-child):not(:last-child) .browser-item-name {
  display: inline-block;
  max-width: 1.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.miller-column:not(:first-child):not(:last-child) .browser-item-chevron {
  display: none;
}

.miller-column:not(:first-child):not(:last-child):hover a,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded a {
  padding: 0.4rem 0.5rem;
  justify-content: space-between;
}

.miller-column:not(:first-child):not(:last-child):hover .browser-item-label,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded .browser-item-label {
  justify-content: flex-start;
  gap: 0.4rem;
}

.miller-column:not(:first-child):not(:last-child):hover .browser-item-name,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded .browser-item-name {
  max-width: min(18rem, calc(var(--expanded-column-width, 14rem) - 3.5rem));
}

.miller-column:not(:first-child):not(:last-child):hover .browser-item-chevron,
.miller-column:not(:first-child):not(:last-child).is-preview-expanded .browser-item-chevron {
  display: inline-block;
}

.browser-item-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.4rem;
}

.browser-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.browser-icon--folder {
  color: #0f5bd8;
}

.browser-icon--page {
  color: #465365;
}

.browser-icon--root {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--accent);
}

.miller-column--root h2 {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.miller-column a:hover,
.miller-column a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.browser-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-item-chevron {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

/* Document shell */
.document-shell,
.error-panel,
.empty-preview {
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0;
  background: var(--panel);
}

.error-panel,
.empty-preview {
  padding: 2rem;
}

.document-shell {
  padding: 1.5rem 2rem;
  min-height: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent);
  font: 700 0.78rem/1.2 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede {
  max-width: 44rem;
  color: var(--muted);
  line-height: 1.7;
}

.tag-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-list a {
  display: inline-flex;
  padding: 0.15rem 0.4rem;
  border-radius: 0;
  background: var(--accent-soft);
  text-decoration: none;
}

.breadcrumbs {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  color: var(--muted);
  margin-left: 0.25rem;
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs span[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.document-meta {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.document-meta h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.1;
}

.document-meta-panel {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
}

.document-meta-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font: 700 0.78rem/1.2 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-meta-panel summary::-webkit-details-marker {
  display: none;
}

.document-meta-panel summary::after {
  content: "+";
  margin-left: auto;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 0;
}

.document-meta-panel[open] summary::after {
  content: "-";
}

.document-meta-panel .meta-grid {
  padding: 0 0.85rem 0.85rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.meta-grid div {
  min-width: 0;
}

.meta-grid dt {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, monospace;
  text-transform: uppercase;
}

.meta-grid dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.markdown-body {
  line-height: 1.75;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0;
  background: #18202a;
  color: #f7f9fc;
}

.markdown-body blockquote {
  margin-left: 0;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0;
  background: rgba(15, 91, 216, 0.05);
}

.markdown-body img {
  display: block;
  max-width: min(85%, 100%);
  height: auto;
}

.version-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-strong);
}

.offline-notice {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 0;
  background: rgba(254, 252, 232, 0.95);
  color: #854d0e;
  font-size: 0.9rem;
}

.offline-notice[hidden] {
  display: none;
}

.cached-notice {
  position: fixed;
  left: 1rem;
  bottom: 4.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 0;
  background: rgba(239, 246, 255, 0.96);
  color: #1d4ed8;
  font-size: 0.9rem;
}

.cached-notice[hidden] {
  display: none;
}

.sync-queue {
  position: fixed;
  left: 1rem;
  bottom: 7.9rem;
  z-index: 30;
  display: grid;
  gap: 0.65rem;
  width: min(28rem, calc(100vw - 2rem));
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(146, 64, 14, 0.24);
  background: rgba(255, 251, 235, 0.97);
  color: #78350f;
  box-shadow: 0 18px 48px rgba(24, 32, 42, 0.12);
  font-size: 0.9rem;
}

.sync-queue[hidden] {
  display: none;
}

.sync-queue__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.sync-queue__header strong,
.sync-queue__header p {
  margin: 0;
}

.sync-queue__header p {
  color: #92400e;
  font-size: 0.84rem;
}

.sync-queue button {
  min-height: 2rem;
  flex: 0 0 auto;
  padding: 0 0.65rem;
  border: 1px solid rgba(146, 64, 14, 0.25);
  background: #fff;
  color: #78350f;
  cursor: pointer;
  font: 700 0.82rem/1 ui-monospace, SFMono-Regular, monospace;
}

.sync-queue button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.sync-queue ul {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sync-queue li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  color: #78350f;
}

.sync-queue li span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.sync-queue li span:last-child {
  flex: 0 0 auto;
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sync-queue li[data-state="conflict"] span:last-child {
  color: #b91c1c;
}

.offline-icon {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 0;
  background: #eab308;
  flex-shrink: 0;
}

.cached-icon {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 0;
  background: #2563eb;
  flex-shrink: 0;
}

.version-notice[hidden] {
  display: none;
}

.version-notice p {
  margin: 0;
  color: var(--text);
}

.version-notice button {
  min-height: 2.2rem;
  padding: 0 0.8rem;
  border: 0;
  border-radius: 0;
  color: white;
  background: var(--accent);
  font: 700 0.9rem/1 ui-monospace, SFMono-Regular, monospace;
  cursor: pointer;
}

.document-meta__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.document-meta__header--editor {
  align-items: end;
}

.document-edit-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  background: var(--panel);
}

.document-shell--editor {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
}

.editor-form {
  min-height: 0;
  position: relative;
}

.editor-form[hidden] {
  display: none;
}

[data-monaco-mount] {
  display: none;
  width: 100%;
  min-height: 60vh;
  height: 100%;
  border: 1px solid var(--border);
  overflow: hidden;
}

[data-monaco-mount].monaco-mounted {
  display: block;
}

.editor-form textarea {
  width: 100%;
  min-height: 60vh;
  height: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  background: #fbfbf9;
  color: var(--text);
  padding: 1rem;
  font: 400 0.98rem/1.6 ui-monospace, SFMono-Regular, monospace;
}

[data-monaco-mount].monaco-mounted ~ textarea {
  display: none;
}

@keyframes monaco-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

[data-monaco-mount]:not(.monaco-mounted) {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--panel-strong) 25%, var(--panel) 50%, var(--panel-strong) 75%);
  background-size: 200% 100%;
  animation: monaco-shimmer 1.5s ease infinite;
  color: var(--muted);
  font-size: 0.85rem;
}

.editor-status {
  display: inline-block;
  min-width: 5.5rem;
  font-weight: 600;
  text-align: right;
}

.editor-status[data-state="queued"] {
  color: #92400e;
}

.editor-status[data-state="conflict"] {
  color: #b91c1c;
}

.editor-status[data-state="saving"],
.editor-status[data-state="unsaved"] {
  color: #1d4ed8;
}

.editor-conflict {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #7f1d1d;
}

.editor-conflict[hidden] {
  display: none;
}

.editor-conflict__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.editor-conflict__header > div:first-child {
  display: grid;
  gap: 0.2rem;
}

.editor-conflict__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.editor-conflict__actions button {
  min-height: 2.1rem;
  padding: 0 0.75rem;
  border: 1px solid #fecaca;
  background: #fff;
  color: #7f1d1d;
  cursor: pointer;
}

.editor-conflict__actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.editor-conflict__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.editor-conflict__choices button {
  min-height: 2rem;
  padding: 0 0.65rem;
  border: 1px solid rgba(127, 29, 29, 0.2);
  background: rgba(255, 255, 255, 0.72);
  color: #7f1d1d;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.editor-conflict__choices button[data-conflict-use="server"] {
  border-color: rgba(185, 28, 28, 0.25);
  background: rgba(254, 202, 202, 0.6);
}

.editor-conflict__choices button[data-conflict-use="local"] {
  border-color: rgba(22, 101, 52, 0.25);
  background: rgba(187, 247, 208, 0.55);
  color: #14532d;
}

.editor-conflict p {
  margin: 0;
}

.editor-conflict__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.86rem;
}

.editor-conflict__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.editor-conflict__swatch {
  width: 0.75rem;
  height: 0.75rem;
  border: 1px solid currentColor;
  display: inline-block;
}

.editor-conflict__swatch--server {
  background: rgba(200, 85, 61, 0.2);
  color: #b91c1c;
}

.editor-conflict__swatch--local {
  background: rgba(63, 143, 89, 0.2);
  color: #166534;
}

.editor-conflict__diff {
  min-height: 16rem;
  overflow: auto;
  border: 1px solid rgba(127, 29, 29, 0.18);
  background: #fff;
}

.editor-conflict code {
  word-break: break-all;
}

.editor-conflict__resolution {
  display: grid;
  gap: 0.4rem;
}

.editor-conflict__resolution label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-conflict__resolution textarea {
  width: 100%;
  min-height: 16rem;
  resize: vertical;
  border: 1px solid rgba(127, 29, 29, 0.18);
  background: #fff;
  color: #1c2430;
  font-family: "Iosevka", "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.75rem;
}

[data-conflict-monaco-mount] {
  display: none;
  width: 100%;
  min-height: 18rem;
  height: 32rem;
  border: 1px solid rgba(127, 29, 29, 0.18);
  background: #fff;
  overflow: hidden;
}

[data-conflict-monaco-mount].monaco-mounted {
  display: block;
}

[data-conflict-monaco-mount].monaco-mounted + textarea {
  display: none;
}

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

/* Adaptive breakpoints */
@media (max-width: 1024px) {
  .workspace-shell,
  .workspace-shell--document,
  .workspace-shell--empty {
    grid-template-columns: minmax(240px, 0.45fr) minmax(0, 1fr);
    gap: 0;
  }

  .document-shell {
    padding: 1.25rem 1.5rem;
  }
}

@media (max-width: 768px) {
  .site-brand img {
    height: 2.25rem;
  }

  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    min-height: auto;
  }

  .site-main {
    height: auto;
    min-height: calc(100vh - 64px);
  }

  .workspace-shell,
  .workspace-shell--document,
  .workspace-shell--empty {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .miller-browser {
    min-height: 16rem;
    max-height: 50vh;
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }

  .miller-column,
  .miller-column:first-child,
  .miller-column:last-child,
  .miller-column:not(:first-child):not(:last-child) {
    flex: 0 0 auto;
    width: auto;
    min-width: 9rem;
    max-width: none;
  }

  .miller-column:not(:first-child):not(:last-child) h2 {
    padding: 0.7rem 0.8rem;
    text-align: left;
  }

  .miller-column:not(:first-child):not(:last-child) h2 .miller-column-title-text {
    max-width: none;
  }

  .miller-column:not(:first-child):not(:last-child) a {
    padding: 0.4rem 0.5rem;
    justify-content: space-between;
  }

  .miller-column:not(:first-child):not(:last-child) .browser-item-label {
    justify-content: flex-start;
    gap: 0.4rem;
  }

  .miller-column:not(:first-child):not(:last-child) .browser-item-name {
    max-width: none;
  }

  .miller-column:not(:first-child):not(:last-child) .browser-item-chevron {
    display: inline;
  }

  .document-shell {
    padding: 1.25rem;
    min-height: auto;
    max-height: none;
    border-left: 1px solid var(--border);
    border-top: 0;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .document-meta-panel summary,
  .document-meta__header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (min-width: 1600px) {
  .workspace-shell--document {
    grid-template-columns: minmax(300px, 0.32fr) minmax(0, 1fr);
  }
}

/* Search results */
.search-panel {
  max-width: 800px;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
}

.search-results {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.search-results li {
  border-bottom: 1px solid var(--border);
}

.search-results li:last-child {
  border-bottom: 0;
}

.search-results a {
  display: block;
  padding: 1rem 0;
  color: var(--text);
  text-decoration: none;
}

.search-results a:hover {
  color: var(--accent);
}

.search-result-title {
  display: block;
  font-weight: 600;
  font-size: 1.1rem;
}

.search-result-path {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

@media (prefers-color-scheme: dark) {
  .site-header {
    border-bottom-color: oklch(0.28 0.018 55 / 0.5);
    background: oklch(0.16 0.014 55 / 0.92);
  }

  .miller-column h2 {
    background: oklch(0.20 0.015 55 / 0.72);
  }

  .miller-column a:hover,
  .miller-column a.is-active {
    background: var(--accent-soft);
  }

  .browser-icon--folder {
    color: oklch(0.705 0.165 55);
  }

  .browser-icon--page {
    color: oklch(0.66 0.018 55);
  }

  .markdown-body pre {
    background: oklch(0.12 0.015 55);
    color: oklch(0.93 0.006 55);
  }

  .markdown-body blockquote {
    border-left-color: var(--accent);
    background: oklch(0.705 0.165 55 / 0.07);
  }

  .document-meta-panel {
    background: oklch(0.20 0.015 55 / 0.5);
  }

  .editor-form textarea {
    background: oklch(0.15 0.012 55);
    color: var(--text);
    border-color: var(--border);
  }

  .editor-conflict {
    border-color: oklch(0.55 0.18 25 / 0.4);
    background: oklch(0.22 0.04 25);
    color: oklch(0.75 0.12 25);
  }

  .editor-conflict__actions button {
    border-color: oklch(0.55 0.18 25 / 0.4);
    background: oklch(0.18 0.018 55);
    color: oklch(0.75 0.12 25);
  }

  .editor-conflict__choices button {
    border-color: oklch(0.55 0.18 25 / 0.35);
    background: oklch(0.18 0.018 55);
    color: oklch(0.75 0.12 25);
  }

  .editor-conflict__choices button[data-conflict-use="server"] {
    border-color: oklch(0.65 0.18 25 / 0.45);
    background: oklch(0.28 0.08 25 / 0.8);
    color: oklch(0.78 0.13 25);
  }

  .editor-conflict__choices button[data-conflict-use="local"] {
    border-color: oklch(0.65 0.15 145 / 0.45);
    background: oklch(0.25 0.07 145 / 0.8);
    color: oklch(0.78 0.12 145);
  }

  .editor-conflict__swatch--server {
    background: oklch(0.35 0.12 25 / 0.65);
    color: oklch(0.72 0.14 25);
  }

  .editor-conflict__swatch--local {
    background: oklch(0.33 0.10 145 / 0.65);
    color: oklch(0.72 0.13 145);
  }

  .editor-conflict__diff {
    border-color: oklch(0.55 0.18 25 / 0.3);
    background: oklch(0.14 0.012 55);
  }

  .editor-conflict__resolution textarea {
    border-color: oklch(0.55 0.18 25 / 0.3);
    background: oklch(0.14 0.012 55);
    color: var(--text);
  }

  [data-conflict-monaco-mount] {
    border-color: oklch(0.55 0.18 25 / 0.3);
    background: oklch(0.14 0.012 55);
  }

  .offline-notice {
    border-color: oklch(0.75 0.15 85 / 0.4);
    background: oklch(0.22 0.03 85 / 0.95);
    color: oklch(0.75 0.12 85);
  }

  .offline-icon {
    background: oklch(0.78 0.165 85);
  }

  .cached-notice {
    border-color: oklch(0.55 0.15 250 / 0.3);
    background: oklch(0.20 0.035 250 / 0.96);
    color: oklch(0.65 0.12 250);
  }

  .cached-icon {
    background: oklch(0.60 0.15 250);
  }

  .sync-queue {
    border-color: oklch(0.65 0.12 75 / 0.32);
    background: oklch(0.21 0.035 75 / 0.96);
    color: oklch(0.75 0.12 75);
    box-shadow: 0 18px 48px oklch(0.08 0.02 55 / 0.32);
  }

  .sync-queue__header p,
  .sync-queue li,
  .sync-queue li span:last-child {
    color: oklch(0.72 0.11 75);
  }

  .sync-queue button {
    border-color: oklch(0.65 0.12 75 / 0.28);
    background: oklch(0.17 0.018 55);
    color: oklch(0.75 0.12 75);
  }

  .sync-queue li[data-state="conflict"] span:last-child {
    color: oklch(0.68 0.16 25);
  }

  .version-notice button {
    background: var(--accent);
  }

  .miller-column:not(:first-child):not(:last-child):hover,
  .miller-column:not(:first-child):not(:last-child).is-preview-expanded {
    box-shadow: 8px 0 24px oklch(0.08 0.02 55 / 0.3);
  }

  .editor-status[data-state="queued"] {
    color: oklch(0.65 0.12 75);
  }

  .editor-status[data-state="conflict"] {
    color: oklch(0.60 0.18 25);
  }

  .editor-status[data-state="saving"],
  .editor-status[data-state="unsaved"] {
    color: oklch(0.65 0.12 250);
  }

  .markdown-body blockquote {
    background: oklch(0.705 0.165 55 / 0.07);
  }
}

/* Comments */
.commentable {
  position: relative;
}

.commentable:hover {
  background: var(--accent-soft);
}

.comment-anchor-btn {
  position: absolute;
  right: -1.5rem;
  top: 0.25rem;
  width: 1.2rem;
  height: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.commentable:hover .comment-anchor-btn {
  opacity: 1;
}

.comment-list {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.comment-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
  border-bottom: 0;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.comment-meta strong {
  color: var(--text);
}

.comment-body {
  font-size: 0.9rem;
  line-height: 1.5;
}

