:root {
  color-scheme: light;
  --ink: #172231;
  --muted: #68778a;
  --muted-strong: #4d5c6e;
  --line: #dbe3ec;
  --line-strong: #c7d2df;
  --surface: #ffffff;
  --surface-soft: #f4f7fb;
  --surface-hover: #f7faff;
  --accent: #1769aa;
  --accent-dark: #0f4e81;
  --accent-soft: #e8f2fb;
  --danger: #b53b3b;
  --danger-soft: #fff0f0;
  --success: #267450;
  --radius: 6px;
  --shadow: 0 16px 34px rgb(24 40 60 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--surface-soft); color: var(--ink); font-size: 14px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgb(23 105 170 / 32%); outline-offset: 2px; }
[hidden] { display: none !important; }
.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; }

.app-shell { min-height: 100dvh; }
.auth-screen { min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 18px; padding: 32px 20px; }
.auth-panel { width: min(100%, 420px); padding: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--accent); border-radius: var(--radius); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.brand-mark-small { width: 32px; height: 32px; font-size: 11px; }
.eyebrow { margin: 22px 0 7px; color: var(--accent-dark); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.auth-panel h1, .main-heading h1 { margin: 0; color: var(--ink); font-size: clamp(24px, 3vw, 32px); line-height: 1.15; letter-spacing: -.02em; }
.auth-copy { margin: 10px 0 26px; color: var(--muted); line-height: 1.55; }
.auth-form, .modal-form { display: grid; gap: 9px; }
label { color: var(--muted-strong); font-size: 12px; font-weight: 700; }
input { width: 100%; min-height: 42px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); }
input::placeholder { color: #8a98a8; }
input:focus { border-color: var(--accent); }
.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field .icon-button { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); min-width: 52px; min-height: 32px; padding: 0 7px; }
.auth-submit { margin-top: 10px; width: 100%; }
.form-status { min-height: 18px; margin: 2px 0 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.auth-footnote { margin: 0; color: var(--muted); font-size: 12px; }

.workspace { min-height: 100dvh; display: grid; grid-template-rows: 60px 1fr; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-brand, .topbar-actions, .connection-status { display: flex; align-items: center; }
.topbar-brand { gap: 10px; }
.topbar-brand strong, .topbar-brand span { display: block; }
.topbar-brand strong { font-size: 14px; letter-spacing: .01em; }
.topbar-brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.topbar-actions { gap: 12px; }
.connection-status { gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa7b4; }
.connection-status[data-state="online"] { color: var(--success); }
.connection-status[data-state="online"] .status-dot { background: var(--success); }
.connection-status[data-state="connecting"] .status-dot { background: #ba7c24; animation: pulse 1.3s ease-in-out infinite; }
.connection-status[data-state="error"] { color: var(--danger); }
.connection-status[data-state="error"] .status-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.workspace-body { min-width: 0; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { display: flex; min-height: 0; flex-direction: column; padding: 25px 14px 16px; background: #edf2f7; border-right: 1px solid var(--line); }
.sidebar-heading, .sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: var(--muted-strong); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.count-label { min-width: 22px; padding: 2px 6px; color: var(--muted); background: #dfe7ef; border-radius: 10px; font-size: 11px; text-align: center; }
.mount-list { display: grid; gap: 3px; margin: 10px 0 27px; }
.mount-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; color: var(--muted-strong); background: transparent; border: 1px solid transparent; border-radius: var(--radius); text-align: left; }
.mount-button:hover { background: rgb(255 255 255 / 70%); }
.mount-button[aria-current="true"] { color: var(--accent-dark); background: var(--accent-soft); border-color: #c9e0f3; font-weight: 700; }
.mount-glyph, .folder-glyph, .entry-glyph { display: inline-grid; place-items: center; flex: 0 0 auto; color: var(--accent); font-size: 12px; font-weight: 800; }
.mount-glyph { width: 20px; height: 20px; border: 1px solid currentColor; border-radius: 4px; font-size: 9px; }
.sidebar-section-heading { margin-bottom: 9px; }
.folder-tree { display: grid; gap: 2px; }
.folder-tree a { display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 5px 10px; color: var(--muted-strong); border-radius: var(--radius); text-decoration: none; }
.folder-tree a:hover, .folder-tree a[aria-current="page"] { color: var(--accent-dark); background: rgb(255 255 255 / 68%); }
.folder-tree a[aria-current="page"] { font-weight: 700; }
.folder-tree .folder-glyph { width: 17px; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.sidebar-footer-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.sidebar-footer-value { display: block; overflow: hidden; color: var(--muted-strong); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.main-panel { min-width: 0; padding: 32px clamp(20px, 4vw, 54px) 46px; }
.main-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; max-width: 1080px; margin: 0 auto 22px; }
.main-heading-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.main-heading .eyebrow { margin-top: 0; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; max-width: 1080px; margin: 0 auto 15px; color: var(--muted); font-size: 12px; }
.breadcrumbs a, .breadcrumbs button { color: var(--muted-strong); background: transparent; border: 0; text-decoration: none; }
.breadcrumbs a:hover, .breadcrumbs button:hover { color: var(--accent-dark); text-decoration: underline; }
.breadcrumb-separator { color: #9aa7b4; padding: 0 2px; }
.inline-status { max-width: 1080px; margin: 0 auto 12px; padding: 10px 12px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f1cdcd; border-radius: var(--radius); font-size: 12px; }
.file-surface { max-width: 1080px; margin: 0 auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.main-panel.is-dragging .file-surface { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(23 105 170 / 18%); }
.file-table-head, .file-row { display: grid; grid-template-columns: minmax(180px, 1fr) 130px 190px 94px; align-items: center; gap: 18px; }
.file-table-head { min-height: 42px; padding: 0 18px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.file-row { min-height: 62px; padding: 0 18px; border-bottom: 1px solid #edf1f5; }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--surface-hover); }
.entry-name { display: flex; align-items: center; min-width: 0; gap: 11px; }
.entry-glyph { width: 25px; height: 25px; color: var(--muted-strong); border: 1px solid var(--line-strong); border-radius: 5px; font-size: 10px; }
.file-row[data-kind="directory"] .entry-glyph { color: var(--accent); background: var(--accent-soft); border-color: #c9e0f3; }
.entry-link { min-width: 0; overflow: hidden; color: var(--ink); background: none; border: 0; font-weight: 650; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.file-row[data-kind="directory"] .entry-link { color: var(--accent-dark); }
.entry-link:hover { text-decoration: underline; }
.entry-meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; opacity: 0; transition: opacity .15s ease; }
.file-row:hover .row-actions, .file-row:focus-within .row-actions { opacity: 1; }
.row-action { min-height: 30px; padding: 0 7px; color: var(--muted-strong); background: transparent; border: 1px solid transparent; border-radius: var(--radius); font-size: 11px; }
.row-action:hover { color: var(--accent-dark); background: var(--accent-soft); border-color: #c9e0f3; }
.row-action.delete:hover { color: var(--danger); background: var(--danger-soft); border-color: #f1cdcd; }
.loading-state { padding: 2px 18px; }
.skeleton-row { display: grid; grid-template-columns: minmax(180px, 1fr) 130px 190px; gap: 18px; min-height: 62px; align-items: center; border-bottom: 1px solid #edf1f5; }
.skeleton-row span { height: 12px; background: linear-gradient(90deg, #edf1f5, #f8fafc, #edf1f5); background-size: 200% 100%; border-radius: 3px; animation: shimmer 1.5s ease-in-out infinite; }
.skeleton-row span:first-child { width: 56%; }
.skeleton-row span:nth-child(2) { width: 45%; }
.skeleton-row span:nth-child(3) { width: 68%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-state, .error-state { padding: 72px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 38px; height: 38px; margin: 0 auto 14px; color: var(--accent); border: 1px solid #c9e0f3; border-radius: 50%; font-size: 22px; font-weight: 300; }
.empty-state h2, .error-state h2 { margin: 0 0 8px; font-size: 18px; }
.empty-state p, .error-state p { max-width: 360px; margin: 0 auto 18px; color: var(--muted); line-height: 1.5; }
.error-state { color: var(--danger); }
.error-state p { color: var(--muted); }

.primary-button, .secondary-button, .text-button, .icon-button { min-height: 38px; border-radius: var(--radius); font-weight: 700; }
.primary-button { padding: 0 15px; color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.primary-button:active, .secondary-button:active, .text-button:active { transform: translateY(1px); }
.secondary-button { padding: 0 13px; color: var(--accent-dark); background: var(--surface); border: 1px solid #b9cddd; }
.secondary-button:hover { background: var(--accent-soft); border-color: #8db5d5; }
.text-button, .icon-button { padding: 0 9px; color: var(--muted-strong); background: transparent; border: 1px solid transparent; }
.text-button:hover, .icon-button:hover { color: var(--accent-dark); background: var(--accent-soft); border-color: #c9e0f3; }

.modal-layer { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(20 34 51 / 36%); }
.modal { position: relative; width: min(100%, 430px); padding: 25px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 24px 70px rgb(17 31 47 / 24%); }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-heading .eyebrow { margin: 0 0 6px; }
.modal-heading h2 { margin: 0; font-size: 20px; }
.modal-close { min-height: 32px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.preview-modal { width: min(100%, 860px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.preview-modal .modal-heading { flex: 0 0 auto; }
.preview-content { flex: 1 1 auto; min-height: 0; margin: 0; overflow: auto; padding: 14px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; white-space: pre; overflow-wrap: anywhere; }
.context-menu { position: fixed; z-index: 40; min-width: 150px; max-width: calc(100vw - 16px); padding: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
.context-menu button { display: block; width: 100%; min-height: 34px; padding: 0 10px; overflow: hidden; color: var(--ink); background: transparent; border: 0; border-radius: 4px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.context-menu button:hover, .context-menu button:focus-visible { color: var(--accent-dark); background: var(--accent-soft); }
.context-menu button:disabled { color: var(--muted); cursor: not-allowed; }
.toast-region { position: fixed; z-index: 30; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { padding: 11px 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12px; }
.toast[data-kind="error"] { border-left-color: var(--danger); }

@media (max-width: 820px) {
  .workspace { grid-template-rows: auto 1fr; }
  .topbar { min-height: 60px; padding: 12px 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .connection-status { order: 3; width: 100%; justify-content: flex-end; }
  .workspace-body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .mount-list { display: flex; overflow-x: auto; margin: 8px 0 12px; padding-bottom: 2px; }
  .mount-button { width: auto; min-width: max-content; }
  .sidebar-section-heading, .folder-tree, .sidebar-footer { display: none; }
  .main-panel { padding: 26px 16px 36px; }
  .main-heading-actions { width: 100%; justify-content: flex-end; }
  .file-table-head, .file-row { grid-template-columns: minmax(0, 1fr) 90px 68px; gap: 10px; }
  .file-table-head span:nth-child(3), .file-row .entry-meta.modified { display: none; }
  .file-table-head { padding: 0 12px; }
  .file-row { min-height: 58px; padding: 0 12px; }
  .row-actions { opacity: 1; }
  .row-action { width: 30px; overflow: hidden; padding: 0; font-size: 0; }
  .row-action::before { font-size: 14px; }
  .row-action.rename::before { content: "R"; }
  .row-action.delete::before { content: "x"; }
  .skeleton-row { grid-template-columns: minmax(0, 1fr) 90px; gap: 10px; }
  .skeleton-row span:nth-child(3) { display: none; }
}
@media (max-width: 480px) {
  .auth-panel { padding: 27px 22px; }
  .topbar-brand span { display: none; }
  .topbar-actions .secondary-button { font-size: 12px; }
  .main-heading { align-items: start; flex-direction: column; gap: 14px; }
  .main-heading-actions { width: 100%; }
  .main-heading-actions button { flex: 1; }
  .file-table-head, .file-row { grid-template-columns: minmax(0, 1fr) 68px; }
  .file-table-head span:nth-child(2), .file-row .entry-meta.size { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
