/* ========================================================================
   apptodo — command-center dark theme
   ======================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  /* neutrals */
  --bg:           #0a0a0c;
  --surface:      #131316;
  --surface-2:   #1c1c21;
  --surface-hover:#18181d;
  --border:       #26262d;
  --border-soft:  #1a1a1f;

  --text:         #eceef0;
  --text-muted:   #9a9aa2;
  --text-dim:     #646470;
  --text-fade:    #43434c;

  /* functional */
  --accent:       #f59e0b;   /* amber */
  --accent-hover: #fbbf24;
  --accent-soft:  rgba(245, 158, 11, 0.12);

  --ok:           #10b981;
  --warn:         #eab308;
  --danger:       #ef4444;
  --danger-soft:  rgba(239, 68, 68, 0.12);

  --prio-high:    #ef4444;
  --prio-med:     #eab308;
  --prio-low:     #52525b;

  /* fonts */
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'Geist Mono', 'SF Mono', ui-monospace, monospace;
}

html { background: var(--bg); color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

.hidden { display: none !important; }

::selection { background: var(--accent); color: var(--bg); }

/* ========================================================================
   Page frame
   ======================================================================== */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

/* ========================================================================
   Topbar
   ======================================================================== */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  justify-self: start;
}

.brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.88); }
}

.nav {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 5px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: color 140ms ease, background 140ms ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-count {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  letter-spacing: 0;
  min-width: 22px;
  text-align: center;
}
.nav-link.active .nav-count { color: var(--text-muted); }

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  justify-self: end;
}
.date-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 140ms ease;
  padding: 0;
}
.icon-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ========================================================================
   Composer
   ======================================================================== */
.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 6px 6px 16px;
  margin-bottom: 32px;
  transition: border-color 160ms ease, background 160ms ease;
}
.composer:focus-within {
  border-color: var(--accent);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.composer-plus {
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 400;
  flex-shrink: 0;
  user-select: none;
}
#title {
  flex: 1;
  min-width: 240px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  padding: 11px 0;
  letter-spacing: -0.005em;
}
#title:focus { outline: none; }
#title::placeholder { color: var(--text-dim); }

.composer-fields {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 5px;
}
.composer-fields select,
.composer-fields input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 9px;
  transition: border-color 140ms ease, background 140ms ease;
  min-width: 0;
}
.composer-fields select {
  cursor: pointer;
  padding-right: 22px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239a9aa2' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
}
.composer-fields input[type="date"] {
  font-family: var(--mono);
  font-size: 11.5px;
  color-scheme: dark;
  max-width: 135px;
}
.composer-fields input#tags {
  width: 140px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.composer-fields *:focus,
.composer-fields *:hover:not(:focus) {
  border-color: var(--text-dim);
}
.composer-fields *:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.submit-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0a0a0c;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 140ms ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -0.005em;
}
.submit-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.submit-btn svg { transition: transform 140ms ease; }
.submit-btn:hover svg { transform: translateX(2px); }

/* ========================================================================
   Entries
   ======================================================================== */
.entries { margin-top: 0; }

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border-soft);
}

.task {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 10px 14px 22px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 140ms ease;
  opacity: 0;
  transform: translateY(4px);
  animation: row-in 360ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.task:nth-child(1) { animation-delay: 20ms; }
.task:nth-child(2) { animation-delay: 50ms; }
.task:nth-child(3) { animation-delay: 80ms; }
.task:nth-child(4) { animation-delay: 110ms; }
.task:nth-child(5) { animation-delay: 140ms; }
.task:nth-child(n+6) { animation-delay: 170ms; }
@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task:hover { background: var(--surface-hover); }

/* priority gutter */
.task::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--prio-low);
  transition: background 140ms ease, width 140ms ease;
}
.task.priority-high::before   { background: var(--prio-high); }
.task.priority-medium::before { background: var(--prio-med); }
.task.priority-low::before    { background: var(--prio-low); }
.task:hover::before { width: 3px; }

