/* WhatsApp Reminders — clean light workspace.
   Palette: pure white surface, olive-leaf primary (hue 113), umber accent. */

:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.002 120);
  --surface-2: oklch(0.948 0.003 120);
  --border: oklch(0.908 0.004 120);
  --ink: oklch(0.24 0.02 113);
  --muted: oklch(0.465 0.018 113);
  --primary: oklch(0.56 0.14 113);
  --primary-strong: oklch(0.48 0.13 113);
  --primary-soft: oklch(0.955 0.035 113);
  --accent: oklch(0.45 0.09 60);
  --accent-soft: oklch(0.955 0.02 60);
  --danger: oklch(0.5 0.18 27);
  --danger-soft: oklch(0.96 0.02 27);
  --warn-soft: oklch(0.95 0.04 85);
  --warn-ink: oklch(0.42 0.1 75);

  --space-xs: 4px; --space-sm: 8px; --space-md: 12px;
  --space-lg: 16px; --space-xl: 24px; --space-2xl: 40px;

  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.9375rem;
  --text-lg: 1.0625rem; --text-xl: 1.375rem;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px oklch(0.24 0.02 113 / 0.06);
  --shadow-md: 0 2px 8px oklch(0.24 0.02 113 / 0.09);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-toast: 30;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-kerning: normal;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.rail {
  display: flex; flex-direction: column; gap: var(--space-xl);
  padding: var(--space-xl) var(--space-lg);
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.main { padding: var(--space-xl) var(--space-2xl) var(--space-2xl); max-width: 980px; width: 100%; margin: 0 auto; }

/* ---------- rail ---------- */
.brand { display: flex; align-items: center; gap: var(--space-md); }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 600; font-size: var(--text-base); line-height: 1.2; }
.brand-sub { font-size: var(--text-xs); color: var(--muted); }

.rail-section { display: flex; flex-direction: column; gap: var(--space-md); flex: 1; }
.rail-heading { display: flex; align-items: center; justify-content: space-between; }
.rail-heading h2 { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

.account-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.account-item {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background 150ms var(--ease);
}
.account-item:hover { background: var(--surface-2); }
.account-info { flex: 1; min-width: 0; }
.account-label { font-weight: 500; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-status { font-size: var(--text-xs); color: var(--muted); }
.account-item .icon-btn { opacity: 0; }
.account-item:hover .icon-btn, .account-item:focus-within .icon-btn { opacity: 1; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.connected { background: var(--primary); }
.status-dot.connecting { background: oklch(0.75 0.02 110); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.qr { background: oklch(0.72 0.13 85); }
.status-dot.logged_out { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }

.rail-foot { border-top: 1px solid var(--border); padding-top: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-sm); align-items: flex-start; }
.rail-user-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: var(--space-sm); }
.rail-user-row .rail-note { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-note { font-size: var(--text-xs); color: var(--muted); }

.rail-empty { font-size: var(--text-sm); color: var(--muted); padding: var(--space-sm) var(--space-md); }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-lg); margin-bottom: var(--space-xl); }
.topbar h1 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; }
.topbar-sub { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.btn-primary, .btn-secondary, .btn-ghost {
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-weight: 500; font-size: var(--text-sm);
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  color: var(--muted); position: relative;
  transition: background 150ms var(--ease), color 150ms var(--ease), opacity 150ms var(--ease);
}
.icon-btn::before { content: ''; position: absolute; inset: -8px; } /* 44px touch target */
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }

:is(button, input, select, textarea, a):focus { outline: none; }
:is(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- events board ---------- */
.event-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-lg);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}
.event-card.paused { background: var(--surface); }
.event-head { display: flex; align-items: center; gap: var(--space-md); }
.event-name { font-size: var(--text-lg); font-weight: 600; flex: 1; min-width: 0; }
.event-name .paused-tag { font-size: var(--text-xs); font-weight: 500; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 2px 8px; margin-left: 8px; vertical-align: 2px; }
.event-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); margin-top: var(--space-sm); }
.chip {
  font-size: var(--text-xs); font-weight: 500;
  background: var(--surface-2); border-radius: 99px; padding: 2px 10px;
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.chip.account-chip { background: var(--accent-soft); color: var(--accent); }

.send-timeline { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-lg); border-top: 1px solid var(--border); padding-top: var(--space-md); }
.send-row { display: grid; grid-template-columns: 14px 130px 1fr auto; align-items: center; gap: var(--space-md); padding: 3px 0; font-size: var(--text-sm); }
.send-marker { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border); justify-self: center; }
.send-marker.sent { background: var(--primary); border-color: var(--primary); }
.send-marker.failed, .send-marker.partial { background: var(--danger); border-color: var(--danger); }
.send-marker.missed { background: var(--surface-2); border-color: var(--surface-2); }
.send-marker.due { border-color: var(--primary); animation: pulse 1.4s ease-in-out infinite; }
.send-label { color: var(--muted); }
.send-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.send-status { font-size: var(--text-xs); font-weight: 500; color: var(--muted); text-align: right; }
.send-status.sent { color: var(--primary-strong); }
.send-status.failed, .send-status.partial { color: var(--danger); }
.send-status.warn { color: var(--warn-ink); }

