:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --input-bg: #0f172a;
}

html[data-theme="light"] {
  --bg: #f8fafc;
  --card: #ffffff;
  --card-border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --input-bg: #f1f5f9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-wrap: break-word;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 10px;
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.brand-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

.nav-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  text-decoration: none;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-icon-link:hover { color: var(--text); }
.nav-icon-link.logout-btn:hover { color: var(--red); }

.theme-switcher { position: relative; }
.theme-toggle-btn {
  background: none; border: none; color: var(--muted);
  font-size: 1.15rem; cursor: pointer; padding: 0; line-height: 1;
}
.theme-toggle-btn:hover { color: var(--text); }
.theme-menu {
  position: absolute;
  top: 130%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 20;
}
.theme-menu-title {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 8px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.theme-option:hover { background: rgba(148, 163, 184, 0.15); }
.theme-option.active { background: var(--primary); color: white; }

.who-link { display: flex; align-items: center; text-decoration: none; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.95rem; padding: 0; }
.link-btn:hover { color: var(--red); }

.publish-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--green);
  text-decoration: none;
  border: 1px solid var(--green);
  border-radius: 999px;
  padding: 2px 10px;
}
.publish-badge:hover { text-decoration: underline; }
.inline { display: inline; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.container-wide { max-width: 1100px; }

.muted { color: var(--muted); }

textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
label { display: block; margin: 12px 0 6px; font-size: 0.9rem; color: var(--muted); }
.hint { font-size: 0.8rem; }

.btn-primary {
  margin-top: 16px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:disabled:hover { background: var(--primary); }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; }
.auth-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.subtitle { color: var(--muted); margin: 0 0 10px; }
.alt-link { text-align: center; margin-top: 16px; color: var(--muted); }
.alt-link a { color: var(--primary); }
.error { color: var(--red); background: rgba(239,68,68,0.1); padding: 8px 12px; border-radius: 8px; }

@media (max-width: 600px) {
  .container { padding: 14px; gap: 14px; }
  .topbar { padding: 12px 14px; }
  .topbar nav { gap: 12px; }
  .auth-card { padding: 22px; }
}
