:root {
  --canvas: #f6f8fb;
  --panel: #ffffff;
  --text: #102033;
  --muted: #526173;
  --border: #d7e1e9;
  --accent: #0b6774;
  --accent-text: #ffffff;
  --accent-soft: #e3f3f4;
  --bad: #b91c1c;
  --warn: #b45309;
  --mail: #6d28d9;
  --files: #0b6774;
  --versions: #0e7490;
  --trash: #94a3b8;
  --focus: #f59e0b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0b1422;
    --panel: #111c2e;
    --text: #e6edf5;
    --muted: #a3b1c2;
    --border: #34465c;
    --accent: #5eead4;
    --accent-text: #062a2f;
    --accent-soft: #123a40;
    --bad: #f87171;
    --warn: #fbbf24;
    --mail: #a78bfa;
    --files: #5eead4;
    --versions: #2dd4bf;
    --trash: #64748b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--canvas);
  color: var(--text);
}

a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; background: var(--panel); padding: 8px 12px; }

button, .button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

button:hover, .button:hover { border-color: var(--accent); }

button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

input, select {
  font: inherit;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }

.search { flex: 1; max-width: 560px; }
.search input { width: 100%; }

.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }

body.signed-out .search, body.signed-out .who, body.signed-out .side { display: none; }

.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 61px); }
body.signed-out .layout { grid-template-columns: 1fr; }

.side { padding: 16px; border-right: 1px solid var(--border); background: var(--panel); }

nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 24px; }
nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
nav a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.storage h2 { font-size: 0.95rem; margin: 0 0 8px; }
.bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--border); }
.bar span { display: block; height: 100%; }
.bar .mail, .legend .mail::before { background: var(--mail); }
.bar .files, .legend .files::before { background: var(--files); }
.bar .versions, .legend .versions::before { background: var(--versions); }
.bar .trash, .legend .trash::before { background: var(--trash); }
.legend { list-style: none; padding: 0; margin: 8px 0; font-size: 0.9rem; color: var(--muted); }
.legend li::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.hint { color: var(--muted); font-size: 0.9rem; }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

main { padding: 20px 24px 96px; min-width: 0; }
main:focus { outline: none; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; font-size: 1.1rem; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.list { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 110px 48px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
}
.list .row:first-child { border-top: 0; }
.row.head { color: var(--muted); font-size: 0.85rem; border: 0; padding: 0 16px 4px; }
.row .when, .row .size { color: var(--muted); font-size: 0.9rem; }

.name {
  border: 0;
  background: none;
  justify-content: flex-start;
  min-width: 0;
  text-align: left;
}
.name span:not(.icon):not(.tag) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon { width: 22px; height: 22px; flex: none; border-radius: 4px; background: var(--muted); }
.icon.folder { background: var(--accent); clip-path: polygon(0 18%, 40% 18%, 50% 30%, 100% 30%, 100% 100%, 0 100%); }
.icon.file { clip-path: polygon(0 0, 70% 0, 100% 30%, 100% 100%, 0 100%); }

.tag { font-size: 0.75rem; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.tag.bad { background: transparent; border: 1px solid var(--bad); color: var(--bad); }

.more { position: relative; }
.dots { min-width: 40px; justify-content: center; letter-spacing: 1px; }
.menu {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.menu[hidden] { display: none; }
.menu button { border: 0; justify-content: flex-start; }

.empty { color: var(--muted); padding: 24px 0; }
.load-more { margin-top: 12px; }

.drop.over { outline: 3px dashed var(--accent); outline-offset: 6px; border-radius: 10px; }

dialog.box {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 20px;
}
dialog.box.wide { width: min(960px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin-top: 0; }
dialog label { display: flex; flex-direction: column; gap: 6px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.picker { list-style: none; padding: 0; max-height: 50vh; overflow: auto; }
.picker li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.picker li:first-child { border-top: 0; }
.picker .link input { flex: 1; min-width: 200px; }

.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.share h3 { margin-bottom: 8px; }

.preview { display: flex; justify-content: center; }
.preview img, .preview video { max-width: 100%; max-height: 70vh; }
.preview iframe { width: 100%; height: 70vh; border: 0; }
.preview pre { width: 100%; max-height: 70vh; overflow: auto; white-space: pre-wrap; }

.uploads {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: 50vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
  padding: 12px 16px;
}
.uploads-head { display: flex; justify-content: space-between; align-items: center; }
.uploads h2 { margin: 0; font-size: 1rem; }
.uploads ul { list-style: none; padding: 0; margin: 8px 0 0; }
.uploads li { display: grid; gap: 2px; padding: 6px 0; border-top: 1px solid var(--border); }
.uploads li.bad .hint { color: var(--bad); }
.uploads progress { width: 100%; }

.status { position: fixed; left: 16px; bottom: 16px; margin: 0; max-width: calc(100vw - 32px); }
.status:not(:empty) { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; }

.welcome { max-width: 560px; margin: 10vh auto; text-align: center; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 16px 0 32px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card h2, .card h3 { margin-top: 0; font-size: 1.05rem; }
.imports { list-style: none; padding: 0; display: grid; gap: 12px; }

.message main, .share-main { max-width: 900px; margin: 0 auto; }
.share-foot { text-align: center; padding: 24px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  nav { flex-direction: row; flex-wrap: wrap; margin-bottom: 12px; }
  .storage .legend, .storage .hint { display: none; }
  .top { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  main { padding: 16px 16px 120px; }
  .row { grid-template-columns: minmax(0, 1fr) 48px; }
  .row .when, .row .size, .row.head { display: none; }
}
