:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f6f7f9;
  --panel-2: #ffffff;
  --line: #dfe3e8;
  --text: #1c2024;
  --muted: #646b75;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --danger: #d1242f;
  --ok: #1a7f37;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
img, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

header.top {
  display: flex; align-items: center; gap: 12px; padding: 12px max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.92);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 26px; height: 26px; flex: none; }
header.top nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }
header.top nav .button { white-space: nowrap; }

main {
  width: 100%; max-width: 1280px; margin: 0 auto; flex: 1;
  padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
}
main.narrow { max-width: 760px; }
footer.bottom { color: var(--muted); font-size: 13px; text-align: center; padding: 24px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
footer.bottom a { color: var(--muted); }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--ok); }

button, .button {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .button:hover { border-color: #b8c0ca; background: var(--panel); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.button.sign-in { padding: 9px 18px; font-weight: 600; box-shadow: 0 1px 3px rgba(37, 99, 235, 0.35); }
.button.docs { padding: 9px 16px; font-weight: 600; }
.button.docs[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.55; cursor: default; }

input[type=text], input[type=search], input[type=number], textarea, select {
  font: inherit; width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(37, 99, 235, 0.35); border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }

/* File browser */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 20px; font-weight: 600; margin-bottom: 16px; overflow-wrap: anywhere; }
.crumbs a { color: var(--accent); }
.crumbs .sep { color: var(--muted); font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1 1 220px; max-width: 360px; }
.owner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
table.files { width: 100%; border-collapse: collapse; font-size: 14px; }
table.files th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.files td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.files tbody tr:hover { background: var(--panel); }
table.files td.name { overflow-wrap: anywhere; }
table.files td.name a { color: var(--text); display: inline-flex; gap: 10px; align-items: center; }
table.files td.name a:hover { color: var(--accent); }
table.files .icon { width: 22px; text-align: center; flex: none; }
table.files .size, table.files .date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
table.files td.actions .row { justify-content: flex-end; flex-wrap: nowrap; gap: 6px; }
table.files td.actions button, table.files td.actions .button { padding: 4px 10px; font-size: 13px; }
@media (hover: hover) {
  table.files td.actions .row { opacity: 0.35; transition: opacity 0.15s; }
  table.files tr:hover td.actions .row, table.files td.actions .row:focus-within { opacity: 1; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 13px; }
.uploads { margin: 0 0 18px; }
.uploads strong { overflow-wrap: anywhere; }
.upload-log { margin: 8px 0 0; padding-left: 18px; font-size: 13px; max-height: 180px; overflow: auto; }
.upload-log:empty { display: none; }
.drop-hint { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }
body.dragging main { outline: 3px dashed var(--accent); outline-offset: -8px; border-radius: var(--radius); background: rgba(37, 99, 235, 0.04); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--panel-2);
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.progress { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* Phones and small tablets */
@media (max-width: 640px) {
  header.top { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  main { padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); }
  .crumbs { font-size: 18px; }
  .toolbar input[type=search] { max-width: none; }
  .owner-actions { margin-left: 0; }
  table.files .date, table.files th.date { display: none; }
  table.files td.actions .row { flex-wrap: wrap; }
  .panel { padding: 14px; }
}
@media (max-width: 400px) {
  .brand .name { display: none; }
  table.files .size, table.files th.size { display: none; }
}
/* Touch screens: bigger targets, and 16px text so iOS doesn't zoom into fields */
@media (pointer: coarse) {
  button, .button { min-height: 44px; }
  table.files td.actions button, table.files td.actions .button { min-height: 36px; }
  input[type=text], input[type=search] { font-size: 16px; }
}
@media (min-width: 1600px) {
  main { max-width: 1520px; }
}
