:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 14px) 18px 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.5px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.panel {
  max-width: 640px;
  margin: 12px auto 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel label {
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-size: 1rem;
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

button {
  cursor: pointer;
  border-radius: 8px;
  font-size: 1rem;
  padding: 12px 16px;
  border: 1px solid transparent;
}

button.primary {
  background: var(--primary);
  color: white;
}

button.primary:hover {
  background: var(--primary-hover);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.row {
  display: flex;
  gap: 10px;
}

.row.space-between {
  justify-content: space-between;
  align-items: center;
}

.task-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.task-form input {
  flex: 1;
}

.task-form select {
  width: auto;
}

.task-form button {
  flex-shrink: 0;
  width: 48px;
  font-size: 1.3rem;
  padding: 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
}

.item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}

.item-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.check,
.del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  padding: 2px 6px;
  flex-shrink: 0;
}

.check:hover {
  color: var(--primary);
}

.del:hover {
  color: var(--danger);
}

.badge {
  align-self: flex-start;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
}

.prio-high {
  background: #b45309;
}

.prio-urgent {
  background: var(--danger);
}

.prio-low {
  background: #475569;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.toast.error {
  border-color: var(--danger);
}

.hidden {
  display: none !important;
}

/* ── Login gate ──────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 30%, #1e293b, var(--bg));
}

.login-box {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: 1px;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  margin: 14px 0 0;
  color: #fca5a5;
  font-size: 0.85rem;
}

