:root {
  color-scheme: light dark;
  --bg: #f8f8fa; --surface: #ffffff; --soft: #f4f4f5; --softer: #e9e9ec; --line: #e4e4e7;
  --text: #18181b; --muted: #71717a;
  --accent: #7c3aed; --accent-hover: #6d28d9; --accent-text: #6d28d9; --accent-soft: #f3efff; --on-accent: #ffffff;
  --danger: #dc2626; --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --icon-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7.5A2.5 2.5 0 0 1 5.5 5H9l2 2.5h7.5A2.5 2.5 0 0 1 21 10v7.5a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 17.5z'/%3E%3C/svg%3E"); --icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5z'/%3E%3Cpath d='M13.5 3v5.5H19'/%3E%3C/svg%3E"); --icon-drive: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 13.5h17'/%3E%3Cpath d='M3.5 13.5 6 6.2A1.8 1.8 0 0 1 7.7 5h8.6a1.8 1.8 0 0 1 1.7 1.2l2.5 7.3v4.7a1.8 1.8 0 0 1-1.8 1.8H5.3a1.8 1.8 0 0 1-1.8-1.8z'/%3E%3Cpath d='M7.5 16.8h.01'/%3E%3C/svg%3E"); --icon-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15.5V4.5'/%3E%3Cpath d='M7.5 9 12 4.5 16.5 9'/%3E%3Cpath d='M4.5 15.5v2a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-2'/%3E%3C/svg%3E"); --icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E"); --icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='M6 13l6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d; --surface: #18181b; --soft: #232327; --softer: #2f2f34; --line: #2a2a2f;
    --text: #f4f4f5; --muted: #a1a1aa;
    --accent: #7c3aed; --accent-hover: #8b5cf6; --accent-text: #c4b5fd; --accent-soft: rgb(139 92 246 / 0.16);
    --danger: #f87171; --danger-soft: rgb(248 113 113 / 0.12);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, system-ui, sans-serif;
       -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--ring); }
a:focus-visible { border-radius: 4px; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 16px; overflow-wrap: anywhere; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

header { position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line);
         background: color-mix(in srgb, var(--surface) 85%, transparent);
         -webkit-backdrop-filter: saturate(1.6) blur(12px); backdrop-filter: saturate(1.6) blur(12px); }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 1040px; margin: 0 auto;
       padding: 10px 20px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand::before { content: ""; width: 22px; height: 22px; background: var(--accent);
                 -webkit-mask: var(--icon-folder) center / contain no-repeat; mask: var(--icon-folder) center / contain no-repeat; }
.account { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
          background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.user { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }
main.narrow { max-width: 420px; padding-top: max(24px, 10vh); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; }
.card > p { margin: 0 0 8px; }
.card > p:last-child { margin-bottom: 0; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
                  border: 0; border-radius: 10px; background: var(--soft); color: var(--text); font: inherit; font-size: 14px;
                  font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
                  transition: background-color 0.15s, color 0.15s, transform 0.1s; }
button:hover, .button:hover { background: var(--softer); text-decoration: none; }
button:active, .button:active { transform: scale(0.97); }
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); }
.quiet { background: none; color: var(--muted); }
.quiet:hover { background: var(--soft); color: var(--text); }
.danger { color: var(--danger); }
.danger:hover { background: var(--danger-soft); }
.upload::before, .new-folder::before { content: ""; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.upload { --icon: var(--icon-upload); position: relative; }
.new-folder { --icon: var(--icon-plus); }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.upload:focus-within { box-shadow: var(--ring); }
.upload:has(input:disabled) { opacity: 0.6; cursor: progress; }

.login { display: grid; gap: 16px; margin-top: 8px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.login input { width: 100%; height: 44px; padding: 0 14px; border: 2px solid transparent; border-radius: 12px; background: var(--soft);
               color: var(--text); font: inherit; transition: border-color 0.15s, background-color 0.15s; }
.login input:hover { background: var(--softer); }
.login input:focus { outline: none; box-shadow: none; border-color: var(--accent); background: var(--surface); }
.login button { height: 44px; margin-top: 4px; font-size: 15px; }
.error { margin: 0 0 4px; padding: 10px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }

.shares { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.shares a { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px;
            background: var(--surface); box-shadow: var(--shadow); color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.shares a:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.shares a::before { content: ""; flex: none; width: 22px; height: 22px; background: var(--muted);
                    -webkit-mask: var(--icon-drive) center / contain no-repeat; mask: var(--icon-drive) center / contain no-repeat; }
.shares .label { flex: 1; min-width: 0; font-weight: 600; }
.chip { flex: none; padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 500; }

nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-bottom: 6px; font-size: 14px; }
nav a { color: var(--muted); }
nav a:hover { color: var(--text); }
nav a[aria-current] { color: var(--text); font-weight: 500; }
nav .sep { color: var(--muted); opacity: 0.5; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
#progress { list-style: none; padding: 0; margin: 0; flex-basis: 100%; display: grid; gap: 6px; font-size: 13px; }
#progress:empty { display: none; }
#progress li { padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
               overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#progress .failed { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.list { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; vertical-align: middle; }
th { background: var(--soft); font-size: 12px; font-weight: 600; color: var(--muted); }
th button { height: auto; padding: 0; background: none; border-radius: 4px; color: inherit; font-size: inherit; font-weight: inherit; gap: 4px; }
th button:hover { background: none; color: var(--text); }
th[aria-sort] button { color: var(--accent-text); }
th[aria-sort] button::after { content: ""; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: var(--icon-arrow) center / contain no-repeat; mask: var(--icon-arrow) center / contain no-repeat; }
th[aria-sort="ascending"] button::after { transform: rotate(180deg); }
td { border-top: 1px solid var(--line); }
tbody tr { transition: background-color 0.1s; }
tbody tr:hover { background: color-mix(in srgb, var(--soft) 60%, transparent); }
td.name a { display: flex; align-items: flex-start; gap: 10px; color: var(--text); font-weight: 500; }
td.name a:hover { color: var(--accent-text); }
td.name a::before { content: ""; flex: none; width: 20px; height: 20px; margin-top: 1px; background: var(--muted);
  -webkit-mask: var(--icon-file) center / contain no-repeat; mask: var(--icon-file) center / contain no-repeat; }
tr[data-folder="1"] td.name a::before { background: var(--text);
  -webkit-mask-image: var(--icon-folder); mask-image: var(--icon-folder); }
td.size, td.modified { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .button, td.actions button { height: 30px; padding: 0 10px; font-size: 13px; background: none; }
td.actions .button:hover, td.actions button:hover { background: var(--soft); }
td.actions .danger:hover { background: var(--danger-soft); }
.empty { margin: 0; padding: 40px 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }

@media (max-width: 600px) {
  .bar { padding: 8px 16px; }
  .user { display: none; }
  main { padding: 16px 16px 40px; }
  h1 { font-size: 21px; }
  /* Each row becomes two lines: the name across the card, then the size and the actions. */
  table, thead, tbody { display: block; }
  thead tr { display: flex; gap: 20px; padding: 0 14px; background: var(--soft); }
  th { padding: 10px 0; background: none; }
  th:nth-child(3), td.modified, th:last-child { display: none; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 10px 8px 6px 14px;
             border-top: 1px solid var(--line); }
  td { padding: 0; border-top: 0; }
  td.name { grid-column: 1 / -1; }
  td.size { padding-left: 30px; font-size: 13px; }
  td.actions .button, td.actions button { height: 32px; padding: 0 8px; }
  .shares { grid-template-columns: 1fr; }
}