/* empty state */
.empty-state {
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
  padding: var(--space-2xl); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-md);
}
.empty-state h2 { font-size: var(--text-lg); font-weight: 600; }
.empty-state p { color: var(--muted); font-size: var(--text-sm); max-width: 40ch; }

/* ---------- composer ---------- */
.composer { display: flex; flex-direction: column; gap: var(--space-xl); max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.field-narrow { max-width: 280px; }
.field label, .type-switch legend { font-weight: 500; font-size: var(--text-sm); }
.label-line { display: flex; justify-content: space-between; align-items: baseline; }
.hint { font-size: var(--text-xs); color: var(--muted); }

input[type="text"], input[type="search"], input[type="tel"], input[type="datetime-local"], input[type="number"], input[type="password"], select, textarea {
  font: inherit; font-size: var(--text-sm);
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color 150ms var(--ease);
}
:is(input, select, textarea):hover { border-color: var(--muted); }
textarea { resize: vertical; min-height: 60px; }
input::placeholder, textarea::placeholder { color: var(--muted); }

.type-switch { border: none; padding: 0; margin: 0; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 3px; gap: 3px; margin-top: 6px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-opt span {
  display: inline-block; padding: 5px 14px; border-radius: 7px;
  font-size: var(--text-sm); font-weight: 500; color: var(--muted);
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.seg-opt input:checked + span { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* group picker */
.group-picker { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.group-picker input { border: none; border-bottom: 1px solid var(--border); border-radius: 0; width: 100%; }
.group-options { max-height: 210px; overflow-y: auto; padding: var(--space-xs); }
.group-opt {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); cursor: pointer;
}
.group-opt:hover { background: var(--surface); }
.group-opt input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.group-opt .g-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-empty { padding: var(--space-lg); font-size: var(--text-sm); color: var(--muted); text-align: center; }
#mention-field.field-disabled .seg { opacity: 0.45; }
#mention-field.field-disabled .seg-opt input { cursor: not-allowed; }
#mention-field.field-disabled > .hint:last-child { visibility: hidden; }

.picker-head { padding: var(--space-sm) var(--space-sm) 0; }
.seg-sm { margin-top: 0; padding: 2px; }
.seg-sm .seg-opt span { padding: 3px 12px; font-size: var(--text-xs); }

/* add a person by phone number */
.add-person {
  display: flex; align-items: center; gap: var(--space-md);
  width: 100%; padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 500; color: var(--primary-strong);
  text-align: left;
  transition: background 150ms var(--ease);
}
.add-person:hover:not(:disabled) { background: var(--primary-soft); }
.add-person:disabled { color: var(--muted); cursor: default; }
.add-person svg { width: 15px; height: 15px; flex-shrink: 0; }
.add-person-error { padding: 2px 10px 6px; font-size: var(--text-xs); color: var(--danger); }
.person-glyph { display: inline-flex; color: var(--muted); flex-shrink: 0; }
.person-glyph svg { width: 14px; height: 14px; }
.chip.person-chip { display: inline-flex; align-items: center; gap: 5px; }
.chip.person-chip .person-glyph svg { width: 12px; height: 12px; }

/* attachment field */
.attach-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--space-sm);
  width: 100%; padding: 10px 12px;
  border: 1px dashed var(--border); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; color: var(--muted);
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}
.attach-btn:hover:not(:disabled) { border-color: var(--muted); color: var(--ink); }
.attach-btn:disabled { cursor: default; }
.attach-btn svg { width: 15px; height: 15px; }
.attach-chip {
  display: flex; align-items: center; gap: var(--space-md);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}
.attach-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); flex-shrink: 0; }
.attach-file-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0;
}
.attach-file-icon svg { width: 20px; height: 20px; }
.attach-meta { flex: 1; min-width: 0; }
.attach-name { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-size { font-size: var(--text-xs); color: var(--muted); }
.chip.media-chip { display: inline-flex; align-items: center; gap: 5px; }
.chip.media-chip svg { width: 12px; height: 12px; color: var(--muted); flex-shrink: 0; }

/* reminder sequence editor */
.reminder-list { display: flex; flex-direction: column; gap: var(--space-sm); margin-top: var(--space-lg); }
.reminder-row {
  display: grid; grid-template-columns: auto 110px 1fr auto; align-items: center; gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: opacity 150ms var(--ease);
}
.reminder-row.off { opacity: 0.55; background: var(--surface); }
.reminder-row input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }
.reminder-when { font-size: var(--text-sm); font-weight: 500; }
.reminder-row input[type="text"] { width: 100%; }
.field label.quiet-toggle { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); font-size: var(--text-sm); font-weight: 400; }
.quiet-toggle input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }
.quiet-toggle input[type="time"] { font: inherit; font-size: var(--text-sm); color: var(--ink); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 8px; }

