:root {
  color-scheme: light;
  --page: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #eef2f0;
  --text: #18201d;
  --muted: #66716c;
  --line: #dce3df;
  --accent: #16665e;
  --accent-hover: #0f554e;
  --accent-foreground: #ffffff;
  --accent-soft: #e3f0ed;
  --danger: #a63d32;
  --focus: rgba(22, 102, 94, 0.2);
  --shadow: 0 14px 36px rgba(21, 37, 31, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-dark {
  color-scheme: dark;
  --page: #111614;
  --surface: #19201d;
  --surface-muted: #222b27;
  --text: #eef4f1;
  --muted: #a1aea8;
  --line: #34403b;
  --accent: #62b9aa;
  --accent-hover: #7bc9bb;
  --accent-foreground: #102b25;
  --accent-soft: #243d38;
  --danger: #f18c80;
  --focus: rgba(98, 185, 170, 0.24);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.library-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.library-sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 18px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.library-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  font-weight: 700;
  text-decoration: none;
}

.library-brand img { border-radius: 8px; }
.command-button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

.command-button.primary-command {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-foreground);
}
@media (hover: hover) and (pointer: fine) {
  .command-button.primary-command:hover { background: var(--accent-hover); }
}

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

.command-button:focus-visible,
.scope-button:focus-visible,
.icon-command:focus-visible,
.account-button:focus-visible,
input:focus-visible,
select:focus-visible,
.folder-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.project-commands { display: grid; gap: 7px; margin: 19px 0 14px; }
.project-commands .command-button { width: 100%; }
.project-commands .import-command { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .project-commands .import-command:hover { background: var(--accent-soft); }
}

.project-commands .command-button svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 auto; }
.scope-nav { display: grid; gap: 2px; }
.scope-button {
  color: var(--text);
  text-decoration: none;
  min-height: 34px;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .scope-button:hover { background: var(--surface-muted); }
}

.scope-button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.folder-section { min-height: 0; margin-top: 22px; overflow: auto; }
.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 7px; }
.sidebar-section-heading h2 { margin: 0; color: var(--muted); font-size: 0.73rem; font-weight: 700; text-transform: uppercase; }
.icon-command {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .icon-command:hover { background: var(--surface-muted); }
}

.folder-tree { display: grid; gap: 2px; }
.folder-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 28px; align-items: center; border-radius: 6px; }
@media (hover: hover) and (pointer: fine) {
  .folder-row:hover { background: var(--surface-muted); }
}

.folder-button {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  overflow: hidden;
  color: var(--muted);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.folder-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}
.folder-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-button.active,
.folder-row.drag-target { background: var(--surface-muted); color: var(--text); }
@media (hover: hover) and (pointer: fine) {
  .folder-button:hover { background: var(--surface-muted); color: var(--text); }
}