/* check button */
.task-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-dim);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 160ms ease;
  flex-shrink: 0;
  padding: 0;
}
.task-check:hover {
  border-color: var(--ok);
  background: rgba(16, 185, 129, 0.08);
}
.task-check::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}
.task.checking .task-check {
  border-color: var(--ok);
  background: var(--ok);
}
.task.checking .task-check::after { transform: rotate(45deg) scale(1); }

/* restore button (archive view) */
.task-restore {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-muted);
  color: var(--text-muted);
  background: transparent;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 160ms ease;
}
.task-restore:hover {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--bg);
}

/* title */
.task-body { min-width: 0; overflow: hidden; }
.task-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 450;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.005em;
  transition: color 220ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-description {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.task.checking .task-title,
.task.archived .task-title {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
  text-decoration-thickness: 1px;
}

/* meta (date + tags) */
.task-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.task-due {
  text-transform: uppercase;
  font-weight: 500;
}
.task-due.overdue { color: var(--danger); }

.task-tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 300px;
}
.task-tag { color: var(--text-muted); font-weight: 400; }
.task-tag::before {
  content: '#';
  color: var(--accent);
  opacity: 0.75;
}

/* delete */
.task-delete {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  border-radius: 4px;
  transition: all 140ms ease;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--sans);
}
.task:hover .task-delete { color: var(--text-dim); }
.task-delete:hover { background: var(--danger-soft); color: var(--danger); }

/* leave animation */
@keyframes leave {
  0%   { opacity: 1; transform: translateX(0); max-height: 90px; }
  40%  { opacity: 0.3; transform: translateX(-6px); }
  100% { opacity: 0; transform: translateX(-12px); max-height: 0; padding-top: 0; padding-bottom: 0; border-color: transparent; }
}
.task-leaving {
  animation: leave 320ms cubic-bezier(0.5, 0, 0.75, 0) forwards;
  overflow: hidden;
  pointer-events: none;
}

/* archive-specific */
.archive-view .task-title {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--text-fade);
  text-decoration-thickness: 1px;
}

/* empty state */
.empty {
  text-align: center;
  padding: 96px 20px;
}
.empty-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.empty-sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  margin: 0;
  letter-spacing: 0.03em;
}

/* ========================================================================
   Token gate
   ======================================================================== */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  animation: fade-in 280ms ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.gate-form {
  max-width: 400px;
  width: 100%;
}
.gate-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  margin: 0 0 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.gate-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.gate-help {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
  line-height: 1.5;
}
.gate-input-wrap {
  display: flex;
  gap: 8px;
}
#token-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 11px 13px;
  transition: border-color 140ms ease, background 140ms ease;
}
#token-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#token-input::placeholder {
  color: var(--text-dim);
  font-family: var(--sans);
}
.gate-input-wrap button {
  background: var(--accent);
  border: none;
  color: var(--bg);
  font-weight: 600;
  padding: 0 20px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 140ms ease;
  font-family: var(--sans);
  letter-spacing: -0.005em;
}
.gate-input-wrap button:hover { background: var(--accent-hover); }
.gate-error {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--danger);
  letter-spacing: 0.02em;
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 900px) {
  .task-meta { font-size: 10.5px; gap: 10px; }
  .task-tags { max-width: 180px; }
}

@media (max-width: 720px) {
  .page { padding: 0 18px 64px; }
  .topbar { grid-template-columns: auto 1fr; gap: 12px; padding: 16px 0; }
  .topbar .nav { grid-column: 1 / -1; order: 3; justify-self: center; }
  .topbar-right .date-label { display: none; }

  .composer { padding: 10px; }
  .composer-row { align-items: stretch; }
  #title { width: 100%; padding: 8px 0; font-size: 15px; }
  .composer-fields { width: 100%; justify-content: space-between; gap: 6px; padding: 0; }
  .submit-btn { margin-left: auto; }

  .task { grid-template-columns: auto 1fr auto; padding: 12px 8px 12px 16px; gap: 12px; }
  .task-meta { grid-column: 2 / -1; grid-row: 2; margin-top: 4px; flex-wrap: wrap; }
  .task-delete { grid-column: 3; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
