:root {
  --ink: #13202b;
  --ink-soft: #52606b;
  --paper: #f3f0e8;
  --surface: #fffdf8;
  --line: #d8d2c5;
  --accent: #dd7d36;
  --accent-dark: #a94e18;
  --green: #2e7257;
  --red: #a83f36;
  --shadow: 0 18px 50px rgba(19, 32, 43, 0.12);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.masthead {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(243, 240, 232, 0.96);
}

.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--paper); background: var(--ink); font: 700 12px/1 ui-monospace, monospace; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { color: var(--ink-soft); font-size: 11px; margin-top: 2px; }
.session-actions { display: flex; align-items: center; gap: 20px; }
.secure-label { color: var(--ink-soft); font-size: 12px; }
.secure-label i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--green); border-radius: 50%; }

main { min-height: calc(100vh - 76px); }
.login-view { min-height: calc(100vh - 76px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 34%); }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 10vw, 150px); }
.eyebrow { margin: 0 0 12px; color: var(--accent-dark); font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; max-width: 760px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 7vw, 84px); font-weight: 500; line-height: .98; letter-spacing: -.045em; }
.lede { max-width: 570px; margin: 28px 0 36px; color: var(--ink-soft); line-height: 1.65; }
#login-form { max-width: 600px; }
label { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.key-row { display: flex; margin-top: 8px; }
.key-row input { flex: 1; min-width: 0; border-right: 0; }
input, textarea { border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink); padding: 13px 14px; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(221, 125, 54, .16); }
.primary-button, .secondary-button, .quiet-button, .back-button, .selection-actions button {
  border: 1px solid transparent;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .02em;
}
.primary-button { color: white; background: var(--accent-dark); }
.primary-button:hover { background: #843c15; }
.destructive-button { background: var(--red); }
.destructive-button:hover { background: #7d2e28; }
.secondary-button { color: var(--ink); background: var(--surface); border-color: var(--line); }
.quiet-button, .back-button { padding-inline: 8px; color: var(--ink-soft); background: transparent; }
.form-error { min-height: 20px; color: var(--red); font-size: 12px; }
.login-aside { display: grid; align-content: center; grid-template-columns: 40px 1fr; gap: 26px 16px; padding: 60px; color: var(--paper); background: var(--ink); }
.login-aside p { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.index-number { padding-top: 6px; color: var(--accent); font: 12px ui-monospace, monospace; }

.workspace { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 80px; }
.page-heading, .browser-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.page-heading h1, .browser-heading h1 { font-size: clamp(38px, 5vw, 64px); }
.browser-heading code { display: block; margin-top: 12px; color: var(--ink-soft); font-size: 13px; }
.browser-actions { display: flex; gap: 10px; }
.search-box { display: flex; align-items: center; min-width: min(380px, 42vw); border-bottom: 1px solid var(--ink); }
.search-box span { color: var(--accent-dark); font: 700 10px ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.search-box input { width: 100%; border: 0; background: transparent; box-shadow: none; }
.search-box.compact { min-width: min(320px, 45vw); }
.status-line { min-height: 24px; margin: 12px 0; color: var(--ink-soft); font-size: 12px; }

.filesystem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); border-top: 1px solid var(--ink); border-left: 1px solid var(--line); }
.filesystem-card { min-height: 245px; display: flex; flex-direction: column; padding: 24px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255, 253, 248, .62); }
.filesystem-card:hover { background: var(--surface); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.region-chip { color: var(--ink-soft); font: 10px ui-monospace, monospace; letter-spacing: .06em; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.state-dot.unavailable { background: var(--red); }
.filesystem-card h2 { margin: 38px 0 8px; font: 500 25px/1.1 Georgia, serif; }
.filesystem-card code { color: var(--ink-soft); font-size: 11px; }
.card-meta { margin: auto 0 20px; color: var(--ink-soft); font-size: 12px; }
.card-meta strong { color: var(--ink); }
.open-filesystem { align-self: flex-start; padding: 7px 0; border: 0; border-bottom: 2px solid var(--accent); background: transparent; color: var(--ink); font-weight: 700; }
.open-filesystem:disabled { cursor: not-allowed; color: var(--ink-soft); border-color: var(--line); }

.back-button { margin: -18px 0 24px -8px; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; min-height: 52px; padding: 0 16px; border: 1px solid var(--line); background: var(--ink); color: var(--paper); font: 12px ui-monospace, monospace; }
.breadcrumbs button { padding: 6px 2px; border: 0; color: inherit; background: transparent; }
.breadcrumbs button:hover { color: var(--accent); }
.crumb-separator { margin: 0 8px; color: #7d8991; }
.file-tools { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.selection-actions { display: flex; gap: 4px; }
.selection-actions button { padding: 8px 10px; border-color: var(--line); background: transparent; }
.danger-text { color: var(--red) !important; }
.file-pane { position: relative; min-height: 300px; border-top: 1px solid var(--ink); background: var(--surface); }
.file-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.file-table th, .file-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.file-table th { color: var(--ink-soft); font: 700 10px ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.file-table th button { padding: 0; border: 0; color: inherit; background: transparent; text-transform: inherit; letter-spacing: inherit; font: inherit; }
.file-table th:nth-child(2) { width: auto; }
.file-table th:nth-child(3) { width: 140px; }
.file-table th:nth-child(4) { width: 200px; }
.file-table th:nth-child(5) { width: 80px; }
.check-column { width: 48px; }
.file-table tbody tr:hover { background: #faf6ed; }
.file-name-button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 2px 0; border: 0; background: transparent; color: var(--ink); text-align: left; font-weight: 600; }
.file-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); color: var(--accent-dark); font: 10px ui-monospace, monospace; }
.file-meta { color: var(--ink-soft); font: 12px ui-monospace, monospace; }
.row-menu { border: 0; background: transparent; color: var(--ink-soft); font-size: 20px; }
.empty-state { padding: 78px 20px; text-align: center; color: var(--ink-soft); }
.empty-state span { font: 40px Georgia, serif; color: var(--accent); }
.empty-state h2 { margin: 10px 0 4px; color: var(--ink); font: 500 22px Georgia, serif; }
.empty-state p { margin: 0; font-size: 13px; }
.drop-overlay { position: absolute; inset: 8px; z-index: 4; display: grid; place-content: center; text-align: center; border: 2px dashed var(--accent); background: rgba(243, 240, 232, .94); }
.drop-overlay strong { font: 500 28px Georgia, serif; }
.drop-overlay span { margin-top: 8px; color: var(--ink-soft); font: 12px ui-monospace, monospace; }

.dialog { width: min(520px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(19, 32, 43, .62); }
.dialog h2 { margin: 0 0 10px; font: 500 30px Georgia, serif; }
.dialog p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.5; }
.dialog label span { display: block; margin-bottom: 7px; }
.dialog label input { width: 100%; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.preview-dialog, .editor-dialog { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); }
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; }
.preview-content { height: calc(100% - 72px); display: grid; place-items: center; margin-top: 18px; background: var(--ink); overflow: auto; }
.preview-content img, .preview-content video { max-width: 100%; max-height: 100%; }
.preview-content iframe { width: 100%; height: 100%; border: 0; background: white; }
.editor-dialog { display: none; grid-template-rows: auto 1fr auto; }
.editor-dialog[open] { display: grid; }
.editor-dialog textarea { width: 100%; height: 100%; resize: none; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.upload-tray { position: fixed; right: 24px; bottom: 24px; z-index: 10; width: min(390px, calc(100vw - 48px)); padding: 18px; color: white; background: var(--ink); box-shadow: var(--shadow); }
.upload-tray div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 12px; }
.upload-tray span { overflow: hidden; color: #c5ccd0; text-overflow: ellipsis; white-space: nowrap; }
.upload-tray progress { width: 100%; accent-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; max-width: min(620px, calc(100vw - 32px)); transform: translateX(-50%); padding: 13px 18px; color: white; background: var(--red); box-shadow: var(--shadow); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 760px) {
  .masthead { height: 66px; padding: 0 16px; }
  .secure-label { display: none; }
  .login-view { min-height: calc(100vh - 66px); grid-template-columns: 1fr; }
  .login-panel { padding: 52px 24px; }
  .login-aside { display: none; }
  .key-row { flex-direction: column; gap: 8px; }
  .key-row input { border-right: 1px solid var(--line); }
  .workspace { width: calc(100% - 24px); padding-top: 36px; }
  .page-heading, .browser-heading { align-items: stretch; flex-direction: column; margin-bottom: 28px; }
  .page-heading .search-box, .search-box.compact { min-width: 100%; }
  .browser-actions { width: 100%; }
  .browser-actions button { flex: 1; }
  .file-tools { align-items: stretch; flex-direction: column; padding: 12px 0; }
  .selection-actions { overflow-x: auto; }
  .file-table th:nth-child(3), .file-table td:nth-child(3) { display: none; }
  .file-table th:nth-child(4), .file-table td:nth-child(4) { width: 112px; }
  .file-table th:nth-child(5) { width: 44px; }
  .file-table th, .file-table td { padding: 11px 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .filesystem-card, button { transition: background-color .15s ease, color .15s ease, transform .15s ease; }
  .primary-button:active { transform: translateY(1px); }
}
