:root {
  --bg:            #15101f;
  --bg-secondary:  #1f1830;
  --bg-section:    #221b35;
  --text:          #ece6fa;
  --hint:          #9686b8;
  --link:          #b794f6;
  --accent:        #9151e6;
  --accent-text:   #ffffff;
  --destructive:   #ff6b8a;
  --separator:     rgba(183, 148, 246, 0.18);

  --glow: 0 0 0 1px rgba(145, 81, 230, 0.15), 0 4px 18px rgba(91, 33, 182, 0.35);

  --radius-card: 14px;
  --radius-sheet: 20px;
  --radius-pill: 100px;

  --tint-tasks: 266 75% 68%;
  --tint-watch: 291 70% 66%;
  --tint-read:  231 75% 72%;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }


[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 6% 12%, rgba(236,230,250,0.8) 0%, transparent 60%),
    radial-gradient(1px 1px at 14% 38%, rgba(183,148,246,0.6) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(236,230,250,0.9) 0%, transparent 60%),
    radial-gradient(1px 1px at 22% 55%, rgba(236,230,250,0.6) 0%, transparent 60%),
    radial-gradient(1px 1px at 28% 64%, rgba(236,230,250,0.7) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 33% 9%, rgba(183,148,246,0.7) 0%, transparent 60%),
    radial-gradient(1px 1px at 36% 41%, rgba(236,230,250,0.55) 0%, transparent 60%),
    radial-gradient(2px 2px at 47% 32%, rgba(236,230,250,0.9) 0%, transparent 60%),
    radial-gradient(1px 1px at 52% 70%, rgba(183,148,246,0.6) 0%, transparent 60%),
    radial-gradient(1px 1px at 58% 14%, rgba(236,230,250,0.65) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 63% 78%, rgba(183,148,246,0.85) 0%, transparent 60%),
    radial-gradient(1px 1px at 68% 47%, rgba(236,230,250,0.6) 0%, transparent 60%),
    radial-gradient(1px 1px at 73% 92%, rgba(183,148,246,0.55) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 81% 22%, rgba(236,230,250,0.8) 0%, transparent 60%),
    radial-gradient(1px 1px at 86% 63%, rgba(236,230,250,0.5) 0%, transparent 60%),
    radial-gradient(2px 2px at 91% 58%, rgba(183,148,246,0.85) 0%, transparent 60%),
    radial-gradient(1px 1px at 95% 36%, rgba(236,230,250,0.55) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 18% 88%, rgba(236,230,250,0.7) 0%, transparent 60%),
    radial-gradient(1px 1px at 8% 75%, rgba(183,148,246,0.5) 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 38% 8%, rgba(183,148,246,0.75) 0%, transparent 60%),
    radial-gradient(1px 1px at 44% 96%, rgba(236,230,250,0.5) 0%, transparent 60%),
    radial-gradient(1px 1px at 77% 5%, rgba(236,230,250,0.6) 0%, transparent 60%),
    radial-gradient(900px 600px at 50% -10%, rgba(91,33,182,0.35) 0%, transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.tabbar {
  display: flex;
  padding: 10px 12px 12px;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--separator);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: none;
  border-radius: var(--radius-card);
  color: var(--hint);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.tab:active { transform: scale(0.96); }

.tab.active {
  background: var(--bg-secondary);
  color: var(--text);
  box-shadow: 0 0 14px rgba(145, 81, 230, 0.25);
}

.tab-icon { display: block; color: currentColor; }
.tab-label { letter-spacing: 0.01em; }

.subbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.subbar::-webkit-scrollbar { display: none; }

.subbar-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.subbar-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

main#content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px 100px;
  -webkit-overflow-scrolling: touch;
}

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

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: rgba(34, 27, 53, 1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: var(--radius-card);
  border: 1px solid rgba(183, 148, 246, 0.22);
  border-top-color: rgba(236, 230, 250, 0.28);
  box-shadow: inset 0 1px 0 rgba(236, 230, 250, 0.06), 0 4px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  animation: card-in 0.22s ease backwards;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.985);
  box-shadow: inset 0 1px 0 rgba(236, 230, 250, 0.08), 0 0 16px rgba(145, 81, 230, 0.35);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-ribbon {
  flex-shrink: 0;
  width: 5px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--separator);
  position: relative;
  overflow: hidden;
}
.card-ribbon::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: hsl(var(--tint, var(--tint-tasks)));
  height: var(--fill, 0%);
  border-radius: 3px;
  transition: height 0.3s ease;
}
.card[data-section="tasks"] .card-ribbon { --tint: var(--tint-tasks); }
.card[data-section="watch"] .card-ribbon { --tint: var(--tint-watch); }
.card[data-section="read"]  .card-ribbon { --tint: var(--tint-read); }
.card.is-done .card-ribbon::after { height: 100%; }

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.is-done .card-title { color: var(--hint); text-decoration: line-through; text-decoration-color: var(--separator); }

.card-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-remind {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.card-note-dot {
  flex-shrink: 0;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: hsl(var(--tint-read));
  margin-right: 2px;
}

.card-chevron { flex-shrink: 0; color: var(--hint); opacity: 0.5; }

.card-swipe-wrap {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  animation: card-in 0.22s ease backwards;
}

.card-swipeable {
  position: relative;
  z-index: 2;
  animation: none;
  touch-action: pan-y;
}

.swipe-action {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 76px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: transparent;
}

.swipe-action-left  { left: 0;  border-radius: var(--radius-card) 0 0 var(--radius-card); }
.swipe-action-right { right: 0; border-radius: 0 var(--radius-card) var(--radius-card) 0; }

.swipe-action-green { color: #34c759; }
.swipe-action-red    { color: #ff3b30; }
.swipe-action-purple { color: #9151E6; }

.swipe-action:active { filter: brightness(0.8); }

.swipe-action svg path{
    stroke: currentColor;
}

.loader {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}
.loader[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--separator);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 70px 24px;
  color: var(--hint);
}
#empty-text { font-size: 15px; margin: 0; line-height: 1.5; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(145, 81, 230, 0.55), 0 0 0 1px rgba(183, 148, 246, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease;
  z-index: 20;
}
.fab:active { transform: scale(0.92); }

.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  z-index: 50;
  animation: overlay-in 0.18s ease;
}
.sheet-overlay[hidden] { display: none; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-height: 86vh;
  background: var(--bg);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: sheet-in 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--separator);
  margin: 4px auto 16px;
}

.sheet-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-status {
  font-size: 13px;
  color: var(--hint);
  margin: 0 0 18px;
}

.sheet-field {
  margin-bottom: 14px;
}
.sheet-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.sheet-field-value {
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}
.sheet-field-value a { color: var(--link); }

.sheet-input, .sheet-textarea {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}
.sheet-input:focus, .sheet-textarea:focus { border-color: var(--accent); }
.sheet-textarea { resize: vertical; min-height: 70px; }


input[type="datetime-local"].sheet-input {
  color-scheme: dark;
}
input[type="datetime-local"].sheet-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(1) saturate(4) hue-rotate(230deg);
  cursor: pointer;
  opacity: 0.75;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 0 16px rgba(145, 81, 230, 0.45); }
.btn-secondary { background: var(--bg-secondary); color: var(--text); }
.btn-destructive { background: transparent; color: var(--destructive); }
.btn-ghost { background: transparent; color: var(--hint); }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.progress-row .sheet-input { background: var(--bg); flex: 1; margin: 0; }
.btn-stepper {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.btn-stepper:active { transform: scale(0.92); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(0);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  animation: toast-in 0.2s ease;
  max-width: calc(100vw - 48px);
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
