:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef4f1;
  --border: #d8dde3;
  --text: #17202a;
  --muted: #667085;
  --brand: #1b6f6a;
  --brand-strong: #13514e;
  --accent: #d9822b;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(26, 33, 45, 0.08);
}

* {
  box-sizing: border-box;
}

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;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: #101828;
  color: #f8fafc;
}

.brand,
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  min-height: 44px;
  font-size: 19px;
  font-weight: 750;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #1b6f6a;
  color: #ffffff;
  flex: 0 0 auto;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a,
.storage-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
}

.side-nav a {
  color: #cbd5e1;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.storage-badge {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #dbe4ee;
  font-size: 13px;
}

.drive-main {
  min-width: 0;
  padding: 24px;
}

.settings-main {
  max-width: 1100px;
}

.settings-main h1,
.settings-card h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
}

.settings-card {
  margin-top: 26px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-intro {
  display: flex;
  gap: 14px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.settings-intro > svg { color: var(--brand); flex: 0 0 auto; }
.settings-intro p, .settings-footer p { margin: 6px 0 0; color: var(--muted); }
.settings-form { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; color: var(--text); background: var(--surface); }
.form-grid textarea { width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 8px; padding: 12px; color: var(--text); background: var(--surface); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.45; }
.optional { color: #98a2b3; font-weight: 500; }
.settings-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-footer p { margin: 0; font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  gap: 16px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs a:hover {
  color: var(--brand);
}

.breadcrumbs span {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.flash-stack {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flash.success {
  border-color: #a7d7c5;
  background: #effaf5;
}

.flash.error {
  border-color: #f3b5ae;
  background: #fff3f1;
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(240px, 420px) minmax(260px, 1fr);
  gap: 12px;
  align-items: center;
  margin: 18px 0 20px;
}

.upload-form,
.folder-form,
.search-form {
  min-width: 0;
}

.folder-form,
.search-form {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.folder-form input,
.search-form input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.folder-form input {
  padding: 0 12px;
}

.search-form {
  padding: 0 12px;
  gap: 8px;
}

.search-form input::placeholder,
.folder-form input::placeholder {
  color: #98a2b3;
}

.primary-action,
.secondary-action,
.icon-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-action {
  background: var(--brand);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--brand-strong);
}

.secondary-action {
  border-left: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}

.secondary-action:hover {
  background: #dfeee9;
}

.icon-button {
  width: 36px;
  height: 36px;
  background: #edf2f7;
  color: #344054;
}

.icon-button:hover {
  background: #e2e8f0;
}

.icon-button.ghost {
  background: transparent;
}

.icon-button.ghost:hover {
  background: #eef2f6;
}

.icon-button.danger {
  background: transparent;
  color: var(--danger);
}

.icon-button.danger:hover {
  background: #fee4e2;
}

.file-surface {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.file-surface.is-dragging {
  border-color: var(--brand);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-items: center;
  align-content: center;
  gap: 10px;
  background: rgba(246, 247, 249, 0.88);
  color: var(--brand-strong);
  font-size: 20px;
  font-weight: 800;
  pointer-events: none;
}

.file-surface.is-dragging .drop-overlay {
  display: grid;
}

.drop-overlay svg {
  width: 34px;
  height: 34px;
}

.file-header,
.file-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 128px 180px 132px;
  gap: 16px;
  align-items: center;
}

.file-header {
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.file-row {
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid #edf0f3;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: #fafbfc;
}

.file-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 650;
}

.file-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex: 0 0 auto;
}

.file-icon.folder {
  background: #fff1d6;
  color: #a15c07;
}

.file-icon.file {
  background: #e6f4f1;
  color: var(--brand);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.row-actions form {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
}

.empty-state p {
  margin: 0;
}

.preview-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.preview-surface {
  min-height: calc(100vh - 118px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-surface iframe {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 120px);
  border: 0;
  background: #ffffff;
}

.preview-surface.image {
  display: grid;
  place-items: center;
  padding: 18px;
  background: #202734;
}

.preview-surface.image img {
  max-width: 100%;
  max-height: calc(100vh - 156px);
  border-radius: 8px;
  object-fit: contain;
}

.rename-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 22px 70px rgba(16, 24, 40, 0.24);
}

.rename-dialog::backdrop {
  background: rgba(16, 24, 40, 0.48);
}

.rename-dialog form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.rename-dialog h2 {
  margin: 0;
  font-size: 20px;
}

.rename-dialog label,
.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dialog-copy {
  margin: -6px 0 0;
  color: var(--text);
  font-weight: 700;
  word-break: break-word;
}

.rename-dialog input,
.rename-dialog select,
.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.login-screen {
  grid-column: 1 / -1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.share-surface {
  display: grid;
  gap: 22px;
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.share-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.share-heading h1,
.share-heading p {
  margin: 0;
}

.share-heading h1 {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.share-heading p,
.share-meta {
  color: var(--muted);
}

.share-link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.share-link-box textarea {
  width: 100%;
  min-width: 0;
  min-height: 104px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  resize: vertical;
  word-break: break-all;
}

.share-open-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--brand);
  font-weight: 750;
}

.share-open-link:hover {
  color: var(--brand-strong);
}

.share-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  font-size: 24px;
}

.brand-block p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
  }

  .side-nav {
    display: none;
  }

  .storage-badge {
    margin-left: auto;
    margin-top: 0;
  }

  .drive-main {
    padding: 16px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .upload-form .primary-action {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .breadcrumbs {
    flex-wrap: wrap;
  }

  .file-header {
    display: none;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name actions"
      "size actions"
      "modified actions";
    gap: 4px 10px;
    min-height: 76px;
    padding: 10px 12px;
  }

  .file-name {
    grid-area: name;
  }

  .file-row > .muted:nth-of-type(1) {
    grid-area: size;
    padding-left: 46px;
  }

  .file-row > .muted:nth-of-type(2) {
    grid-area: modified;
    padding-left: 46px;
  }

  .row-actions {
    grid-area: actions;
  }

  .storage-badge span {
    display: none;
  }

  .share-link-box {
    grid-template-columns: 1fr;
  }

  .preview-surface,
  .preview-surface iframe {
    min-height: calc(100vh - 136px);
  }
}
