:root {
  --bg: #0b1020;
  --bg-grad-1: #0f172a;
  --bg-grad-2: #1e1b4b;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%, rgba(99, 102, 241, 0.25), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(236, 72, 153, 0.2), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg));
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.6);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: -2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.field > span {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.field input,
.field textarea,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color var(--transition), background var(--transition),
    box-shadow var(--transition);
  width: 100%;
  font-size: 15px;
  color: var(--text);
  resize: vertical;
}

.field textarea {
  min-height: 54px;
  font-family: inherit;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(255, 255, 255, 0.06);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field input[type="datetime-local"] {
  color-scheme: dark;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform var(--transition), background var(--transition),
    border-color var(--transition), opacity var(--transition);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(99, 102, 241, 0.7);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
}

.btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner.warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.banner.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

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

.reminders-header .section-title {
  margin-bottom: 0;
}

.badge {
  background: var(--accent-soft);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.reminders-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reminders-list.compact .reminder-item {
  padding: 12px 14px;
  opacity: 0.7;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  animation: slide-in 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reminder-main {
  flex: 1;
  min-width: 0;
}

.reminder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reminder-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.reminder-note {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
  word-break: break-word;
  white-space: pre-wrap;
}

.reminder-when {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.reminder-when svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.reminder-time {
  font-variant-numeric: tabular-nums;
}

.reminder-relative {
  color: var(--text-muted);
}

.reminder-relative.soon {
  color: var(--warning);
}

.reminder-relative.overdue {
  color: var(--danger);
}

.reminder-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.icon-btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-dim);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
  max-width: 320px;
  margin: 0 auto;
}

.past details summary {
  cursor: pointer;
  list-style: none;
}

.past details summary::-webkit-details-marker {
  display: none;
}

.past details[open] summary {
  margin-bottom: 12px;
}

.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 12px;
}

.toast-root {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 100;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toast-in 200ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  max-width: calc(100% - 32px);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
}
.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

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

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

/* ============================================================================
   Header actions
============================================================================ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
}

.pill-success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.pill-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.pill-muted {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
}

.tag-tone {
  background: rgba(236, 72, 153, 0.12);
  border-color: rgba(236, 72, 153, 0.3);
  color: #fbcfe8;
}

/* ============================================================================
   Settings dialog
============================================================================ */
.settings-dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #151a2e, #0f1426);
  color: var(--text);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
}

.hint code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

.settings-status {
  font-size: 13px;
  min-height: 20px;
  color: var(--text-dim);
}

.settings-status.success { color: #86efac; }
.settings-status.error { color: #fca5a5; }

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ============================================================================
   Takeover screen \u2014 full-screen acknowledgement UI
============================================================================ */
.takeover {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.takeover.active {
  opacity: 1;
  pointer-events: auto;
}

.takeover-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 600px at 50% 30%, rgba(236, 72, 153, 0.35), transparent 60%),
    radial-gradient(900px 600px at 50% 80%, rgba(99, 102, 241, 0.35), transparent 60%),
    rgba(8, 10, 24, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: takeover-bg 8s ease-in-out infinite alternate;
}

@keyframes takeover-bg {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(30deg); }
}

.takeover-content {
  position: relative;
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: 40px 24px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7);
  animation: takeover-pop 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes takeover-pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.takeover-pulse {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.6);
  animation: pulse 1.6s ease-out infinite;
}

.takeover-pulse::before {
  content: "";
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/><path d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/></svg>") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/><path d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/></svg>") center/contain no-repeat;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.6); transform: scale(1); }
  70% { box-shadow: 0 0 0 26px rgba(236, 72, 153, 0); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); transform: scale(1); }
}

.takeover-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.takeover-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  word-break: break-word;
}

.takeover-note {
  color: var(--text-dim);
  margin-bottom: 12px;
  font-size: 15px;
  white-space: pre-wrap;
}

.takeover-counter {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(236, 72, 153, 0.15);
  color: #fbcfe8;
  border: 1px solid rgba(236, 72, 153, 0.3);
  margin-bottom: 24px;
}

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

.takeover-btn {
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform var(--transition), filter var(--transition), background var(--transition);
}

.takeover-btn:active { transform: scale(0.98); }

.takeover-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 14px 30px -10px rgba(236, 72, 153, 0.6);
  font-size: 16px;
  padding: 16px 20px;
}

.takeover-btn-primary:hover { filter: brightness(1.05); }

.takeover-btn-secondary {
  background: var(--surface-2);
}

.takeover-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px;
}

.takeover-btn-ghost:hover { color: var(--text); }

@media (max-width: 520px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
  }
  .brand-text h1 { font-size: 18px; }
}
