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

/* Notification bell */
.notification-bell {
  position: relative;
}

.notification-bell__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.notification-bell__trigger:hover {
  background: rgba(0, 0, 0, 0.06);
}

.notification-bell__trigger svg {
  display: block;
}

.notification-bell__count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #dc2626;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notification-bell__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.notification-bell__dropdown[hidden] {
  display: none;
}

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

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

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

.notification-item.is-read {
  opacity: 0.7;
  cursor: default;
}

.notification-message {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}

.notification-time {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.notification-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.notification-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.notification-footer {
  padding: 0.5rem 1rem;
  text-align: center;
}

.notification-footer button {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.notification-footer button:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--panel);
}

.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: 0;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.825rem;
  transition: border-color 0.15s, background 0.15s;
}

.site-search input::placeholder {
  color: var(--muted);
}

.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-family: inherit;
  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;
}

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

.auth-dev-login .btn-secondary {
  width: 100%;
}

/* 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: 0.75rem 1.5rem;
  min-height: 2.75rem;
  border: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-cta:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.btn-cta:active {
  transform: translateY(1px);
}

.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%, 1180px);
  margin: 0 auto 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.9rem;
}

.account-avatar {
  display: inline-flex;
  width: 3.4rem;
  height: 3.4rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.account-header h1 {
  margin-top: 0.15rem;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.account-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.account-role {
  padding: 0.18rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, monospace;
  text-transform: uppercase;
}

.account-header .account-signout {
  display: inline-flex;
  min-height: 2.45rem;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border-color: var(--border);
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: none;
  font-size: 0.9rem;
}

.account-header .account-signout:hover {
  border-color: var(--muted);
  background: var(--accent-soft);
}

.account-layout {
  display: grid;
  width: min(100%, 1180px);
  margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem);
  gap: 1rem;
  align-items: start;
}

.account-main,
.account-sidebar {
  display: grid;
  gap: 1rem;
}

.account-section {
  width: 100%;
  padding: clamp(1rem, 2vw, 1.35rem);
  border-radius: var(--radius-md);
}

.account-section__header {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.account-section__header--action {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.account-section__header h2,
.account-list-heading h3 {
  margin: 0;
}

.account-section__header h2 {
  font-size: 1.2rem;
}

.account-section__header p,
.account-list-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.account-section__kicker {
  margin: 0 0 0.25rem !important;
  color: var(--accent) !important;
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, monospace !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.account-section__divider {
  height: 1px;
  margin: 1.25rem 0 1rem;
  background: var(--border);
}

.account-list-heading {
  display: grid;
  gap: 0.25rem;
}

.account-list-heading h3 {
  font-size: 1rem;
}

.account-action,
.account-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.account-action {
  min-height: 2.5rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  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;
}

.account-action:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

.account-action:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent);
}

.account-page-header,
.token-create-layout {
  width: min(100%, 920px);
  margin-right: auto;
  margin-left: auto;
}

.account-page-header {
  margin-bottom: 1rem;
  padding: clamp(1rem, 2vw, 1.35rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-page-header h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.account-page-header p:last-child {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.account-back {
  width: fit-content;
  margin-bottom: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.account-back:hover {
  color: var(--accent);
}

.token-create-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 18rem);
  gap: 1rem;
  align-items: start;
}

.token-create-note h2 {
  margin: 0;
  font-size: 1.05rem;
}

.token-create-note p:last-child {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.account-shell .auth-form button[type="submit"] {
  min-height: 2.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
}

.account-form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.account-form-footer .form-status {
  flex: 1 1 14rem;
}

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

.account-section--danger .account-section__kicker {
  color: #b42318 !important;
}

.account-shell .account-danger-button[type="submit"] {
  border-color: color-mix(in srgb, #b42318 70%, var(--border));
  background: #b42318;
  box-shadow: 0 4px 12px color-mix(in srgb, #b42318 22%, transparent);
}

.account-shell .account-danger-button[type="submit"]:hover {
  background: #8f1c13;
}

.scope-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 3%, var(--panel-strong));
}

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

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

.scope-grid input {
  width: auto;
}

.auth-form .auth-choice.account-toggle {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.auth-form .account-toggle input {
  width: auto;
  margin: 0.1rem 0 0;
}

.account-toggle span {
  display: grid;
  min-width: 0;
  gap: 0.2rem;
}

.account-toggle strong {
  color: var(--text);
}

.account-toggle small {
  color: var(--muted);
  line-height: 1.35;
}

.token-output {
  max-width: 100%;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  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);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.token-list {
  margin-top: 0.75rem;
}

.token-meta {
  display: grid;
  gap: 0.18rem;
}

.token-meta small {
  color: var(--muted);
  line-height: 1.35;
}

.token-row.is-revoked {
  opacity: 0.64;
}

.token-empty {
  display: block !important;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

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

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

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

.user-management {
  display: grid;
  gap: 1rem;
}

.user-management .account-form-footer {
  margin-top: 0.25rem;
}

.user-management button[type="submit"] {
  min-height: 2.5rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.user-disable-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.user-disable-toggle input {
  width: auto;
}

@media (max-width: 880px) {
  .account-layout {
    grid-template-columns: 1fr;
  }

  .token-create-layout {
    grid-template-columns: 1fr;
  }

  .account-sidebar {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    align-items: start;
  }
}

@media (max-width: 560px) {
  .account-shell {
    padding: 0.75rem;
  }

  .account-header {
    align-items: flex-start;
    padding: 0.9rem;
  }

  .account-avatar {
    width: 2.8rem;
    height: 2.8rem;
  }

  .account-header .account-signout {
    min-height: 2.2rem;
    padding: 0.45rem;
  }

  .account-signout svg {
    display: none;
  }

  .user-row {
    grid-template-columns: 1fr;
  }
}

/* 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) 1.25rem;
}

.workspace-shell--document.comments-visible {
  grid-template-columns: minmax(220px, 0.30fr) minmax(0, 1fr) minmax(280px, 24rem);
}

.document-comments-aside {
  display: flex;
  flex-direction: row;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--panel);
}

/* Scrollbar-style strip */
.document-comments-strip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 1.25rem;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 94%, var(--text));
}

