:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-raised: #ffffff;
  --text: #172026;
  --text-strong: #0c141a;
  --muted: #64727d;
  --faint: #8b98a3;
  --line: #d9e0e5;
  --line-strong: #c5ced6;
  --accent: #0f766e;
  --accent-soft: #dff5f1;
  --accent-strong: #0b544f;
  --warn: #b7791f;
  --danger: #b42318;
  --code: #101820;
  --shadow: 0 18px 50px rgb(16 24 32 / 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-strong);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

button.ghost {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

button.ghost:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

textarea {
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 18px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h2 {
  margin: 0;
  line-height: 1.15;
  color: var(--text-strong);
}

.login-panel label {
  display: grid;
  gap: 7px;
}

.login-panel label span,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: var(--code);
  color: #eef8f6;
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 188px;
}

.nav {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.nav button {
  width: auto;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-weight: 600;
}

.nav button:hover,
.nav button.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 1px 2px rgb(16 24 32 / 0.08);
}

.list {
  display: grid;
  gap: 5px;
}

.list button {
  width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.list button:hover {
  border-color: var(--line);
  background: var(--surface);
}

.main-pane {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto minmax(110px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 0.88);
  backdrop-filter: blur(10px);
}

.topbar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.path-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 22px;
}

.browser {
  display: grid;
  height: 100%;
  min-height: 0;
}

.browser-grid {
  --nav-panel-width: 360px;
  --nav-panel-gap: 14px;
  --nav-panel-left: 22px;
  --nav-panel-top: 80px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.muted-copy {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.panel,
.document-frame,
.file-list-pane,
.preview-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.file-list-pane,
.preview-pane {
  min-height: 62vh;
  overflow: auto;
}

.file-list-pane {
  position: fixed;
  top: var(--nav-panel-top);
  left: var(--nav-panel-left);
  z-index: 12;
  width: min(var(--nav-panel-width), calc(100vw - 44px));
  max-height: calc(100vh - var(--nav-panel-top) - 22px);
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgb(255 255 255 / 0.94);
  box-shadow: 0 18px 52px rgb(16 24 32 / 0.16);
  backdrop-filter: blur(12px);
}

.panel-path {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 32px;
  gap: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 0 8px;
  color: var(--muted);
}

.panel-path button {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 116px;
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-strong);
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 750;
}

.panel-path button:hover {
  background: var(--accent-soft);
}

.panel-path-sep,
.panel-path-ellipsis {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
}

.nav-fab {
  width: 42px;
  min-height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
}

.preview-pane {
  transition: margin-left 160ms ease;
}

.browser-grid:not(.nav-collapsed) .preview-pane {
  margin-left: calc(var(--nav-panel-width) + var(--nav-panel-gap));
}

.nav-fab:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.nav-fab span {
  width: 17px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: currentColor;
}

.panel {
  padding: 16px;
}

.file-list {
  display: grid;
  align-content: start;
  padding: 0;
}

.nav-module {
  min-width: 0;
}

.nav-module + .nav-module {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.module-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 30px;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
}

.module-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.module-count {
  min-width: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  line-height: 20px;
}

.file-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.file-row:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.file-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-icon {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.file-meta {
  min-width: 0;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.empty-folder,
.empty-preview {
  color: var(--muted);
  padding: 24px;
  line-height: 1.6;
}

.empty-folder.compact {
  padding: 10px 8px;
  font-size: 13px;
}

.empty-preview {
  min-height: 62vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.empty-preview h3 {
  color: var(--text-strong);
  margin: 0 0 6px;
}

.panel-head,
.document-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
}

.document-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

.document-stack {
  color: #22303a;
}

.page-section {
  scroll-margin-top: 92px;
}

.page-section + .page-section {
  border-top: 1px solid var(--line);
}

.page-divider {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 32px 0;
  background: var(--surface);
}

.page-divider span {
  display: inline-flex;
  max-width: 100%;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.list-row strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-strong);
}

.list-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.audit-main {
  min-width: 0;
}

.markdown {
  max-width: 920px;
  width: 100%;
  padding: 28px 32px 42px;
  color: #22303a;
  line-height: 1.72;
  font-size: 16px;
}

.document-frame .markdown {
  background: var(--surface);
}

.preview-pane .markdown {
  max-width: none;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  color: var(--text-strong);
  line-height: 1.28;
  scroll-margin-top: 90px;
}

.markdown h1 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 30px;
  letter-spacing: 0;
}

.markdown h2 {
  margin-top: 34px;
  margin-bottom: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 22px;
}

.markdown h3 {
  margin-top: 26px;
  margin-bottom: 10px;
  font-size: 17px;
}

.markdown h4,
.markdown h5,
.markdown h6 {
  margin-top: 22px;
  margin-bottom: 8px;
  font-size: 15px;
}

.markdown .heading-anchor {
  opacity: 0;
  margin-left: 8px;
  color: var(--faint);
  text-decoration: none;
  font-size: 0.78em;
  transition: opacity 120ms ease;
}

.markdown h1:hover .heading-anchor,
.markdown h2:hover .heading-anchor,
.markdown h3:hover .heading-anchor,
.markdown h4:hover .heading-anchor,
.markdown h5:hover .heading-anchor,
.markdown h6:hover .heading-anchor {
  opacity: 1;
}

.markdown p,
.markdown li {
  color: #26333b;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown blockquote,
.markdown table,
.markdown figure,
.markdown pre {
  margin-top: 0;
  margin-bottom: 18px;
}

.markdown ul,
.markdown ol {
  padding-left: 1.35rem;
}

.markdown li + li {
  margin-top: 5px;
}

.markdown a {
  color: var(--accent-strong);
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown blockquote {
  border-left: 4px solid var(--accent);
  background: #f4fbf9;
  color: #30424d;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
}

.markdown blockquote > :last-child {
  margin-bottom: 0;
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

.markdown table {
  display: block;
  width: 100%;
  overflow: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown table th,
.markdown table td {
  min-width: 120px;
  border: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}

.markdown table th {
  background: #f3f6f7;
  color: var(--text-strong);
  font-weight: 750;
}

.markdown table tr:nth-child(even) td {
  background: #fbfcfd;
}

.markdown input[type="checkbox"] {
  width: auto;
  margin: 0 7px 0 0;
  transform: translateY(1px);
}

.markdown img {
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.markdown pre,
.code-block {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafb;
  color: #172026;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.markdown code {
  background: #edf3f5;
  color: #18252c;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown pre code {
  display: block;
  min-width: max-content;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.markdown figure[data-rehype-pretty-code-figure] {
  margin: 18px 0;
}

.markdown figure[data-rehype-pretty-code-figure] pre {
  margin: 0;
  padding: 14px 0;
  background: #f7fafb !important;
}

.markdown figure[data-rehype-pretty-code-figure] code {
  display: grid;
  background: transparent;
}

.markdown [data-line] {
  min-height: 1.5em;
  padding: 0 16px;
}

.markdown [data-highlighted-line] {
  background: #fff7d1;
}

.markdown .plain-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.search-row,
.shell-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.shell-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.settings-layout {
  max-width: 960px;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 12px;
    padding: 10px 12px;
  }

  .nav-fab {
    display: none;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    overflow-x: auto;
  }

  .nav button {
    flex: 1 0 auto;
    padding: 0 10px;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .view {
    padding: 12px;
  }

  .browser-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .file-list-pane,
  .preview-pane,
  .empty-preview {
    min-height: auto;
  }

  .file-list-pane {
    position: static;
    width: 100%;
    max-height: none;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .file-list-pane[hidden] {
    display: grid !important;
  }

  .browser-grid:not(.nav-collapsed) .preview-pane {
    margin-left: 0;
    margin-top: 0;
  }

  .shell-form,
  .search-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
