:root {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: rgba(255,255,255,.05);
  --border: rgba(226,232,240,.15);
  --text: #e2e8f0;
  --muted: rgba(226,232,240,.55);
}

html.light {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: rgba(0,0,0,.04);
  --border: rgba(0,0,0,.1);
  --text: #0f172a;
  --muted: rgba(15,23,42,.5);
}

/* explicit overrides so light mode works even without variable inheritance */
html.light,
html.light body {
  background: #f1f5f9;
  color: #0f172a;
}

html.light .header,
html.light .footer {
  background: #f1f5f9;
  border-color: rgba(0,0,0,.1);
}

html.light .card,
html.light .auth-card {
  background: rgba(0,0,0,.04);
  border-color: rgba(0,0,0,.1);
  color: #0f172a;
}

html.light .muted {
  opacity: .6;
  color: #0f172a;
}

html.light .flash {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0,0,0,.12);
}

html.light .auth-card input,
html.light input[type="text"],
html.light input[type="number"],
html.light input[type="password"],
html.light input[type="email"] {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0,0,0,.15);
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main {
  flex: 1;
}

a { 
  color: inherit; 
  text-decoration: none; 
}

.container { 
  width: min(1000px, 92%); 
  margin: 0 auto; 
}

.skip-link { 
  position:absolute; 
  left:-999px; 
  top:auto; 
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background:#fff;
  color:#000;
  padding:.5rem;
  border-radius:.5rem;
}

/* ---------- Header ---------- */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.navbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 1rem 0;
  gap: 1rem;
}

.logo { 
  font-weight: 800; 
  letter-spacing: .5px; 
}

.nav-links {
  list-style:none;
  display:flex;
  align-items:center;
  gap:1rem;
  margin:0;
  padding:0;
}

.nav-links a { opacity:.9; }
.nav-links a:hover { opacity: 1; }
.nav-links a.active { opacity: 1; text-decoration: underline; }

.nav-hello { 
  opacity: .8; 
  font-size: .95rem; 
}

/* ---------- Toast Flashes (Top Right) ---------- */
.flashes {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  width: min(380px, calc(100vw - 2rem));
  display: grid;
  gap: .6rem;
}

.flash {
  padding: .85rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0,0,0,.2);
  transform: translateX(8px);
  opacity: 0;
  animation: toastIn .18s ease forwards;
  cursor: pointer;
}

@keyframes toastIn {
  to { transform: translateX(0); opacity: 1; }
}

.flash.is-hiding {
  animation: toastOut .22s ease forwards;
}

@keyframes toastOut {
  to { transform: translateX(10px); opacity: 0; }
}

.flash-error { border-color: rgba(248,113,113,.45); }
.flash-success { border-color: rgba(34,197,94,.45); }
.flash-info { border-color: rgba(56,189,248,.45); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding:.8rem 1rem;
  border-radius: .9rem;
  border: 1px solid rgba(226,232,240,.2);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
  user-select: none;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(226,232,240,.35);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(0,0,0,.18);
}

.btn:focus-visible {
  outline: 2px solid rgba(56,189,248,.45);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary { 
  background: rgba(56,189,248,.15); 
}

.btn.primary:hover { 
  background: rgba(56,189,248,.22); 
}

.btn.secondary { 
  background: rgba(226,232,240,.06); 
}

.btn.secondary:hover { 
  background: rgba(226,232,240,.10); 
}

/* ---------- Danger Minimal Delete ---------- */
.btn.danger {
  border: 1px solid rgba(248,113,113,.45);
  color: #f87171;
  background: transparent;
}

.btn.danger:hover {
  background: rgba(248,113,113,.12);
  border-color: rgba(248,113,113,.65);
}


/* ---------- Layout ---------- */
.hero { padding: 4rem 0 2rem; }

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 .75rem;
}

.hero p {
  max-width: 60ch;
  opacity: .9;
}

.actions {
  display:flex;
  gap: .75rem;
  margin-top: 1.25rem;
}

/* ---------- Cards ---------- */
.features { padding: 2rem 0 4rem; }

.grid {
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
  box-shadow: 0 14px 34px rgba(0,0,0,.22);
}

/* ---------- Auth Card ---------- */
.auth-card {
  width: min(420px, 100%);
  margin: 2rem auto;
  padding: 1.25rem;
  border-radius: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.auth-card h1 { margin: 0 0 .75rem; }

.auth-card form {
  display: grid;
  gap: .6rem;
  margin-top: .8rem;
}

.auth-card label { 
  font-size: .95rem; 
  opacity: .9; 
}

.auth-card input {
  padding: .7rem .8rem;
  border-radius: .8rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}

.auth-card input:focus {
  outline: none;
  border-color: rgba(56,189,248,.35);
  box-shadow: 0 0 0 4px rgba(56,189,248,.12);
}

.muted { 
  opacity: .85; 
  margin-top: 1rem; 
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  opacity: .8;
  text-align:center;
  background: var(--bg);
}

@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
  .actions { flex-direction: column; align-items: flex-start; }
  .navbar { flex-direction: column; align-items: flex-start; }
  .room-layout { flex-direction: column !important; }
  .room-layout > .auth-card { width: 100% !important; }
  .room-layout > div[style*="width:320px"],
  .room-layout > div[style*="width:260px"] { width: 100% !important; position: static !important; }

  /* Navbar mobile — hide greeting text, compress */
  .nav-hello { display: none; }
  .nav-links { flex-wrap: wrap; gap: .5rem; }

  /* My Tasks mobile — collapsible, compact height */
  .todo-panel-body { display: none; }
  .todo-panel-body.open { display: flex !important; flex-direction: column; }
  .todo-panel { height: auto !important; max-height: none !important; }
  .todo-toggle-btn { cursor: pointer; user-select: none; width: 100%; background: none; border: none;
                     color: var(--text); font-size: 1rem; font-weight: 600;
                     display: flex; align-items: center; justify-content: space-between; padding: 0; }
}

.room-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-top: .75rem;
}

.btn {
  padding: .6rem 1rem;
  border-radius: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  border: 1px solid transparent;
}

.btn.danger {
  background: transparent;
  border: 1px solid #ff4d4f;
  color: #ff4d4f;
}

.btn.danger:hover {
  background: rgba(255, 77, 79, 0.12);
  border-color: #ff4d4f;
  color: #ff4d4f;
}

/* ---------- Password Toggle ---------- */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  flex: 1;
  padding-right: 2.6rem;
}

.pw-toggle {
  position: absolute;
  right: .55rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: .5;
  padding: .2rem;
  line-height: 1;
  transition: opacity .15s ease;
}

.pw-toggle:hover { opacity: .85; }

/* ---------- Presence Dots ---------- */
.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: background .3s ease, box-shadow .3s ease;
}

.presence-dot.online {
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, .25);
  animation: pulse-online 2.5s ease-in-out infinite;
}

.presence-dot.online.focusing {
  background: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, .3);
  animation: pulse-focusing 1.4s ease-in-out infinite;
}

.presence-dot.offline {
  background: rgba(226, 232, 240, .18);
}

@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74, 222, 128, .25); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, .08); }
}

@keyframes pulse-focusing {
  0%, 100% { box-shadow: 0 0 0 2px rgba(96, 165, 250, .3); }
  50%       { box-shadow: 0 0 0 6px rgba(96, 165, 250, .08); }
}