.document-comments-strip__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.document-comments-strip__toggle:hover {
  opacity: 1;
  color: var(--accent);
}

.document-comments-strip__toggle svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* Track area for comment markers */
.document-comments-strip__track {
  position: relative;
  flex: 1;
  width: 100%;
  margin-top: 0.25rem;
}

/* Comment markers on the strip */
.document-comments-strip__marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s, width 0.15s, height 0.15s;
}

.document-comments-strip__marker:hover,
.document-comments-strip__marker.is-active {
  opacity: 1;
  transform: translateX(-50%) scale(1.3);
}

/* Panel */
.document-comments-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--border);
  background: var(--panel);
}

.comments-visible .document-comments-panel {
  display: flex;
}

.document-comments-panel__list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

/* Bidirectional hover highlighting */
.comments-aside-item {
  margin-bottom: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  transition: border-color 0.15s, background 0.15s;
}

.comments-aside-item.is-highlighted,
.comments-aside-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--panel-strong));
}

.comments-aside-item__target {
  margin: -0.6rem -0.6rem 0.4rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent-soft);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}

.comments-aside-item:hover .comments-aside-item__target,
.comments-aside-item.is-highlighted .comments-aside-item__target {
  background: color-mix(in srgb, var(--accent) 12%, var(--accent-soft));
  color: var(--accent);
}

.comments-aside-item__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.comments-aside-item__body {
  font-size: 0.85rem;
  line-height: 1.4;
}

