:root {
  --bg: #F7F5F0;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #5c5c5c;
  --line: #ddd8ce;
  --red: #A31F34;
  --red-deep: #8a1a2c;
  --red-soft: rgba(163, 31, 52, 0.08);
  --shadow: 0 12px 40px rgba(17, 17, 17, 0.06);
  --radius: 2px;
  --font: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: "IBM Plex Serif", Georgia, serif;
  --ui-scale: 1.25;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Default 125% — same feel as browser zoom for easier reading */
  zoom: var(--ui-scale);
}

@supports not (zoom: 1) {
  html {
    font-size: 18.75px; /* 15px × 1.25 */
  }
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(163, 31, 52, 0.06), transparent 55%),
    linear-gradient(180deg, #faf8f4 0%, var(--bg) 40%, #f3efe6 100%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@supports not (zoom: 1) {
  body {
    font-size: 1rem;
  }
}

.hidden { display: none !important; }

/* —— Login —— */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 2.25rem 2rem 2rem;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.mit-bar {
  display: block;
  width: 48px;
  height: 6px;
  background: var(--red);
  margin-bottom: 1.25rem;
}

.brand-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.login-panel h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-sub {
  margin: 0.6rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

#login-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

#login-form input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  background: #fbfaf7;
  font: inherit;
  color: var(--ink);
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#login-form input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.remember-row {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.remember-row input {
  width: auto !important;
  margin: 0 !important;
  accent-color: var(--red);
  transform: scale(1.15);
}

.login-hint {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

#login-btn,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 0;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#login-btn:hover,
.btn-primary:hover {
  background: var(--red-deep);
}

#login-btn:active,
.btn-primary:active {
  transform: translateY(1px);
}

.error {
  margin: 0.85rem 0 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 500;
}

/* —— App shell —— */
.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mit-mark {
  width: 14px;
  height: 28px;
  background: var(--red);
  flex-shrink: 0;
}

.brand {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: block;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--bg);
  font: inherit;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
}

.section-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 0.7rem 0.15rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.nav-back {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  width: 34px;
  height: 34px;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-back:hover {
  border-color: var(--red);
  color: var(--red);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.2rem;
  min-width: 0;
  font-size: 0.78rem;
  flex: 1;
}

.crumb {
  border: 0;
  background: transparent;
  color: var(--red);
  font: inherit;
  font-weight: 600;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb.current {
  color: var(--ink);
  cursor: default;
  font-weight: 700;
}

.crumb-sep { color: var(--muted); opacity: 0.7; }

.nav-status {
  margin: 0;
  padding: 0.45rem 0.85rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-list {
  overflow: auto;
  padding: 0.35rem 0.5rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.nav-group {
  margin: 0.65rem 0.35rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-row-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem;
  align-items: stretch;
}

.nav-row-wrap.active .nav-row {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.nav-row-wrap.active .nav-sub,
.nav-row-wrap.active .nav-badge,
.nav-row-wrap.active .nav-chevron { color: rgba(255, 255, 255, 0.85); }

.nav-row-wrap.active .nav-icon { color: #fff; }

.nav-rename {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 0.55rem;
  cursor: pointer;
  white-space: nowrap;
}

.nav-rename:hover {
  color: var(--red);
  border-color: var(--red);
}

.nav-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 0.45rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: #fff;
  padding: 0.7rem 0.65rem;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s;
}

.nav-row:hover {
  background: var(--red-soft);
  border-color: rgba(163, 31, 52, 0.18);
}

.nav-row.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.nav-row.active .nav-sub,
.nav-row.active .nav-badge,
.nav-row.active .nav-chevron { color: rgba(255, 255, 255, 0.85); }

.nav-row.folder { border-left: 3px solid var(--red); }

.nav-icon {
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 700;
}

.nav-row.active .nav-icon { color: #fff; }

.nav-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav-title {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-sub {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--red);
  white-space: nowrap;
}

.nav-chevron { color: var(--muted); font-weight: 700; }

.main {
  min-width: 0;
  position: relative;
  background:
    linear-gradient(90deg, transparent 39px, rgba(163, 31, 52, 0.045) 40px) 0 0 / 40px 100%,
    transparent;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: calc(100vh - 64px);
  text-align: center;
  padding: 2rem;
  animation: rise 0.4s ease both;
}

.empty-state h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.75rem;
}

.empty-state p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.viewer {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 64px);
  animation: rise 0.35s ease both;
}

.viewer-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 64px;
  z-index: 10;
}

.viewer-titles h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  word-break: break-word;
}

.muted {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  word-break: break-all;
}

.viewer-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.viewer-actions .btn-primary {
  width: auto;
  min-width: 96px;
  padding: 0.6rem 1rem;
}

.quick-copy {
  padding: 1rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.quick-copy-hint {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  box-shadow: 0 1px 0 rgba(17, 17, 17, 0.03);
  animation: rise 0.3s ease both;
}

.copy-row.is-editing {
  border-color: var(--ink);
  background: #fff;
}

.copy-meta { min-width: 0; }

.copy-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.3rem;
}

.copy-value {
  display: block;
  font-family: ui-monospace, "IBM Plex Sans", Menlo, Consolas, monospace;
  font-size: 0.98rem;
  font-weight: 500;
  word-break: break-all;
  color: var(--ink);
  line-height: 1.35;
  user-select: all;
  cursor: pointer;
}

.copy-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, "IBM Plex Sans", Menlo, Consolas, monospace;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
  padding: 0.45rem 0.55rem;
  border: 1.5px solid var(--ink);
  background: #fff;
  outline: none;
}

.copy-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(163, 31, 52, 0.15);
}

