:root {
  --blue: #1a73e8;
  --blue-dark: #1765cc;
  --blue-light: #e8f0fe;
  --grey-bg: #f6f8fc;
  --grey-line: #e0e3e7;
  --grey-text: #5f6368;
  --text: #202124;
  --danger: #d93025;
  --shadow: 0 1px 3px rgba(60,64,67,.15), 0 1px 2px rgba(60,64,67,.1);
  --radius: 12px;
  font-family: "Google Sans", Roboto, -apple-system, "Segoe UI", system-ui, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: #fff;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
button { font-family: inherit; cursor: pointer; }

/* ---------- Auth pages (login / setup) ---------- */
.auth-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--grey-bg); padding: 24px;
}
.auth-card {
  background: #fff; width: 100%; max-width: 420px;
  border: 1px solid var(--grey-line); border-radius: 28px;
  padding: 40px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #1a73e8, #34a853); flex: none;
  display: grid; place-items: center; color: #fff; font-size: 22px;
}
.brand h1 { font-size: 22px; font-weight: 500; margin: 0; }
.auth-card p.sub { color: var(--grey-text); margin: 6px 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--grey-text); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid #cdd1d6; border-radius: 8px; outline: none;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: none;
  padding: 11px 24px; border-radius: 8px; font-size: 15px; font-weight: 500;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-light); }
.btn.danger { background: var(--danger); }
.msg { margin: 12px 0 0; font-size: 13px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: #188038; }
.qr { text-align: center; margin: 8px 0 4px; }
.qr img { width: 190px; height: 190px; border: 1px solid var(--grey-line); border-radius: 8px; }
.secret { font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--grey-bg); padding: 8px 10px; border-radius: 6px;
  word-break: break-all; font-size: 12px; color: var(--grey-text); }

/* ---------- App shell ---------- */
.topbar {
  height: 64px; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; border-bottom: 1px solid var(--grey-line); background: #fff;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand h1 { font-size: 20px; }
.menu-btn { display: none; background: transparent; border: none; font-size: 22px;
  color: var(--grey-text); padding: 6px 8px; border-radius: 50%; line-height: 1; }
.menu-btn:hover { background: var(--grey-bg); }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(32,33,36,.4); z-index: 45; }
.backdrop.show { display: block; }
.search {
  flex: 1; max-width: 720px; display: flex; align-items: center;
  background: var(--grey-bg); border-radius: 10px; padding: 0 14px; height: 44px;
}
.search input { flex: 1; border: none; background: transparent; outline: none;
  font-size: 15px; padding: 0 10px; color: var(--text); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--blue);
  color: #fff; display: grid; place-items: center; font-weight: 500; cursor: pointer;
}
.layout { display: flex; height: calc(100vh - 64px); }
.sidebar { width: 240px; padding: 16px 12px; border-right: 1px solid var(--grey-line); flex: none; }
.new-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: var(--text); border: 1px solid var(--grey-line);
  border-radius: 16px; padding: 12px 22px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.new-btn:hover { background: var(--grey-bg); }
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 9px 14px;
  border-radius: 0 20px 20px 0; color: var(--text); font-weight: 500; cursor: pointer;
}
.nav-item.active { background: var(--blue-light); color: var(--blue-dark); }
.nav-item:hover:not(.active) { background: var(--grey-bg); }
.quota { margin-top: 20px; padding: 0 14px; color: var(--grey-text); font-size: 12px; }
.quota .bar { height: 4px; background: var(--grey-line); border-radius: 2px; margin: 8px 0 6px; overflow: hidden; }
.quota .bar > i { display: block; height: 100%; background: var(--blue); }

