/* dgntw — global theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.12);
}

[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-subtle: #12151c;
  --fg: #eceef2;
  --fg-muted: #9aa3b2;
  --accent: #7c6cf6;
  --accent-soft: rgb(124 108 246 / 0.14);
  --border: #232833;
  --card: #12151c;
  --card-hover: #171b24;
  --input-bg: #0f1218;
  --ring: rgb(124 108 246 / 0.35);
  --header-bg: rgb(10 12 16 / 0.72);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-subtle: #eef0f4;
  --fg: #171a21;
  --fg-muted: #5d6572;
  --accent: #6d5ce7;
  --accent-soft: rgb(109 92 231 / 0.10);
  --border: #e2e5ea;
  --card: #ffffff;
  --card-hover: #f2f4f8;
  --input-bg: #ffffff;
  --ring: rgb(109 92 231 / 0.30);
  --header-bg: rgb(247 248 250 / 0.72);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection { background: var(--accent-soft); }

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; font-weight: 700; }

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.85; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font: 500 0.92rem var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--card-hover); border-color: var(--fg-muted); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff 12%); border-color: var(--accent); box-shadow: var(--shadow-md); }

/* Inputs */
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input:not([type]), textarea, select {
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--fg);
  font: 400 0.92rem var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--fg-muted); opacity: 0.7; }

button:not(.btn):not([class]) {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font: 500 0.88rem var(--font);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
button:not(.btn):not([class]):hover { background: var(--card-hover); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

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

/* Dashboard launcher cards (dashboard.astro renders these via set:html, so they
   need global styles — Astro scoped CSS never matches injected HTML). */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 600px) {
  .dash-cards { grid-template-columns: 1fr; }
}
.dash-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.9rem;
  padding: 1.4rem 1.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease,
    box-shadow .15s ease, transform .15s ease;
}
.dash-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.dash-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.6rem; height: 2.6rem;
  background: var(--accent-soft);
  border-radius: calc(var(--radius) - 2px);
  color: var(--accent);
}
.dash-card-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}
.dash-card-label {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
}
.dash-card-desc {
  font-size: 0.85rem; color: var(--fg-muted); line-height: 1.45;
}

/* Notes app (notes.astro + notes/deleted.astro render cards via set:html, so
   they need global styles — Astro scoped CSS never matches injected HTML). */