.copy-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  align-items: center;
}

.copy-row .btn-copy,
.copy-row .btn-row-edit {
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  min-width: 72px;
  cursor: pointer;
  flex-shrink: 0;
}

.copy-row .btn-copy {
  background: var(--red);
  color: #fff;
}

.copy-row .btn-row-edit {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.copy-row .btn-row-edit:hover {
  border-color: var(--ink);
  background: rgba(17, 17, 17, 0.04);
}

.copy-row .btn-copy:hover { background: var(--red-deep); }
.copy-row .btn-copy.copied { background: var(--ink); }
.copy-row .btn-copy:disabled,
.copy-row .btn-row-edit:disabled {
  opacity: 0.55;
  cursor: wait;
}

.copy-notes {
  margin: 0.25rem 0 0;
  padding: 0 1.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.raw-wrap {
  margin: 0.75rem 1.25rem 2rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.raw-wrap > summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  list-style: none;
}

.raw-wrap > summary::-webkit-details-marker { display: none; }
.raw-wrap[open] > summary { border-bottom: 1px solid var(--line); color: var(--ink); }
.raw-wrap .file-content { padding: 1rem; }

.file-content {
  margin: 0;
  padding: 1.25rem 1.5rem 3rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Sans", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  flex: 1;
  outline: none;
}

.file-media {
  padding: 1.25rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

.file-media img {
  max-width: min(100%, 720px);
  height: auto;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fff;
}

.brand-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.file-media iframe {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  background: #fff;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--ink);
  color: #fff;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 50;
  animation: rise 0.2s ease both;
}

.nav-crumbbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
  min-height: 44px;
  flex-wrap: wrap;
}

.nav-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-new {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-new:hover {
  border-color: var(--red);
  color: var(--red);
}

.btn-new-primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-new-primary:hover {
  background: var(--red-deep);
  color: #fff;
}

.composer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 17, 17, 0.35);
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: rise 0.2s ease both;
}

.composer-panel {
  width: min(640px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.35rem;
}

.composer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.composer-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
}

#composer-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0.75rem 0 0.35rem;
}

#composer-form input,
#composer-form select,
#composer-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfaf7;
  font: inherit;
  color: var(--ink);
  padding: 0.7rem 0.8rem;
  outline: none;
}

#composer-form textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
  font-family: "IBM Plex Sans", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

#composer-form input:focus,
#composer-form select:focus,
#composer-form textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.composer-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.composer-actions .btn-primary {
  width: auto;
  min-width: 120px;
}

#file-editor {
  width: 100%;
  min-height: 50vh;
  margin: 0;
  padding: 1.25rem 1.5rem 3rem;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fffefb;
  font: inherit;
  font-family: "IBM Plex Sans", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  outline: none;
}

.tree-empty {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.folder-share-panel {
  margin: 0.5rem 0.85rem 0.25rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  background: var(--surface);
}

.folder-share-panel label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

#folder-share-url {
  flex: 1 1 140px;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
}

#btn-share-folder.is-shared {
  border-color: var(--red);
  color: var(--red);
  font-weight: 700;
}

.share-panel {
  margin: 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  background: var(--surface);
}

.share-panel label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

#share-url {
  flex: 1 1 220px;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
}

.share-status {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.upload-preview-wrap {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#upload-preview {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

#upload-form label {
  display: block;
  margin: 0.85rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

#upload-form input,
#upload-form select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
}

#upload-form input:focus,
#upload-form select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(163, 31, 52, 0.88);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.drop-overlay p { margin: 0; }

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand lock"
      "search search";
  }
  .topbar-left { grid-area: brand; }
  .search-wrap { grid-area: search; }
  #logout-btn { grid-area: lock; }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    max-height: 48vh;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-actions {
    width: 100%;
    margin-left: 0;
  }
  .btn-new { flex: 1; }
  .viewer-head {
    top: auto;
    flex-direction: column;
  }
  .viewer-actions { width: 100%; flex-wrap: wrap; }
  .viewer-actions .btn-primary,
  .viewer-actions .btn-ghost { flex: 1; justify-content: center; }
}
