:root {
  color-scheme: light dark;
  --paper: light-dark(#ffffff, #191b1e);
  --ink: light-dark(#25282b, #e4e7ea);
  --muted: light-dark(#687078, #a5acb5);
  --line: light-dark(#e5e8eb, #30353b);
  --hover: light-dark(#f3f5f7, #24282e);
  --accent: light-dark(#3c68a3, #99bdeb);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
  accent-color: var(--accent);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .5; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.header, main { width: min(1040px, calc(100% - 48px)); margin-inline: auto; }
.header { height: 60px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 6px; border: 0; border-radius: 4px; background: none; color: var(--muted); flex-shrink: 0; }
.icon-button:hover { background: var(--hover); color: var(--ink); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.theme-light, [data-theme="dark"] .theme-dark { display: none; }
[data-theme="dark"] .theme-light { display: block; }
main { padding-block: 20px 40px; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 18px; font-size: 12px; color: var(--muted); }
.breadcrumbs button { max-width: 100%; padding: 3px 0; border: 0; background: none; color: inherit; overflow-wrap: anywhere; }
.breadcrumbs button:hover { color: var(--accent); }
.breadcrumbs button:last-child { color: var(--ink); }
.breadcrumbs .separator { padding-inline: 3px; color: var(--muted); opacity: .55; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.search { width: min(320px, 100%); min-width: 0; }
.search input { width: 100%; height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); font-size: 12px; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.name-mode { display: flex; flex-shrink: 0; padding: 2px; border: 1px solid var(--line); border-radius: 4px; }
.name-mode button { padding: 5px 9px; border: 0; border-radius: 2px; background: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.name-mode button:hover { color: var(--ink); }
.name-mode button[aria-pressed="true"] { background: var(--hover); color: var(--ink); }

table { table-layout: fixed; border-collapse: collapse; width: 100%; border-top: 1px solid var(--line); }
td { height: 42px; padding: 4px 0; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--hover); }
.file-name { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 0; border: 0; background: none; text-align: left; font-size: 13px; }
.file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); }
.file-name:hover { color: var(--accent); }
.file-name.folder { font-weight: 500; }
.status { padding: 36px 0; margin: 0; color: var(--muted); font-size: 13px; }
.status.error, .document-status.error { color: light-dark(#a04336, #e7a095); }
.snapshot-date { display: block; margin: -12px 0 20px; color: var(--muted); font-size: 12px; }
.list-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding-top: 10px; color: var(--muted); font-size: 12px; }
.list-footer a { text-decoration: underline; text-underline-offset: 2px; }

dialog { padding: 0; border: 1px solid var(--line); border-radius: 6px; width: min(1100px, calc(100vw - 40px)); height: calc(100dvh - 40px); max-height: none; color: var(--ink); background: var(--paper); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #0008; }
#settings-dialog { width: min(480px, calc(100vw - 32px)); height: fit-content; border: 1px solid var(--line); border-radius: 6px; }
#settings-dialog .document-header { display: flex; }
.settings-option { display: flex; align-items: flex-start; gap: 10px; padding: 20px; font-size: 13px; }
.document-header { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.document-header h2 { flex: 1; margin: 0; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tabs { display: flex; gap: 14px; margin-right: 8px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; padding: 6px 0; background: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-pressed="true"] { border-bottom-color: var(--ink); color: var(--ink); }
.document-status { padding: 10px 20px; margin: 0; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.document-status:empty { display: none; }
.document-content { flex: 1; min-height: 0; overflow: auto; }
.document-content pre { margin: 0; padding: 20px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.9 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.document-content iframe { display: block; width: 100%; height: 100%; border: 0; background: white; color-scheme: light; }
.document-content img { display: block; max-width: 100%; height: auto; margin: 20px auto; }
.metadata { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px 24px; margin: 0; padding: 24px 20px; font-size: 13px; }
.metadata dt { color: var(--muted); }
.metadata dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 600px) {
  .header, main { width: calc(100% - 32px); }
  .header { height: 52px; }
  main { padding-top: 16px; }
  .breadcrumbs { font-size: 11px; gap: 3px; margin-bottom: 14px; }
  .toolbar { flex-wrap: wrap; gap: 10px; }
  .search { width: 100%; }
  .name-mode { margin-left: auto; }
  dialog { width: 100vw; height: 100dvh; max-width: none; border: 0; border-radius: 0; }
  .document-header { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 32px); padding-inline: 12px; gap: 4px 8px; }
  .document-header h2 { grid-column: 1; grid-row: 1; }
  .document-actions { display: contents; }
  .tabs { grid-column: 1 / -1; grid-row: 2; margin: 0; }
  #original { grid-column: 2; grid-row: 1; }
  #download { grid-column: 3; grid-row: 1; }
  #close { grid-column: 4; grid-row: 1; }
  .document-content pre { padding: 16px; }
  .metadata { grid-template-columns: 85px minmax(0, 1fr); gap: 14px 16px; padding: 20px 16px; font-size: 12px; }
}