.note-head { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1.1rem; }
.note-head h2 { font-size: 1.25rem; margin: 0; display: flex; align-items: center; }
.note-head h2::after { content: ''; flex: 1; height: 1px; background: var(--border); margin-left: 0.5rem; }
.note-head #note-search { flex: 1; max-width: 16rem; }
.note-search-status { font-size: 0.8rem; color: var(--fg-muted); margin: 0 0 0.6rem; }
.trash-link { font-size: 0.8rem; color: var(--fg-muted); text-decoration: none; margin-right: auto; } .trash-link:hover { color: var(--fg); text-decoration: underline; }
[hidden] { display: none !important; }
.note-card { display: flex; gap: 0.65rem; align-items: center; padding: 0.7rem 0.9rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }
.note-card:hover { background: var(--card-hover); }
.note-text { flex: 1; min-width: 0; }
.note-text strong { font-weight: 600; display: block; }
.note-snippet { display: block; color: var(--fg-muted); font-size: 0.85rem; }
.note-rel { display: inline-block; margin-top: 0.2rem; font-size: 0.75rem; color: var(--fg-muted); }
.icon-btn-sm { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem; flex-shrink: 0; background: none; border: none; border-radius: 6px; color: var(--fg-muted); font-size: 0.85rem; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }
.icon-btn-sm:hover { background: rgb(220 38 38 / 0.12); color: #dc2626; }
.note-trash-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.note-empty { padding: 2rem; text-align: center; color: var(--fg-muted); background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }
#notes { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }

/* Note editor page (/notes/new, /notes/:id/edit) — full-viewport, mobile-first */
.note-editor-page { display: flex; flex-direction: column; gap: 0.6rem; min-height: calc(100dvh - 9.5rem); padding-bottom: env(safe-area-inset-bottom); }
.note-editor-heading { margin: 0; font-size: 1.15rem; }
.note-editor-page #note-title { width: 100%; font-size: 1.05rem; }
.note-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.35rem; background: var(--card-subtle, rgba(128,128,128,0.08)); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.note-toolbar button { min-width: 1.9rem; height: 1.9rem; padding: 0 0.3rem; font-size: 0.8rem; line-height: 1; border: 1px solid var(--border); border-radius: 0.35rem; background: var(--card); color: var(--fg); cursor: pointer; }
.note-toolbar button:hover { border-color: var(--accent, #555); }
/* Table-edit buttons are only shown while the cursor is inside a table */
.note-toolbar .tb-hidden { display: none; }
.note-toolbar button.active { background: var(--accent-soft, rgba(128,128,128,0.25)); border-color: var(--accent, #555); }
#note-editor-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#note-editor { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 0.6rem 0.8rem; background: var(--card); flex: 1 1 auto; min-height: 12rem; }
.tiptap { outline: none; }
.tiptap p { margin: 0.35rem 0; }
.tiptap h2 { font-size: 1.25rem; font-weight: 700; margin: 0.6rem 0 0.3rem; }
.tiptap h3 { font-size: 1.1rem; font-weight: 600; margin: 0.5rem 0 0.25rem; }
.tiptap ul, .tiptap ol { padding-left: 1.4rem; margin: 0.35rem 0; }
.tiptap blockquote { border-left: 3px solid var(--border); margin: 0.5rem 0; padding: 0.2rem 0.8rem; color: var(--fg-muted); }
.tiptap pre { background: rgba(128,128,128,0.12); border: 1px solid var(--border); border-radius: 0.35rem; padding: 0.5rem 0.7rem; font-family: ui-monospace, monospace; font-size: 0.85rem; margin: 0.5rem 0; }
.tiptap code { font-family: ui-monospace, monospace; font-size: 0.88em; background: rgba(128,128,128,0.12); padding: 0.1rem 0.3rem; border-radius: 0.25rem; }
.tiptap pre code { background: none; padding: 0; }
.tiptap table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; }
.tiptap th, .tiptap td { border: 1px solid var(--border); padding: 0.35rem 0.55rem; text-align: left; }
.tiptap th { background: rgba(128,128,128,0.12); font-weight: 600; }
.tiptap a { color: var(--accent, #4a90d9); text-decoration: underline; }
.tiptap p.is-editor-empty:first-child::before { content: attr(data-placeholder); float: left; color: var(--fg-muted); pointer-events: none; }
.note-editor-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding-bottom: env(safe-area-inset-bottom); }

/* Note toast */
.note-toast { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #dc2626; color: #fff; padding: 0.55rem 1rem; border-radius: var(--radius-sm); font-size: 0.88rem; z-index: 110; display: none; }
.note-toast.show { display: block; }

/* Confirm dialog (modular — src/lib/confirm-dialog.ts) */
.confirm-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.55); display: none; align-items: center; justify-content: center; z-index: 120; backdrop-filter: blur(2px); }
.confirm-backdrop.open { display: flex; }
.confirm-card { width: min(400px, calc(100vw - 2rem)); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.25rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom)); animation: confirm-pop 0.14s ease-out; }
@keyframes confirm-pop { from { opacity: 0; transform: scale(0.96) translateY(4px); } to { opacity: 1; transform: none; } }
.confirm-icon { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 0.8rem; background: var(--accent-soft); color: var(--accent); }
.confirm-icon.danger { background: rgb(220 38 38 / 0.12); color: #dc2626; }
.confirm-title { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.confirm-msg { margin: 0 0 1rem; color: var(--fg-muted); font-size: 0.9rem; line-height: 1.5; }
.confirm-card:not(:has(.confirm-msg)) .confirm-title { margin-bottom: 1rem; }
.confirm-foot { display: flex; justify-content: flex-end; gap: 0.5rem; }
.btn-danger-confirm { background: #dc2626; border-color: #dc2626; }
.btn-danger-confirm:hover { background: #b91c1c; border-color: #b91c1c; }


/* Task page (rows are client-injected -> no data-astro-cid, must be global) */
#task-form { display: flex; align-items: center; gap: 0.6rem; }
#task-input { flex: 1; min-width: 0; }
#task-search { flex: 0 1 200px; min-width: 110px; margin-left: auto; }
.tasks-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.tasks-list li { display: flex; flex-wrap: wrap; gap: 0.4rem 0.65rem; align-items: center; padding: 0.7rem 0.9rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); transition: background-color 0.15s ease, border-color 0.15s ease; }
.tasks-list li:hover { background: var(--card-hover); }
.tasks-list li.done { opacity: 0.55; }
.tasks-list li.done .task-title { text-decoration: line-through; }
.tasks-list .task-title { flex: 1; min-width: 0; }
.tasks-list li.section-empty { background: none; border: 1px dashed var(--border); box-shadow: none; color: var(--fg-muted); font-size: 0.88rem; padding: 0.75rem 0.9rem; }
.tasks-list input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; cursor: pointer; }
.tasks-list .due-badge { flex-shrink: 0; font-size: 0.72rem; font-weight: 600; line-height: 1; padding: 0.28rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.due-overdue { background: rgb(220 38 38 / 0.14); color: #dc2626; }
.due-today { background: rgb(22 163 74 / 0.14); color: #16a34a; }
.due-tomorrow { background: rgb(217 119 6 / 0.16); color: #d97706; }
.due-week { background: rgb(124 58 237 / 0.14); color: #7c3aed; }
.due-far { background: var(--border); color: var(--fg-muted); }
.tasks-list .task-title { cursor: pointer; }
.tasks-list .task-title:hover { text-decoration: underline; text-decoration-color: var(--fg-muted); }
.tasks-list .task-title-input { flex: 1; min-width: 0; font-size: 0.95rem; padding: 0.25rem 0.5rem; margin: 0; }
.tasks-list .due-badge { cursor: pointer; }
.tasks-list .due-badge:hover { filter: brightness(0.94); }
.tasks-list .due-set { flex-shrink: 0; background: none; border: 1px dashed var(--border); color: var(--fg-muted); font-size: 0.72rem; font-weight: 600; padding: 0.22rem 0.5rem; border-radius: 999px; cursor: pointer; }
.tasks-list .due-set:hover { color: var(--accent); border-color: var(--accent); }
.tasks-list .due-edit { display: inline-flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.tasks-list .due-input { font-size: 0.75rem; padding: 0.18rem 0.3rem; margin: 0; }
.tasks-list .due-clear { background: none; border: none; color: var(--fg-muted); font-size: 0.72rem; cursor: pointer; padding: 0.1rem 0.2rem; }
.tasks-list .due-clear:hover { color: #dc2626; }

/* ---- Reminders ---- */
.rem-tabs { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); }
.rem-tab { border: none; background: transparent; color: var(--fg-muted); font: 500 0.85rem var(--font); padding: 0.35rem 0.8rem; border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }
.rem-tab:hover { color: var(--fg); }
.rem-tab.active { background: var(--accent); color: #fff; }

.rem-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md, 12px); padding: 0.85rem 1rem; margin-bottom: 0.65rem; }
.rem-card.completed { opacity: 0.55; }
.rem-card.completed .rem-text { text-decoration: line-through; }
.rem-main { flex: 1; min-width: 0; }
.rem-text-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.rem-text { font-weight: 500; }
.rem-rec-badge { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); white-space: nowrap; }
.rem-meta { display: flex; gap: 0.5rem; font-size: 0.78rem; color: var(--fg-muted); margin-top: 0.2rem; }
.rem-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }

.btn-sm { padding: 0.3rem 0.65rem; font: 500 0.8rem var(--font); border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--fg); cursor: pointer; transition: background-color 0.15s ease; }
.btn-sm:hover { background: var(--card-hover); }
.rem-done { background: var(--accent); border-color: var(--accent); color: #fff; }
.rem-done:hover { background: color-mix(in srgb, var(--accent) 88%, #fff 12%); }

.rem-empty { text-align: center; padding: 3.5rem 1rem; }
.rem-empty-icon { font-size: 3.5rem; margin-bottom: 0.8rem; }
.rem-empty p { margin: 0.25rem 0; }

.rem-form-card { flex-direction: column; align-items: stretch; }
.rem-form-card h3 { margin: 0 0 0.9rem; font-size: 1.05rem; }
.rem-form-card label { display: block; margin-bottom: 0.8rem; }
.rem-form-card label:has(> span) > span { display: block; font-size: 0.75rem; font-weight: 500; color: var(--fg-muted); margin-bottom: 0.3rem; }
.rem-form-card input, .rem-form-card select { width: 100%; }
.rem-form-card input.num { width: 4rem; }
.rem-row { display: flex; gap: 0.8rem; }
.rem-row .grow { flex: 1; }
.rem-rec { border-top: 1px solid var(--border); padding-top: 0.8rem; margin: 0.8rem 0; }
.rem-rec-label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--fg-muted); margin-bottom: 0.5rem; }
.rem-rec-freq { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.rem-rec-freq label { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.92rem; font-weight: 450; }
.rem-rec-freq input[type="radio"], .rem-rec-freq input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.rem-rec-details { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.7rem; padding: 0.7rem 0.8rem; background: var(--input-bg); border-radius: var(--radius-sm); }
.rem-rec-details label.inline { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.rem-rec-details label.inline > span { font-size: 0.8rem; margin: 0; }
.rem-day-picker { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.day-btn { padding: 0.25rem 0.6rem; font-size: 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--fg-muted); cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }
.day-btn:hover { color: var(--fg); }
.day-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.rem-form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.4rem; }
.rem-error { background: color-mix(in srgb, #dc2626 10%, transparent); color: #dc2626; padding: 0.55rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.88rem; }

/* In-app due reminders dialog (Base.astro, client-fetched) */
.rem-banner-stack { position: fixed; inset: 0; z-index: 120; display: none; align-items: center; justify-content: center; background: rgb(0 0 0 / 0.55); backdrop-filter: blur(2px); overflow-y: auto; padding: 1rem; }
.rem-banner-stack.open { display: flex; flex-direction: column; gap: 0.6rem; }
.rem-banner { pointer-events: auto; display: flex; align-items: center; gap: 0.6rem; max-width: 760px; width: min(760px, calc(100vw - 2rem)); flex-shrink: 0; background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 0.6rem 1rem; animation: confirm-pop 0.14s ease-out; }
.rem-banner .bell { font-size: 1.3rem; }
.rem-banner .btext { flex: 1; font-size: 0.95rem; color: var(--fg); }
.rem-banner .bactions { display: flex; gap: 0.4rem; flex-shrink: 0; }