.main { flex: 1; overflow: auto; padding: 20px 28px; position: relative; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.crumbs .c { cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.crumbs .c:hover { background: var(--grey-bg); }
.crumbs .sep { color: var(--grey-text); font-size: 18px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin: 14px 0; color: var(--grey-text); }
.toolbar .spacer { flex: 1; }
.icon-btn { background: transparent; border: none; padding: 8px; border-radius: 50%; color: var(--grey-text); }
.icon-btn:hover { background: var(--grey-bg); }
.icon-btn.active { color: var(--blue); }

/* grid view */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card {
  border: 1px solid var(--grey-line); border-radius: var(--radius); background: #fff;
  padding: 14px; cursor: pointer; user-select: none; transition: box-shadow .1s, background .1s;
}
.card:hover { background: var(--grey-bg); }
.card.sel { background: var(--blue-light); border-color: var(--blue); }
.card .row { display: flex; align-items: center; gap: 10px; }
.card .ficon { font-size: 22px; flex: none; }
.card .fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.more { flex: none; background: transparent; border: none; color: var(--grey-text);
  font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 50%; opacity: 0; }
.card:hover .more, .list tr:hover .more, .more:focus { opacity: 1; }
.more:hover { background: rgba(0,0,0,.06); }
.list .nm .more { margin-left: auto; }
.card .thumb { margin-top: 12px; height: 120px; border-radius: 8px; background: var(--grey-bg);
  display: grid; place-items: center; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb .big { font-size: 52px; color: #9aa0a6; }
.card .meta { margin-top: 8px; font-size: 12px; color: var(--grey-text); }

/* list view */
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-weight: 500; color: var(--grey-text); font-size: 12px;
  border-bottom: 1px solid var(--grey-line); padding: 10px 12px; }
.list td { padding: 10px 12px; border-bottom: 1px solid var(--grey-line); }
.list tr { cursor: pointer; }
.list tr:hover td { background: var(--grey-bg); }
.list tr.sel td { background: var(--blue-light); }
.list .nm { display: flex; align-items: center; gap: 12px; font-weight: 500; }

.empty { text-align: center; color: var(--grey-text); padding: 80px 20px; }
.empty .big { font-size: 64px; }

/* context menu */
.ctx { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--grey-line);
  border-radius: 8px; box-shadow: var(--shadow); padding: 6px 0; min-width: 200px; }
.ctx .item { padding: 9px 16px; display: flex; align-items: center; gap: 12px; }
.ctx .item:hover { background: var(--grey-bg); }
.ctx .item.danger { color: var(--danger); }
.ctx .sep { height: 1px; background: var(--grey-line); margin: 6px 0; }

/* drop overlay */
.drop-overlay {
  position: absolute; inset: 12px; border: 3px dashed var(--blue); border-radius: 16px;
  background: rgba(232,240,254,.75); display: none; place-items: center; z-index: 40;
  font-size: 20px; color: var(--blue-dark); font-weight: 500; pointer-events: none;
}
.drop-overlay.show { display: grid; }

/* uploads toast */
.uploads {
  position: fixed; right: 24px; bottom: 24px; width: 340px; background: #fff;
  border: 1px solid var(--grey-line); border-radius: 10px; box-shadow: var(--shadow);
  z-index: 50; overflow: hidden; display: none;
}
.uploads.show { display: block; }
.uploads header { background: #202124; color: #fff; padding: 12px 16px; font-size: 14px; font-weight: 500; }
.uploads .u { padding: 10px 16px; border-bottom: 1px solid var(--grey-line); font-size: 13px; }
.uploads .u .n { display: flex; justify-content: space-between; gap: 8px; }
.uploads .u .b { height: 4px; background: var(--grey-line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.uploads .u .b > i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .15s; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(32,33,36,.5); display: none;
  place-items: center; z-index: 70; }
.modal-bg.show { display: grid; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 16px; font-weight: 500; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* menu popover (avatar) */
.pop { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--grey-line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0; min-width: 180px; display: none; }
.pop.show { display: block; }
.pop .item { padding: 10px 16px; }
.pop .item:hover { background: var(--grey-bg); }
.hidden { display: none !important; }

/* ---------- Mobile / responsive ---------- */
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .topbar { gap: 10px; padding: 0 10px; }
  .topbar .brand h1 { display: none; }         /* keep just the logo to save room */
  .search { height: 40px; padding: 0 10px; }

  /* Sidebar becomes a slide-in drawer */
  .layout { height: auto; min-height: calc(100vh - 64px); }
  .sidebar {
    position: fixed; top: 64px; bottom: 0; left: 0; width: 260px; z-index: 46;
    background: #fff; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,.2); overflow-y: auto;
  }
  .sidebar.open { transform: none; }

  .main { padding: 14px; height: auto; }
  .crumbs { font-size: 17px; overflow-x: auto; white-space: nowrap; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .card .thumb { height: 96px; }

  /* touch targets: always show the ⋮ button on touch devices */
  .more { opacity: 1; padding: 6px 8px; font-size: 20px; }

  /* list view: drop the Modified column on small screens */
  .list th:nth-child(3), .list td:nth-child(3) { display: none; }

  .uploads { left: 12px; right: 12px; width: auto; bottom: 12px; }
  .modal { margin: 16px; }
  .ctx { min-width: 220px; }
  .ctx .item { padding: 12px 16px; }          /* bigger tap targets */
}

@media (max-width: 400px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .search input::placeholder { color: transparent; }  /* icon-only search on tiny screens */
}
