:root {
  --bg: #16122b;
  --bg-2: #1e1840;
  --card: #241c4d;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f1ff;
  --muted: #b7b0d4;
  --amber: #e0a03a;
  --amber-2: #f0c56a;
  --violet: #8b8ad8;
  --ok: #6ec89a;
  --danger: #e07a7a;
  --new: #8b8ad8;
  --progress: #e0a03a;
  --done: #6ec89a;
  --radius: 16px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body {
  padding-top: var(--safe-top);
  padding-bottom: calc(88px + var(--safe-bottom));
}
button, input { font: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  cursor: pointer;
}
.hidden { display: none !important; }

.screen { min-height: 100dvh; }

#login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 8px;
}
.login-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
}
#login h1 { margin: 8px 0 0; font-size: 28px; }
#login p { color: var(--muted); margin: 0 0 12px; max-width: 28ch; }
#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, 100%);
}
#login-form input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  outline: none;
}
#login-form button,
.fab,
#modal-ok {
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  color: #2a1b04;
  font-weight: 700;
  border-radius: 12px;
  padding: 14px 16px;
}
.error { color: var(--danger); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--pad) 4px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px var(--pad) 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.filters button {
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
}
.filters button.active {
  background: #3a2d72;
  color: var(--text);
  border-color: transparent;
}
.filters span {
  display: inline-block;
  min-width: 1.2em;
  margin-left: 4px;
  color: var(--amber-2);
  font-variant-numeric: tabular-nums;
}

.list {
  padding: 0 var(--pad) 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 12px;
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 4px;
  min-height: 52px;
  touch-action: pan-y;
}
.row.layer { background: #2a2158; }
.row.task.done .title { color: var(--muted); text-decoration: line-through; }
.row.drop-into { outline: 2px solid var(--amber); }
.row.dragging { opacity: 0.45; pointer-events: none; }
.drop-line { pointer-events: none; }

.grip {
  width: 28px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.grip::before { content: "⋮⋮"; letter-spacing: -2px; font-size: 14px; }

.body { min-width: 0; }
.title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.title-input {
  width: 100%;
  background: #120e24;
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 6px 8px;
  outline: none;
}
.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.chev {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--violet);
}
.chev.open { transform: rotate(90deg); }

.actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chip, .icon-btn {
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  padding: 0 8px;
  background: #120e24;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
}
.chip.on-new { background: #3b3570; color: #ddd9ff; border-color: transparent; }
.chip.on-in_progress { background: #5a3d12; color: var(--amber-2); border-color: transparent; }
.chip.on-done { background: #1e4a34; color: var(--ok); border-color: transparent; }
.icon-btn { width: 32px; padding: 0; }
.icon-btn.danger:hover { color: var(--danger); }

.composer {
  display: flex;
  gap: 8px;
  background: var(--bg-2);
  border: 1px dashed var(--violet);
  border-radius: 14px;
  padding: 8px;
}
.composer input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  padding: 8px;
}

.drop-line {
  height: 3px;
  background: var(--amber);
  border-radius: 3px;
  margin: 2px 8px;
}

.fab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px var(--pad) calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}
.fab { flex: 1; }
.fab.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 18, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 24px;
}
.modal-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  width: min(420px, 100%);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (min-width: 720px) {
  #main { max-width: 720px; margin: 0 auto; }
}
