:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --border: #d8dee4;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --danger: #cf222e;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  padding: 16px;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  text-align: center;
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.btn-google {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}
.layout:has(.detail:not(.hidden)) {
  grid-template-columns: 240px 1fr 300px;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.brand { font-weight: 600; font-size: 16px; padding: 0 8px; }

#views { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.nav-item:hover { background: #ebeef1; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.quota { margin-top: auto; padding: 0 8px; }
.quota-bar {
  height: 6px;
  background: #dde1e5;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
#quota-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.user-box { display: flex; gap: 8px; align-items: center; padding: 0 8px; }
.user-box img { border-radius: 50%; background: #ddd; }
.user-meta { min-width: 0; }
.user-meta > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions { display: flex; gap: 12px; padding: 0 8px; }
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--accent); cursor: pointer; font-size: 12px;
}
.link-btn.danger { color: var(--danger); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.search { display: flex; gap: 6px; flex: 1; min-width: 240px; }
.search input { flex: 1; min-width: 0; }

input, select, button {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
button { cursor: pointer; }
button:hover { background: var(--bg-soft); }

.breadcrumb {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  min-height: 42px;
}
.crumb {
  background: none; border: 0; padding: 4px 6px;
  color: var(--accent); cursor: pointer; border-radius: 4px;
}
.crumb:hover { background: var(--accent-soft); }
.crumb.current { color: var(--text); font-weight: 500; cursor: default; }
.crumb.current:hover { background: none; }
.crumb-sep { color: var(--muted); }

.status { padding: 12px 16px; color: var(--muted); }
.status.is-error { color: var(--danger); }

.table-wrap { flex: 1; overflow-y: auto; }

table.files { width: 100%; border-collapse: collapse; }
table.files th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
table.files td {
  padding: 8px 16px;
  border-bottom: 1px solid #eef1f3;
  vertical-align: middle;
}
table.files tbody tr:hover { background: var(--bg-soft); }

.col-size, .col-date, .col-owner { width: 1%; white-space: nowrap; }
.col-act { width: 1%; }

.name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name-cell img { width: 16px; height: 16px; flex: none; }
.name-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--text); cursor: pointer; text-align: left;
}
.name-text:hover { text-decoration: underline; }
.badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #eef1f3;
  color: var(--muted);
  flex: none;
}

.row-actions { display: flex; gap: 4px; }
.icon-btn {
  padding: 3px 8px;
  font-size: 12px;
}

.load-more-wrap { padding: 12px 16px; text-align: center; }

/* ---------- detail ---------- */
.detail {
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  position: relative;
  background: var(--bg-soft);
}
.detail .close {
  position: absolute; top: 8px; right: 8px;
  border: 0; background: none; font-size: 20px; line-height: 1;
  padding: 4px 8px; color: var(--muted);
}
.detail h3 { margin: 24px 0 12px; font-size: 15px; word-break: break-word; }
.detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; }
.detail dt { color: var(--muted); font-size: 12px; }
.detail dd { margin: 0; font-size: 12px; word-break: break-word; }
.detail .thumb {
  width: 100%; border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 12px; display: block; background: #fff;
}
.detail .export-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

@media (max-width: 860px) {
  .layout, .layout:has(.detail:not(.hidden)) { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .col-owner, .col-date { display: none; }
  .detail {
    position: fixed; inset: 0; z-index: 10; border: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --accent-soft: #15314f;
    --danger: #f85149;
  }
  :root:not([data-theme="light"]) .nav-item:hover { background: #21262d; }
  :root:not([data-theme="light"]) table.files td { border-bottom-color: #21262d; }
  :root:not([data-theme="light"]) .quota-bar { background: #30363d; }
  :root:not([data-theme="light"]) .badge { background: #21262d; }
}