.comments-aside-item__comment {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.comments-aside-item__comment:last-child {
  border-bottom: 0;
}

.document-comments-aside__empty {
  margin: 0;
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Paragraph highlight when connected to sidebar */
.commentable.is-highlighted {
  background: var(--accent-soft);
  transition: background 0.15s;
}

@media (min-width: 769px) {
  .comments-visible .comment-list {
    display: none;
  }
}

/* Mobile-only elements hidden on desktop by default */
.document-mobile-bar,
.mobile-drawer-backdrop,
.mobile-drawer-close,
.document-comments-sheet {
  display: none;
}

/* Empty state: browser capped at 36% max */
.workspace-shell--empty {
  grid-template-columns: minmax(300px, 0.5625fr) 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;
}

.miller-column h2.has-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.miller-column-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.miller-column-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.miller-column-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.miller-column:hover .miller-column-actions button,
.miller-column-actions button:focus {
  opacity: 1;
}

.miller-column-actions button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 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,
.keyboard-navigation-active .miller-column a.is-keyboard-selected {
  background: var(--accent-soft);
  color: var(--accent);
}

.keyboard-navigation-active .miller-column a.is-keyboard-selected {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: -2px;
}

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

.tag-preview {
  max-width: 800px;
  padding: 2rem;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0;
  background: var(--panel);
}

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

.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 actions dropdown */
.document-actions-dropdown {
  position: relative;
  display: inline-block;
}

.document-actions-dropdown > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  list-style: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.document-actions-dropdown > summary::-webkit-details-marker {
  display: none;
}

.document-actions-dropdown > summary:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-strong));
  border-color: var(--accent);
  color: var(--accent);
}

.document-actions-dropdown > summary svg {
  width: 1.1rem;
  height: 1.1rem;
}

.document-actions-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 50;
  min-width: 14rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: 0 8px 32px rgba(24, 32, 42, 0.12);
}

.document-actions-dropdown:not([open]) .document-actions-dropdown__menu {
  display: none;
}

.document-actions-dropdown__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.document-actions-dropdown__item:hover {
  background: var(--accent-soft);
}

.document-actions-dropdown__item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.document-actions-dropdown__item--danger {
  color: #b42318;
}

