:root {
  --bg: #0e1016;
  --surface: #161a23;
  --surface-2: #1d222d;
  --border: #262c39;
  --text: #e7eaf0;
  --muted: #8a92a6;
  --faint: #5b6275;
  --accent: #6366f1;
  --accent-hover: #7c7ff5;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 50% -10%, #1a1f2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: 32px 16px 80px;
}

.app {
  max-width: 640px;
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.presence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 999px;
}

.presence .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.new-item {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.new-item input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.new-item input::placeholder {
  color: var(--faint);
}

.new-item input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.new-item button {
  flex: 0 0 auto;
  width: 50px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
}

.new-item button:hover {
  background: var(--accent-hover);
}

.new-item button:active {
  transform: scale(0.94);
}

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list:empty {
  display: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  transition: background 0.12s;
}

.row:first-child {
  border-top: none;
}

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

.row.sub {
  padding-left: 44px;
  background: rgba(0, 0, 0, 0.12);
}

.row.sub::before {
  content: '';
  position: absolute;
}

.check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid var(--faint);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
}

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

.check svg {
  width: 13px;
  height: 13px;
  stroke: #fff;
  stroke-width: 3.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.12s, transform 0.12s;
}

.row.done .check {
  background: var(--accent);
  border-color: var(--accent);
}

.row.done .check svg {
  opacity: 1;
  transform: scale(1);
}

.text {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.35;
  padding: 4px 2px;
  outline: none;
  min-width: 0;
  border-radius: 6px;
  transition: color 0.15s;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  vertical-align: top;
  display: block;
}

.text:focus {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.row.sub .text {
  font-size: 0.94rem;
}

.row.done .text {
  color: var(--faint);
  text-decoration: line-through;
}

.row.rainy .text {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}

.row.rainy.done .text {
  text-decoration: underline line-through;
}

.actions .rain {
  font-size: 0.95rem;
  filter: grayscale(1);
  opacity: 0.55;
}

.actions .rain:hover {
  filter: none;
  opacity: 1;
  background: var(--border);
}

.row.rainy .rain {
  filter: none;
  opacity: 1;
}

.actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.12s;
}

.row:hover .actions,
.row:focus-within .actions {
  opacity: 1;
}

.actions button {
  width: 28px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}

.actions .move {
  font-size: 1rem;
  width: 24px;
}

.actions button:hover {
  background: var(--border);
  color: var(--text);
}

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

.empty {
  text-align: center;
  color: var(--faint);
  font-size: 0.95rem;
  margin-top: 28px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 0 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend {
  text-align: center;
  color: var(--faint);
  font-size: 0.8rem;
  margin-top: 14px;
}

.legend u {
  text-underline-offset: 3px;
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 6px;
  transition: color 0.12s;
}

.link:hover {
  color: var(--accent-hover);
}

.conn-status {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}

@media (max-width: 480px) {
  body {
    padding: 20px 10px 80px;
  }
  .row {
    gap: 8px;
    padding: 12px 8px;
  }
  .actions {
    opacity: 1;
    gap: 0;
  }
  .actions button {
    width: 27px;
    height: 32px;
    font-size: 1rem;
  }
  .actions .move {
    width: 20px;
  }
  .row.sub {
    padding-left: 30px;
  }
}
