:root {
  --ink: #0b0d12;
  --ink-2: #10141c;
  --line: rgba(148, 190, 220, 0.14);
  --text: #d7e3ec;
  --text-dim: #6d8296;
  --cyan: #22d3ee;
  --blue: #2f6bff;
  --pink: #e0355f;
  --font-head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  overflow-x: hidden;
}

#bg-dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 46% 70% at 58% 42%, rgba(34, 211, 238, 0.05), transparent 70%);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 20px;
  letter-spacing: 0.02em;
}

.brand .worm { width: 30px; height: 30px; }

.worm .sclera { fill: #f6f5f1; }
.worm .pupil { fill: #16181d; }

.topnav { display: flex; align-items: center; gap: 14px; }
.whoami { color: #a8bccb; font-size: 14px; }
.bg-select {
  width: auto;
  margin-top: 0;
  background: rgba(16, 20, 28, 0.8);
  border: 1px solid rgba(148, 190, 220, 0.28);
  border-radius: 8px;
  color: #a8bccb;
  font-size: 13px;
  padding: 6px 10px;
}

#boop-column {
  position: relative;
  z-index: 1;
  margin-left: 58%;
  transform: translateX(-50%);
  width: min(520px, 88vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0 120px;
}

.boop {
  --u: 0;
  --bc: #3a536b;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid color-mix(in srgb, var(--bc) 55%, transparent);
  border-radius: 999px;
  background: rgba(16, 20, 28, 0.72);
  backdrop-filter: blur(6px);
  padding: 0 20px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.15s;
  box-shadow: 0 0 calc(var(--u) * 26px) color-mix(in srgb, var(--bc) calc(var(--u) * 55%), transparent),
              inset 0 0 calc(var(--u) * 18px) color-mix(in srgb, var(--bc) calc(var(--u) * 14%), transparent);
}

.boop:hover { transform: scale(1.02); }

.boop-actions {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease-out;
}

.boop:hover .boop-actions,
.boop:focus-within .boop-actions {
  opacity: 1;
  pointer-events: auto;
}

.boop:hover .boop-title,
.boop:hover .boop-meta,
.boop:focus-within .boop-title,
.boop:focus-within .boop-meta { opacity: 0.35; }

.boop-title, .boop-meta { transition: opacity 0.16s ease-out; }

.led-btn {
  background: rgba(11, 13, 18, 0.88);
  border-radius: 999px;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.88em;
  letter-spacing: 0.05em;
  padding: 4px 16px;
  cursor: pointer;
}

.led-btn:active { transform: scale(0.95); }

.led-green {
  border: 1px solid #2bd97c;
  color: #2bd97c;
  text-shadow: 0 0 9px rgba(43, 217, 124, 0.9);
  box-shadow: 0 0 12px rgba(43, 217, 124, 0.35), inset 0 0 8px rgba(43, 217, 124, 0.12);
}

.led-green:hover { box-shadow: 0 0 20px rgba(43, 217, 124, 0.6), inset 0 0 10px rgba(43, 217, 124, 0.2); }

.led-blue {
  border: 1px solid #4f8cff;
  color: #7fa8ff;
  text-shadow: 0 0 9px rgba(79, 140, 255, 0.9);
  box-shadow: 0 0 12px rgba(79, 140, 255, 0.35), inset 0 0 8px rgba(79, 140, 255, 0.12);
}

.led-blue:hover { box-shadow: 0 0 20px rgba(79, 140, 255, 0.6), inset 0 0 10px rgba(79, 140, 255, 0.2); }

.boop-title {
  font-family: var(--font-head);
  font-weight: 500;
  color: color-mix(in srgb, var(--bc) 72%, #ffffff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.boop-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 0.78em;
  color: var(--text-dim);
  white-space: nowrap;
}

.boop-meta .due-label { color: color-mix(in srgb, var(--bc) 80%, #dfe9f0); }


.boop.bobbing { animation: bob 3.2s ease-in-out infinite; }
.boop.wiggling { animation: wiggle 1.9s ease-in-out infinite; }
.boop.overdue { animation: pulse 2.4s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}

@keyframes wiggle {
  0%, 100% { rotate: 0deg; translate: 0 0; }
  20% { rotate: 0.8deg; translate: 0 -2px; }
  45% { rotate: -0.7deg; translate: 0 -3px; }
  70% { rotate: 0.5deg; translate: 0 -1px; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 22px color-mix(in srgb, var(--bc) 45%, transparent); }
  50% { box-shadow: 0 0 40px color-mix(in srgb, var(--bc) 80%, transparent); }
}

.boop.completing {
  pointer-events: none;
  animation: settle 0.72s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

@keyframes settle {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  18% { transform: scale(1.03); filter: brightness(1.6); }
  100% { opacity: 0; transform: scale(0.9); filter: brightness(1.1); }
}

.ripple-ring {
  position: absolute;
  inset: -1px;
  border-radius: 999px;
  border: 1px solid var(--bc);
  pointer-events: none;
  animation: ripple-out 0.9s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}

.ripple-ring.late { animation-delay: 0.18s; opacity: 0; }

@keyframes ripple-out {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

.empty-state {
  position: fixed;
  left: 58%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
}

.empty-worm .worm { width: 90px; height: 90px; opacity: 0.7; animation: bob 4.5s ease-in-out infinite; }
.empty-line { color: var(--text-dim); margin-top: 10px; font-size: 14px; }

.add-btn {
  position: fixed;
  right: 34px;
  bottom: 34px;
  z-index: 3;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--cyan) 60%, transparent);
  background: rgba(16, 20, 28, 0.85);
  color: var(--cyan);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.15s;
}

.add-btn:hover { box-shadow: 0 0 24px rgba(34, 211, 238, 0.35); transform: scale(1.05); }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: min(420px, 94vw);
  background: rgba(13, 17, 24, 0.97);
  border-left: 1px solid var(--line);
  padding: 26px 28px;
  overflow-y: auto;
  animation: panel-in 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes panel-in {
  from { translate: 40px 0; opacity: 0; }
  to { translate: 0 0; opacity: 1; }
}

.panel-scrim {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: rgba(5, 7, 10, 0.55);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panel-head h2 { font-family: var(--font-head); font-weight: 500; font-size: 19px; }

form label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
  letter-spacing: 0.03em;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--cyan) 60%, transparent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

textarea { resize: vertical; }

.field-row { display: flex; gap: 12px; }
.field-row label { flex: 1; }

.panel-actions { display: flex; gap: 10px; margin-top: 6px; }

.panel-section {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
}

.panel-section > h3 {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.countdown {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--cyan);
  margin-bottom: 14px;
}

.countdown .count-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.countdown.count-overdue { color: var(--pink); }

.done-btn {
  background: rgba(43, 217, 124, 0.14);
  border: 1px solid #2bd97c;
  color: #2bd97c;
  font-weight: 500;
}

.done-btn:hover { box-shadow: 0 0 18px rgba(43, 217, 124, 0.4); }

.danger-btn {
  background: rgba(224, 53, 95, 0.1);
}

button {
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  padding: 9px 16px;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}

.primary-btn {
  background: color-mix(in srgb, var(--cyan) 18%, var(--ink-2));
  border: 1px solid color-mix(in srgb, var(--cyan) 55%, transparent);
  color: var(--cyan);
}

.primary-btn:hover { box-shadow: 0 0 16px rgba(34, 211, 238, 0.25); }

.ghost-btn {
  background: none;
  border: 1px solid rgba(148, 190, 220, 0.28);
  color: #a8bccb;
}

.ghost-btn:hover { color: var(--text); border-color: rgba(148, 190, 220, 0.5); }

.ghost-btn.scope-active {
  color: var(--cyan);
  border-color: color-mix(in srgb, var(--cyan) 55%, transparent);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}

.danger-btn {
  background: none;
  border: 1px solid color-mix(in srgb, var(--pink) 45%, transparent);
  color: var(--pink);
}

.danger-btn:hover { box-shadow: 0 0 14px rgba(224, 53, 95, 0.25); }

.form-error { color: var(--pink); font-size: 13px; margin-bottom: 12px; }

.field-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: -4px 0 12px;
}

.clamp-note { color: #d9b45a; }

.note-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 14px;
}

.note-link-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--cyan);
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--cyan) 40%, transparent);
  border-radius: 999px;
  padding: 3px 12px;
  transition: box-shadow 0.2s;
}

.note-link-chip::after { content: ' ↗'; opacity: 0.7; }
.note-link-chip:hover { box-shadow: 0 0 12px rgba(34, 211, 238, 0.3); text-decoration: underline; }

.day-rail {
  position: fixed;
  left: 7%;
  top: 38%;
  z-index: 1;
  font-family: var(--font-head);
  pointer-events: none;
}

.rail-dow {
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.rail-date {
  font-size: 44px;
  font-weight: 500;
  line-height: 1.15;
  color: color-mix(in srgb, var(--cyan) 55%, var(--text));
}

.rail-counts {
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}

.rail-counts .rail-overdue { color: var(--pink); }
.rail-counts .rail-today { color: var(--cyan); }

#list-view {
  position: relative;
  z-index: 1;
  margin: 12px auto 120px;
  width: min(1060px, 94vw);
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(13, 17, 24, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13.5px;
}

.task-table th {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.task-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 190, 220, 0.07);
  color: #c9d8e4;
}

.task-table tbody tr { cursor: pointer; transition: background 0.15s; }
.task-table tbody tr:hover { background: rgba(34, 211, 238, 0.06); }
.task-table tbody tr:last-child td { border-bottom: none; }

.task-table .cell-title { font-weight: 500; color: var(--text); }
.task-table .cell-note-dot { color: var(--text-dim); font-size: 12px; }
.task-table .cell-dim { color: var(--text-dim); }
.task-table .cell-overdue { color: var(--pink); }
.task-table .cell-soon { color: var(--cyan); }
.task-table .cell-done { color: #2bd97c; }

.task-table .led-btn { font-size: 12px; padding: 3px 12px; }

@media (max-width: 1100px) {
  .day-rail { display: none; }
}

.history { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.history h3 { font-family: var(--font-head); font-weight: 500; font-size: 14px; color: var(--text-dim); margin-bottom: 10px; }
.history ul { list-style: none; }
.history li { font-size: 13px; color: var(--text-dim); padding: 4px 0; }
.history li .late-note { color: var(--pink); opacity: 0.8; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(16, 20, 28, 0.96);
  border: 1px solid rgba(148, 190, 220, 0.3);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  color: #c9d8e4;
  animation: toast-in 0.25s ease-out;
}

.toast .undo-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--cyan);
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
}

.toast .undo-link:hover { text-decoration: underline; }

@keyframes toast-in {
  from { translate: 0 12px; opacity: 0; }
  to { translate: 0 0; opacity: 1; }
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: min(360px, 92vw);
  background: rgba(13, 17, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 34px;
  text-align: center;
}

.login-mark .worm { width: 64px; height: 64px; }
.login-title { font-family: var(--font-head); font-weight: 500; font-size: 26px; margin: 10px 0 4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-card form { text-align: left; }
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 4px;
  background: color-mix(in srgb, var(--cyan) 18%, var(--ink-2));
  border: 1px solid color-mix(in srgb, var(--cyan) 55%, transparent);
  color: var(--cyan);
}

.dtp { position: relative; }

.dtp-display {
  cursor: pointer;
  caret-color: transparent;
}

.dtp-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 8;
  width: 268px;
  background: #10151d;
  border: 1px solid rgba(148, 190, 220, 0.3);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.dtp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dtp-head .dtp-month {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

.dtp-nav {
  background: none;
  border: 1px solid rgba(148, 190, 220, 0.25);
  border-radius: 6px;
  color: #a8bccb;
  width: 28px;
  height: 26px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}

.dtp-nav:hover { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 55%, transparent); }

.dtp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.dtp-dow {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 0;
}

.dtp-day {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #c9d8e4;
  font-size: 13px;
  padding: 5px 0;
  cursor: pointer;
}

.dtp-day:hover { border-color: rgba(34, 211, 238, 0.5); }
.dtp-day.other-month { color: #45586a; }
.dtp-day.today { border-color: rgba(148, 190, 220, 0.35); }

.dtp-day.selected {
  background: rgba(34, 211, 238, 0.18);
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 500;
}

.dtp-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.dtp-foot input[type="time"] {
  margin-top: 0;
  width: auto;
  flex: 1;
  color-scheme: dark;
}

.dtp-set {
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-weight: 500;
  padding: 8px 18px;
}

.dtp-set:hover { box-shadow: 0 0 14px rgba(34, 211, 238, 0.35); }

body[data-tone="light"] {
  --text: #1e2a36;
  --text-dim: #5a6d7e;
  --line: rgba(20, 40, 60, 0.15);
}

body[data-tone="light"] .whoami,
body[data-tone="light"] .ghost-btn,
body[data-tone="light"] .bg-select { color: #33475a; }

body[data-tone="light"] .ghost-btn,
body[data-tone="light"] .bg-select { border-color: rgba(20, 40, 60, 0.3); background: rgba(255, 255, 255, 0.4); }

body[data-tone="light"] .brand { color: #16222e; }

body[data-overlay="1"]::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(6, 9, 14, 0.45);
}

#list-view { overflow-x: auto; }
.task-table { min-width: 760px; }

@media (hover: none) {
  .boop-actions {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    flex-shrink: 0;
  }
  .boop:hover .boop-title,
  .boop:hover .boop-meta,
  .boop:focus-within .boop-title,
  .boop:focus-within .boop-meta { opacity: 1; }
  .boop .led-btn { font-size: 0.8em; padding: 3px 11px; }
}

@media (max-width: 720px) {
  #boop-column { margin-left: 50%; width: 94vw; }
  .empty-state { left: 50%; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .topnav { flex-wrap: nowrap; gap: 8px; }
  .whoami { display: none; }
  .brand { font-size: 17px; }
  .brand .worm { width: 24px; height: 24px; }
  .bg-select { max-width: 110px; }
  .ghost-btn { padding: 6px 10px; font-size: 13px; }
  .boop { min-width: 0 !important; width: 100% !important; }
  .boop-meta { gap: 6px; }
  .boop-meta .due-label { font-size: 0.95em; }
  .add-btn { right: 18px; bottom: 18px; }
  .panel { padding: 20px 18px; }
  .field-row { flex-direction: column; gap: 0; }
}