.document-actions-dropdown__item--danger:hover {
  background: color-mix(in srgb, #b42318 10%, var(--panel-strong));
}

.document-actions-dropdown__divider {
  margin: 0.35rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.document-actions-dropdown__meta {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.document-actions-dropdown__meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.document-actions-dropdown__meta-label {
  flex-shrink: 0;
  width: 3rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.document-actions-dropdown__meta-value {
  font-size: 0.8rem;
  word-break: break-all;
}

.document-actions-dropdown__tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-actions-dropdown__tag-list a {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background 0.15s;
}

.document-actions-dropdown__tag-list a:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.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-codemirror-mount] {
  display: none;
  width: 100%;
  min-height: 60vh;
  height: 100%;
  border: 1px solid var(--border);
  overflow: hidden;
}

[data-codemirror-mount].codemirror-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-codemirror-mount].codemirror-mounted ~ textarea {
  display: none;
}

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

[data-codemirror-mount]:not(.codemirror-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: codemirror-shimmer 1.5s ease infinite;
  color: var(--muted);
  font-size: 0.85rem;
}

[data-codemirror-mount] .cm-editor,
[data-conflict-codemirror-mount] .cm-editor {
  height: 100%;
}

.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-codemirror-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-codemirror-mount].codemirror-mounted {
  display: block;
}

[data-conflict-codemirror-mount].codemirror-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--empty {
    grid-template-columns: minmax(240px, 0.45fr) minmax(0, 1fr);
    gap: 0;
  }

  .workspace-shell--document {
    grid-template-columns: minmax(240px, 0.45fr) minmax(0, 1fr) 1.25rem;
    gap: 0;
  }

  .workspace-shell--document.comments-visible {
    grid-template-columns: minmax(180px, 0.30fr) minmax(0, 1fr) 16rem;
  }

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

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

  .site-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    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;
  }

  .workspace-shell--document.comments-visible {
    grid-template-columns: 1fr;
  }

  /* Mobile shell layout */
  .document-shell {
    display: flex;
    flex-direction: column;
    padding: 0;
    min-height: auto;
    max-height: none;
    border-left: 1px solid var(--border);
    border-top: 0;
  }

  /* Mobile top bar */
  .document-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }

  .document-mobile-bar__title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }

  .document-mobile-bar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel-strong);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
  }

  .document-mobile-bar__btn:hover {
    background: color-mix(in srgb, var(--accent) 8%, var(--panel-strong));
    border-color: var(--accent);
    color: var(--accent);
  }

  .document-mobile-bar__btn svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  /* Breadcrumbs below mobile bar */
  .document-shell .breadcrumbs {
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    font-size: 0.85rem;
  }

  /* Backdrop for drawers */
  .mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  body.drawer-open .mobile-drawer-backdrop {
    opacity: 1;
    visibility: visible;
  }

  /* Drawer close button */
  .mobile-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s;
  }

  .mobile-drawer-close:hover {
    color: var(--accent);
  }

  .mobile-drawer-close svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  .mobile-drawer-close--inside {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 5;
  }

  /* Left file picker drawer */
  .miller-browser {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(82vw, 20rem);
    min-height: auto;
    max-height: none;
    z-index: 200;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 0;
    background: var(--panel);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .miller-browser.is-open {
    transform: translateX(0);
  }

  .miller-browser .mobile-drawer-close--inside {
    top: 0.5rem;
    right: 0.5rem;
  }

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

  /* Top metadata drawer */
  .document-meta {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 200;
    max-height: 70vh;
    overflow-y: auto;
    padding: 2.2rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--panel);
    transform: translateY(-110%);
    transition: transform 0.25s ease;
    box-shadow: 0 12px 40px rgba(24, 32, 42, 0.12);
  }

  .document-meta.is-open {
    transform: translateY(0);
  }

  .document-meta .mobile-drawer-close--inside {
    top: 0.55rem;
    right: 0.55rem;
  }

  .document-meta__header {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .document-actions-dropdown__menu {
    position: static;
    box-shadow: none;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--panel-strong);
    margin-top: 0.5rem;
  }

  .document-actions-dropdown__item {
    padding: 0.65rem 0.8rem;
  }

  .document-actions-dropdown__meta {
    padding: 0.5rem 0.8rem;
  }

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

  /* Document body padding */
  .document-shell .markdown-body {
    padding: 1rem;
    padding-bottom: calc(1rem + 64px);
  }

  /* Comments bottom sheet */
  .document-comments-aside {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 80vh;
    max-height: none;
    z-index: 200;
    flex-direction: column;
    background: var(--panel);
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.25s ease;
    box-shadow: 0 -4px 24px rgba(24, 32, 42, 0.08);
  }

  .document-comments-aside.is-open {
    transform: translateY(0);
  }

  .document-comments-aside .document-comments-strip,
  .document-comments-aside .document-comments-panel {
    display: none;
  }

  .document-comments-sheet {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  .document-comments-sheet__handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
    height: 48px;
    padding: 0 0.6rem;
    border-bottom: 1px solid var(--border);
  }

  .document-comments-sheet__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
  }

  .document-comments-sheet__toggle svg {
    width: 1rem;
    height: 1rem;
    color: var(--accent);
  }

  .document-comments-sheet__panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
  }
}

@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);
  }

  .notification-bell__trigger:hover {
    background: rgba(255, 255, 255, 0.08);
  }

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

  .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-codemirror-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,
.keyboard-navigation-active .commentable.is-keyboard-selected,
.keyboard-navigation-active .markdown-body .is-keyboard-selected {
  background: var(--accent-soft);
}

.keyboard-navigation-active .markdown-body .is-keyboard-selected {
  outline: 2px solid color-mix(in srgb, var(--accent) 68%, transparent);
  outline-offset: 0.25rem;
}