.folder-button.active .folder-icon { color: var(--accent); }
.folder-action { width: 27px; height: 27px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.folder-action[aria-expanded="true"] { background: var(--surface); color: var(--text); }
@media (hover: hover) and (pointer: fine) {
  .folder-action:hover { background: var(--surface); color: var(--text); }
}

.folder-action:focus-visible,
.folder-menu button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.folder-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  width: 160px;
  min-width: 136px;
  max-width: calc(100vw - 16px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.folder-menu button { width: 100%; padding: 8px 10px; border: 0; border-radius: 4px; background: transparent; text-align: left; white-space: nowrap; cursor: pointer; }
.folder-menu button:focus-visible { background: var(--surface-muted); }
@media (hover: hover) and (pointer: fine) {
  .folder-menu button:hover { background: var(--surface-muted); }
}


.account-area { position: relative; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.account-button {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.account-notification-badge,
.menu-notification-badge { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #c83b35; box-shadow: 0 0 0 2px var(--surface); }
.account-notification-badge { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 1px; transform: translateY(-3px); }
.account-notification-badge[hidden], .menu-notification-badge[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .account-button:hover { background: var(--surface-muted); }
}

.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #c9553f; color: #fff; font-weight: 700; }
.account-copy { min-width: 0; }
.account-name-line { display: flex; align-items: flex-start; min-width: 0; gap: 4px; }
.account-name-line strong { min-width: 0; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 0.84rem; }
.account-copy small { margin-top: 2px; color: var(--muted); font-size: 0.69rem; }
.account-menu {
  position: absolute;
  right: 0;
  bottom: 48px;
  left: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.account-menu button,
.account-menu a { display: block; width: 100%; padding: 8px; border: 0; border-radius: 5px; background: transparent; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.account-menu [hidden] { display: none !important; }
@media (hover: hover) and (pointer: fine) {
  .account-menu button:hover,
  .account-menu a:hover { background: var(--surface-muted); }
}

.account-menu .friend-invite-menu-item { display: flex; align-items: flex-start; justify-content: flex-start; gap: 4px; }
.account-menu .friend-invite-menu-item .menu-notification-badge { margin-top: 4px; transform: translateY(-3px); }

.library-main { min-width: 0; padding: 22px 28px 40px; }
.library-toolbar { display: flex; align-items: center; gap: 18px; min-height: 60px; border-bottom: 1px solid var(--line); }
.library-heading { flex: 1 1 0; min-width: 0; }
.library-toolbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0 15px; font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; letter-spacing: 0; }
.section-kicker { margin: 0; color: var(--accent); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.search-field { flex-shrink: 0; width: min(340px, 40vw); margin-left: auto; }
.danger-command { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.danger-command:focus-visible { background: color-mix(in srgb, var(--danger) 9%, transparent); }
@media (hover: hover) and (pointer: fine) {
  .danger-command:hover { background: color-mix(in srgb, var(--danger) 9%, transparent); }
}

.search-field input, .auth-form input:not([type="checkbox"]), .compact-dialog input:not([type="radio"]):not([type="checkbox"]):not([type="file"]) {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}
.mobile-menu-button { display: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.library-status { min-height: 34px; padding: 12px 2px 6px; color: var(--muted); font-size: 0.78rem; }
.friend-invite-reminder { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 18px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); border-radius: 7px; background: color-mix(in srgb, var(--accent-soft) 42%, var(--surface)); }
.friend-invite-reminder-copy { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.friend-invite-reminder-copy strong { font-size: .76rem; white-space: nowrap; }
.friend-invite-reminder-copy span { overflow: hidden; color: var(--muted); font-size: .72rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.friend-invite-reminder-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 4px; }
.friend-invite-reminder-actions .command-button { min-height: 28px; padding: 4px 8px; font-size: .72rem; }
.friend-invite-reminder[hidden] { display: none; }
.invitation-center { margin: 10px 0 22px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.invitation-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.invitation-heading h2 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; }
.invitation-count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-foreground); font-size: 0.74rem; font-weight: 700; }
.invitation-list { display: grid; gap: 8px; margin-top: 13px; }
.invitation-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.invitation-copy { display: grid; gap: 4px; min-width: 0; }
.invitation-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invitation-copy span { color: var(--muted); font-size: 0.79rem; }
.invitation-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.document-list-region { margin-top: 8px; }
.document-table-header, .document-row {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr) 130px 56px;
  align-items: center;
  column-gap: 16px;
}
.document-table-header { min-height: 32px; padding: 0 10px; color: var(--muted); font-size: 0.7rem; font-weight: 650; text-transform: uppercase; }
.document-table-header > :last-child { text-align: right; white-space: nowrap; }
.document-row { min-height: 58px; padding: 8px 10px; border-top: 1px solid var(--line); }
@media (hover: hover) and (pointer: fine) {
  .document-row:hover { background: var(--surface); }
}

.document-title { min-width: 0; color: var(--text); font-weight: 650; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { overflow: hidden; color: var(--muted); font-size: 0.79rem; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; min-width: 0; }
.row-actions > .icon-command { flex: 0 0 auto; color: var(--muted); }
.row-actions > .icon-command[aria-expanded="true"] { background: var(--surface-muted); color: var(--text); }
.row-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  width: 176px;
  min-width: 156px;
  max-width: calc(100vw - 16px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.row-menu button { width: 100%; padding: 8px 10px; border: 0; border-radius: 4px; background: transparent; text-align: left; white-space: nowrap; cursor: pointer; }
.row-menu button:focus-visible { background: var(--surface-muted); color: var(--text); }
@media (hover: hover) and (pointer: fine) {
  .row-menu button:hover { background: var(--surface-muted); color: var(--text); }
}

.row-menu button:focus-visible { outline: 3px solid var(--focus); outline-offset: -1px; }
.folder-menu[hidden],
.row-menu[hidden] { display: none; }
.library-empty { padding: 64px 20px; border-top: 1px solid var(--line); text-align: center; }
.library-empty h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; }
.library-empty p { color: var(--muted); }
.empty-actions { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }
.empty-actions[hidden] { display: none; }
@media (max-width: 620px) {
  .friend-invite-reminder { align-items: stretch; flex-direction: column; gap: 9px; }
  .friend-invite-reminder-actions { justify-content: flex-end; }
  .invitation-row { align-items: stretch; flex-direction: column; gap: 10px; }
  .invitation-actions .command-button { flex: 1 1 0; }
}

.compact-dialog { width: min(420px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.github-dialog { width: min(520px, calc(100vw - 28px)); }
.friend-invite-dialog { width: min(440px, calc(100vw - 28px)); }
.friend-invite-quota { margin: 8px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.4; }
.github-dialog [hidden] { display: none !important; }
.github-connection-state, .github-account-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.github-connection-state > div, .github-account-row > div { min-width: 0; flex: 1; }
.github-connection-state p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.github-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: #24292f; color: #fff; font-size: .72rem; font-weight: 800; }
.github-account-avatar { display: block; flex: 0 0 auto; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-muted); object-fit: cover; }
.github-account-row { border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.github-account-label { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 3px; }
.github-account-row .command-button { margin-left: auto; }
.github-repository-actions { margin: -2px 0 10px; }
.github-repository-actions:has(.github-install-link[hidden]) { display: none; }
.github-repository-field { display: grid; min-width: 0; gap: 6px; }
.github-repository-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.github-repository-field-heading label { color: var(--muted); font-size: .78rem; font-weight: 600; }
.icon-command.repository-refresh-button { flex: 0 0 auto; width: 28px; min-height: 28px; height: 28px; color: var(--muted); }
.repository-refresh-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.github-install-link { padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: .82rem; font-weight: 650; cursor: pointer; }
.github-import-options { margin-top: 13px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); }
.github-import-options > p { margin: 0 0 10px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.github-import-choice-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 10px; }
.compact-dialog::backdrop { background: rgba(12, 18, 16, 0.42); }
.compact-dialog form { padding: 18px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 17px; }
.dialog-heading h2 { margin: 3px 0 0; font-family: Georgia, "Times New Roman", serif; }
.compact-dialog label, .auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-description { margin: -5px 0 18px; color: var(--muted); font-size: 0.84rem; line-height: 1.55; }
.dialog-field { min-width: 0; }
.dialog-field > span { justify-self: end; margin-top: -1.1rem; color: var(--muted); font-size: 0.68rem; font-weight: 500; }
.dialog-field select {
  width: 100%;
  min-height: 38px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}
.dialog-location { margin: 13px 0 0; color: var(--muted); font-size: 0.73rem; line-height: 1.4; }
.dialog-error { margin: 12px 0 0; padding: 9px 11px; border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); font-size: 0.78rem; line-height: 1.45; }
.dialog-error.is-info { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }
.dialog-error[hidden] { display: none; }
.project-create-dialog { width: min(620px, calc(100vw - 28px)); }
.import-project-dialog { width: min(560px, calc(100vw - 28px)); }
.compact-dialog[aria-busy="true"] .dialog-heading,
.compact-dialog[aria-busy="true"] .dialog-description,
.compact-dialog[aria-busy="true"] fieldset,
.compact-dialog[aria-busy="true"] .dialog-field,
.compact-dialog[aria-busy="true"] .import-dropzone,
.compact-dialog[aria-busy="true"] .selected-archive,
.compact-dialog[aria-busy="true"] .dialog-location { opacity: 0.62; }
.compact-dialog[aria-busy="true"] .command-button:disabled { cursor: wait; }
.import-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.import-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 142px;
  padding: 22px;
  border: 1px dashed color-mix(in srgb, var(--accent) 52%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.import-dropzone[hidden] { display: none; }
.import-dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) {
  .import-dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
}

.import-dropzone:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.import-dropzone > span:not(.zip-mark),
.selected-archive > span:not(.zip-mark) { display: grid; min-width: 0; gap: 4px; }
.import-dropzone small,
.selected-archive small { color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.zip-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.selected-archive {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}
.selected-archive[hidden] { display: none; }
.selected-archive strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-options { display: grid; grid-template-columns: minmax(0, 1fr) 176px; gap: 12px; margin-top: 17px; }
.import-progress { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 0.76rem; font-weight: 600; }
.import-progress[hidden] { display: none; }
.import-progress progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: var(--surface-muted);
  accent-color: var(--accent);
}
.import-progress progress::-webkit-progress-bar { background: var(--surface-muted); border-radius: 4px; }
.import-progress progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.import-progress progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.import-progress.is-complete { color: var(--accent); }
.import-progress.is-error { color: var(--danger); }
.import-progress.is-error progress { accent-color: var(--danger); }
.import-progress.is-error progress::-webkit-progress-value { background: var(--danger); }
.import-progress.is-error progress::-moz-progress-bar { background: var(--danger); }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 30; max-width: 360px; padding: 10px 13px; border-radius: 7px; background: #18201d; color: #fff; box-shadow: var(--shadow); }

.auth-page { min-height: 100vh; background: var(--surface); }
.auth-shell { width: min(440px, calc(100% - 36px)); margin: 0 auto; padding: 28px 0 60px; }
.auth-brand { margin-bottom: min(14vh, 110px); }
.auth-form-region h1 { margin: 5px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; letter-spacing: 0; }
.auth-intro { margin: 0 0 25px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 16px; }
.auth-form .auth-remember { display: flex; align-items: center; gap: 8px; width: fit-content; color: var(--text); font-size: 0.82rem; cursor: pointer; }
.auth-remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.auth-remember[hidden] { display: none !important; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-error { padding: 9px 11px; border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); font-size: 0.82rem; }
.auth-switch { margin-top: 20px; color: var(--muted); font-size: 0.84rem; }

@media (max-width: 1100px) and (min-width: 821px) {
  .document-table-header,
  .document-row { grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) 120px 56px; }
  .document-table-header > :nth-child(3),
  .document-row > :nth-child(3) { display: none; }
}

@media (max-width: 820px) {
  .library-shell { grid-template-columns: 1fr; }
  .library-sidebar { position: fixed; left: 0; transform: translateX(-102%); width: min(280px, 86vw); transition: transform var(--motion-exit, 140ms) var(--motion-move, ease-out); box-shadow: var(--shadow); }
  .library-sidebar.open { transform: translateX(0); transition-duration: var(--motion-normal, 200ms); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 8; background: rgba(12, 18, 16, 0.38); }
  .library-main { padding: 15px 14px 32px; }
  .mobile-menu-button { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .library-toolbar { align-items: center; }
  .library-toolbar h1 { margin-bottom: 12px; font-size: 1.3rem; }
  .search-field { flex-shrink: 0; width: min(220px, 43vw); }
  .document-table-header { display: none; }
  .document-row { grid-template-columns: minmax(0, 1fr) 42px; min-height: 66px; column-gap: 8px; }
  .document-row > .document-meta { display: none; }
  .document-row > .document-meta:nth-child(4) {
    display: block;
    grid-column: 1;
    color: var(--muted);
    font-size: 0.72rem;
  }
  .document-row > .row-actions { grid-column: 2; grid-row: 1 / span 2; }
  .mobile-menu-button,
  .icon-command,
  .scope-button { min-height: 40px; }
  .icon-command { width: 40px; }
  .sidebar-backdrop:not([hidden]) { display: block; }
}

@media (max-width: 520px) {
  .library-toolbar { flex-wrap: wrap; gap: 10px; padding-bottom: 12px; }
  .search-field { order: 3; width: 100%; margin-left: 0; }
  .auth-brand { margin-bottom: 64px; }
  .compact-dialog form { padding: 16px; }
  .import-options { grid-template-columns: minmax(0, 1fr); }
  .github-import-choice-grid { grid-template-columns: minmax(0, 1fr); }
  .import-dropzone { min-height: 124px; padding: 18px 14px; }
  .dialog-actions .command-button { flex: 1 1 0; }
  .empty-actions { flex-direction: column; align-items: stretch; }
}
.project-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.project-type-options legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.project-type-options label {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 104px;
  padding: 14px;
  align-content: center;
  background: var(--surface);
  transition: border-color var(--motion-fast, 120ms) var(--motion-enter, ease-out), background-color var(--motion-fast, 120ms) var(--motion-enter, ease-out);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.project-type-options label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(22, 102, 94, 0.08);
}

.project-type-options label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.project-type-options input { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.project-type-options span:not(.project-type-mark) { display: grid; gap: 3px; }
.project-type-options small { color: var(--muted); }
.project-type-options label:nth-of-type(1) .project-type-mark { color: #2b6ea6; background: #eaf3fb; }
.project-type-options label:nth-of-type(2) .project-type-mark { color: #9b5420; background: #fbefe5; }
.project-type-options label:nth-of-type(3) .project-type-mark { color: #6b4fa0; background: #f1ecfb; }
.project-type-options label:nth-of-type(4) .project-type-mark { color: var(--accent); background: var(--accent-soft); }
.project-type-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  font-weight: 700;
}

.document-title .document-type-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  vertical-align: middle;
}

.document-title .document-type-badge.type-web_slides {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 520px) {
  .project-type-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .project-type-options legend { grid-column: 1; }
  .project-type-options label { grid-template-columns: 32px minmax(0, 1fr); gap: 7px; min-height: 98px; padding: 10px; }
  .project-type-options .project-type-mark { width: 32px; height: 32px; font-size: 0.62rem; }
  .project-type-options small { font-size: 0.68rem; line-height: 1.35; }
}

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); outline: 3px solid var(--accent); }
.sidebar-modal-open { overflow: hidden; }
.compact-dialog, .auth-dialog, .library-sidebar { overscroll-behavior: contain; }
.auth-dialog { max-height: calc(100dvh - 28px); overflow-y: auto; }
.verification-status { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }

/* Keep the mobile scrim on the same clock as its sidebar. */
@media (max-width: 820px) {
  .sidebar-backdrop {
    opacity: 1;
    transition: opacity var(--motion-normal) var(--motion-move), display var(--motion-normal) allow-discrete;
  }
  .sidebar-backdrop[hidden] {
    opacity: 0;
    pointer-events: none;
    transition-duration: var(--motion-exit);
  }
  @starting-style { .sidebar-backdrop:not([hidden]) { opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  .library-sidebar, .sidebar-backdrop, .project-type-options label, .import-dropzone, .import-progress progress::-webkit-progress-value { transition: none; }
  .project-type-options label:has(input:checked) { transform: none; }
}
