/* Palette mirrors the hosted files' own dark/light variables so the chrome
   feels like part of the same app. Dark is the default; [data-theme="light"]
   (set by the nav toggle / shared localStorage) swaps the tokens. */
:root {
  --bg: #18181b;
  --surface: #26272b;
  --surface-2: #1f2023;
  --border: rgba(255, 255, 255, 0.09);
  --hover: rgba(255, 255, 255, 0.06);
  --text: #e8e8ea;
  --text-dim: #9a9ba1;
  --accent: #4e9733;
  --accent-hover: #5aa83d;
  --danger: #e2564e;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --border: rgba(0, 0, 0, 0.10);
  --hover: rgba(0, 0, 0, 0.05);
  --text: #1a1d21;
  --text-dim: #5b6067;
  --accent: #4e9733;
  --accent-hover: #457f2f;
  --danger: #cf2b2b;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.10);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--accent); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  height: 52px; padding: 0 1rem;
  background: var(--surface-2); color: var(--text);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 600; color: var(--text); text-decoration: none; }
.topbar > span { color: var(--text-dim); font-size: .9rem; }
.hamburger { font-size: 1.4rem; cursor: pointer; user-select: none; line-height: 1; color: var(--text); }

/* Theme toggle pill */
.theme-toggle {
  margin-left: auto; width: 46px; height: 26px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); position: relative; cursor: pointer; padding: 0;
}
.theme-toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); transition: left .2s ease;
}
.theme-toggle[aria-pressed="false"] .theme-toggle-thumb { left: 22px; background: var(--text-dim); }

/* Drawer: off-canvas on mobile */
.drawer {
  position: fixed; top: 0; left: 0; z-index: 20;
  width: 78%; max-width: 300px; height: 100%;
  background: var(--surface-2); color: var(--text);
  border-right: 1px solid var(--border); padding: 1rem;
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.nav-toggle:checked ~ .drawer { transform: translateX(0); }

.scrim {
  position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.nav-toggle:checked ~ .scrim { opacity: 1; pointer-events: auto; }

.nav { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.nav li a {
  display: block; padding: .55rem .65rem; margin-bottom: .15rem;
  color: var(--text-dim); text-decoration: none; border-radius: 8px;
  font-size: .93rem; border-left: 3px solid transparent;
}
.nav li a:hover { background: var(--hover); color: var(--text); }
.nav li a.active {
  background: var(--hover); color: var(--text);
  border-left-color: var(--accent); font-weight: 600;
}
.nav li.empty { color: var(--text-dim); padding: .55rem .65rem; font-size: .9rem; }
.drawer-foot {
  border-top: 1px solid var(--border); padding-top: .8rem; margin-top: .5rem;
  display: flex; gap: 1.2rem;
}
.drawer-foot a { color: var(--accent); text-decoration: none; font-size: .92rem; }

.content { position: absolute; top: 52px; left: 0; right: 0; bottom: 0; background: var(--bg); }
.page-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.placeholder { padding: 2rem; color: var(--text-dim); }

/* Desktop: pin drawer open, offset content */
@media (min-width: 768px) {
  .hamburger, .scrim { display: none; }
  .drawer { transform: none; width: 260px; }
  .content { left: 260px; }
}

/* Shared form controls */
input, select, button, .google-btn {
  font: inherit; border-radius: 8px;
}
input, select {
  padding: .6rem .7rem; background: var(--bg);
  border: 1px solid var(--border); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  padding: .55rem .9rem; cursor: pointer; border: 0;
  background: var(--accent); color: #fff; font-weight: 600;
}
button:hover { background: var(--accent-hover); }

/* Login */
.login {
  max-width: 360px; margin: 10vh auto; padding: 2rem 1.75rem; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 1.25rem; font-size: 1.6rem; }
.login-form { display: flex; flex-direction: column; gap: .6rem; }
.login-form button { padding: .7rem; }
.google-btn {
  display: block; padding: .7rem; text-decoration: none;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.google-btn:hover { border-color: var(--accent); }
.or { margin: 1rem 0; color: var(--text-dim); font-size: .85rem; }
.error {
  color: var(--danger); background: var(--hover);
  border-radius: 8px; padding: .5rem; margin: 0 0 .75rem; font-size: .9rem;
}

/* Admin */
.admin { max-width: 780px; margin: 1.5rem auto; padding: 0 1rem 3rem; }
.admin section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.1rem 1.3rem; margin: 1.1rem 0;
}
.admin h2 { margin: 0 0 .9rem; font-size: 1.05rem; }
.admin table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin th {
  text-align: left; padding: .5rem; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-dim); border-bottom: 1px solid var(--border);
}
.admin td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); }
.admin .inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.admin .inline input, .admin .inline select { flex: 1 1 auto; min-width: 160px; }
.admin .danger {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); padding: .35rem .7rem; font-weight: 500;
}
.admin .danger:hover { background: var(--danger); color: #fff; }

/* Upload as a drop-zone look */
.upload {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  border: 1.5px dashed var(--border); border-radius: 10px;
  padding: 1rem; background: var(--bg);
}
.upload input[type=file] { flex: 1 1 auto; color: var(--text-dim); border: 0; background: transparent; }
.upload input[type=file]::file-selector-button {
  font: inherit; margin-right: .7rem; padding: .45rem .8rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}

.banner {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: .7rem .9rem; border-radius: 8px; margin: .5rem 0; font-size: .92rem;
}
.banner code { word-break: break-all; color: var(--accent); }