.comment-anchor-btn {
  position: absolute;
  right: -1.5rem;
  top: 0.25rem;
  width: 1.28rem;
  height: 1.28rem;
  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);
  opacity: 0.82;
  overflow: visible;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.comment-anchor-btn svg {
  width: 0.78rem;
  height: 0.78rem;
}

.comment-anchor-btn--has-comments {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, black);
  color: white;
  opacity: 1;
}

.comment-anchor-btn--has-comments:hover,
.comment-anchor-btn--has-comments:focus-visible {
  background: color-mix(in srgb, var(--accent) 88%, black);
}

.comment-anchor-count {
  position: absolute;
  top: -0.3rem;
  right: -0.4rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.24rem;
  border: 1px solid var(--panel-strong);
  border-radius: 999px;
  background: var(--text);
  color: var(--panel-strong);
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.comment-anchor-count[hidden] {
  display: none;
}

.comment-anchor-tooltip {
  position: absolute;
  top: -2rem;
  right: -0.25rem;
  z-index: 2;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(0.2rem);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

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

.comment-anchor-btn:hover,
.comment-anchor-btn:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
}

.comment-anchor-btn:hover .comment-anchor-tooltip,
.comment-anchor-btn:focus-visible .comment-anchor-tooltip {
  opacity: 1;
  transform: translateY(0);
}

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

.comments-hidden .comment-list {
  display: none;
}

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

.comment-popup {
  position: absolute;
  left: 50%;
  top: calc(100% + 0.4rem);
  transform: translateX(-50%) translateY(0.25rem);
  z-index: 100;
  width: min(22rem, calc(100vw - 2rem));
  max-height: 18rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.comment-popup--visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.comment-popup__title {
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.comment-popup__list {
  max-height: 14rem;
  overflow-y: auto;
}

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

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

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

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

.comment-popup__body {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.permissions-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.permissions-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.permissions-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.permissions-form {
  display: grid;
  gap: 1rem;
}

.permissions-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.permissions-panel__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-strong) 62%, transparent);
}

.permissions-panel__header h2 {
  margin: 0.15rem 0 0;
  font-size: 1.1rem;
}

.permission-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.permission-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.permission-select-all input,
.permission-user-check {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.permission-bulk-actions select,
.permission-user-row select {
  min-height: 2.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
}

.permission-bulk-actions select {
  min-width: 9rem;
  padding: 0.5rem 0.65rem;
}

.permission-apply {
  min-height: 2.35rem;
  padding: 0.45rem 0.8rem;
}

.permission-user-list {
  display: grid;
}

.permission-user-row {
  display: grid;
  grid-template-columns: auto minmax(14rem, 1.4fr) minmax(13rem, 1fr) minmax(9rem, 12rem);
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.permission-user-row:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.permission-user-row:last-child {
  border-bottom: 0;
}

.permission-user-main,
.permission-grant-meta {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
}

.permission-user-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.permission-user-name em {
  color: var(--accent);
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, monospace;
  font-style: normal;
  letter-spacing: 0;
  text-transform: uppercase;
}

.permission-user-email,
.permission-user-meta,
.permission-grant-meta small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permission-grant-meta strong {
  font-size: 0.94rem;
}

.permission-select-wrap {
  min-width: 0;
}

.permission-user-row select {
  width: 100%;
  padding: 0.5rem 0.65rem;
}

.permissions-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.1rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-strong) 50%, transparent);
}

@media (max-width: 620px) {
  .permissions-header {
    display: grid;
  }

  .permissions-panel__header,
  .permission-user-row {
    grid-template-columns: 1fr;
  }

  .permissions-panel__header {
    align-items: start;
  }

  .permission-bulk-actions {
    justify-content: stretch;
  }

  .permission-bulk-actions select,
  .permission-apply,
  .permissions-footer .btn-primary {
    width: 100%;
  }
}
