:root {
  --bg: #f7f6f2;
  --fg: #1a1a1a;
  --muted: #6a6a6a;
  --subtle: #8a8a8a;
  --border: #d9d5cb;
  --border-light: #e8e4da;
  --accent: #b45309;
  --accent-hover: #92400e;
  --card: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8vh 24px 6vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

header h1 {
  font-size: 2.25rem;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 1.05rem;
}

/* --- toolbar for authed users --- */
.home-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.home-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}
.home-identity strong { color: var(--fg); }
.logout-form { display: inline; margin: 0; padding: 0; }
.btn-link {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover { color: var(--accent); }

/* --- upload form (compact) --- */
#upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dropzone {
  position: relative;
  display: block;
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: #fff7ed;
}
.dropzone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.dropzone-inner {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dropzone-inner strong { font-size: 1rem; }
.dropzone-inner span { color: var(--muted); font-size: 0.88rem; }
.dropzone-inner .hint {
  margin-top: 4px;
  color: var(--accent);
  font-weight: 500;
  min-height: 1.1em;
}

.form-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-primary, .btn-secondary {
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.btn-secondary:hover { background: var(--card); }

/* --- doc list --- */
.doc-list-section h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.doc-count {
  background: var(--border);
  color: var(--fg);
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.doc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
}
.doc-item:hover {
  border-color: var(--accent);
  background: #fffcf6;
}
.doc-item-title {
  font-weight: 600;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item-meta {
  color: var(--muted);
  font-size: 0.82rem;
}
.open-badge {
  color: var(--accent);
  font-weight: 600;
}

.empty-state {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin: 4px 0; }
.empty-state .empty-hint { font-size: 0.88rem; color: var(--subtle); }
.empty-state strong { color: var(--fg); }

/* --- login gate (anonymous) --- */
.login-gate {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.login-gate p {
  margin: 0;
  color: var(--muted);
  max-width: 380px;
}
.btn-login {
  display: inline-block;
  margin-top: 4px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-login:hover { background: var(--accent-hover); }