.editor-intro { margin-bottom: var(--space-lg); max-width: 65ch; }
.preview-placeholder { font-size: var(--text-sm); color: var(--muted); }

.preview { margin-top: var(--space-lg); border-radius: var(--radius-md); background: var(--surface); padding: var(--space-md) var(--space-lg); display: flex; flex-direction: column; gap: 4px; }
.preview:empty { display: none; }
.preview-line { display: flex; gap: var(--space-md); font-size: var(--text-sm); }
.preview-time { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.preview-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-heading { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 2px; }

.form-error, .login-error { color: var(--danger); font-size: var(--text-sm); background: var(--danger-soft); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); }
.composer-actions { display: flex; gap: var(--space-md); }

/* ---------- link view ---------- */
.link-panel { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-xl); max-width: 760px; align-items: start; }
.link-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-xl); display: flex; flex-direction: column; gap: var(--space-md); }
.link-card h2 { font-size: var(--text-base); font-weight: 600; }
.qr-holder { display: flex; justify-content: center; }
.qr-holder img { width: 240px; height: 240px; border-radius: var(--radius-md); image-rendering: pixelated; }
.qr-skeleton { width: 240px; height: 240px; border-radius: var(--radius-md); background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.link-divider { display: flex; align-items: center; height: 100%; color: var(--muted); font-size: var(--text-sm); padding-top: 100px; }
.pair-label { font-weight: 500; font-size: var(--text-sm); margin-bottom: calc(var(--space-sm) * -1); }
.pair-row { display: flex; gap: var(--space-sm); margin: 0; }
.pair-row input { flex: 1; min-width: 0; }
.pair-row input[aria-invalid="true"] { border-color: var(--danger); }
.qr-paused { width: 240px; height: 240px; display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--space-xl); border: 1px dashed var(--border); border-radius: var(--radius-md); }
.pair-code { font-size: 1.75rem; font-weight: 600; letter-spacing: 0.18em; text-align: center; padding: var(--space-md); background: var(--primary-soft); border-radius: var(--radius-md); font-variant-numeric: tabular-nums; }
.link-success { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--space-2xl); }
.link-success .big-check { width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }

/* ---------- toasts ---------- */
.toast-region { position: fixed; bottom: var(--space-xl); right: var(--space-xl); display: flex; flex-direction: column; gap: var(--space-sm); z-index: var(--z-toast); }
.toast {
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius-md); padding: 10px 16px;
  font-size: var(--text-sm); box-shadow: var(--shadow-md);
  animation: toast-in 200ms var(--ease);
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- skeleton / loading ---------- */
.skeleton-card { height: 120px; border-radius: var(--radius-lg); background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin-bottom: var(--space-lg); }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; background: var(--surface); padding: var(--space-xl) var(--space-lg); }
.login-card {
  width: min(400px, 100%);
  background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-2xl) var(--space-2xl) var(--space-2xl);
  animation: login-in 300ms var(--ease);
}
@keyframes login-in { from { opacity: 0; transform: translateY(8px); } }
.login-brand { margin-bottom: var(--space-2xl); }
.login-title { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--space-xs); }
.login-sub { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-xl); }
.login-card form { display: flex; flex-direction: column; gap: var(--space-md); }
.login-label { font-weight: 500; font-size: var(--text-sm); margin-bottom: -6px; }
.login-card form input.invalid { border-color: var(--danger); }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: var(--radius-md);
  transition: color 150ms var(--ease);
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle svg[hidden] { display: none; }
.login-submit { padding: 10px 16px; margin-top: var(--space-sm); }
.login-switch { margin-top: var(--space-xl); font-size: var(--text-sm); color: var(--muted); display: flex; gap: 6px; }
.login-switch-btn { color: var(--primary-strong); font-weight: 500; padding: 0; }
.login-switch-btn:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: column; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: var(--space-xl) var(--space-lg); }
  .field-row { grid-template-columns: 1fr; }
  .link-panel { grid-template-columns: 1fr; }
  .link-divider { padding: 0; justify-content: center; height: auto; }
  .send-row { grid-template-columns: 14px 110px 1fr; }
  .send-status { grid-column: 2 / -1; text-align: left; padding-left: 0; }
}

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