/* Client App Stylesheet (ADR-149) */
:root {
  --bg: #0f141c;
  --surface: #18202c;
  --surface-alt: #222d3d;
  --border: #2c3a4e;
  --text: #e6edf3;
  --text-muted: #8b9bb4;
  --primary: #2563eb;  /* white text on it: 5.2:1 (3b82f6 was 3.7:1) */
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.brand { font-size: 1.15rem; font-weight: 700; color: #fff; text-decoration: none; }
.brand-sub { color: #93c5fd; }

nav { display: flex; align-items: center; gap: 1rem; }
nav a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; font-weight: 500; }
nav a:hover, nav a.active { color: #fff; }
nav form { display: inline; }

.container {
  max-width: 1000px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.alert-info { background: rgba(59, 130, 246, 0.15); border: 1px solid var(--primary); color: #93c5fd; }
.alert-danger { background: var(--danger-bg); border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: var(--success-bg); border: 1px solid var(--success); color: #6ee7b7; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #2f3e54; }
.btn-danger { background: var(--danger-bg); border-color: var(--danger); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-success { background: var(--success-bg); border-color: var(--success); color: #6ee7b7; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill-band { background: var(--surface-alt); color: #cbd5e1; border: 1px solid var(--border); }
.pill-sent { background: var(--success-bg); color: #6ee7b7; border: 1px solid var(--success); }
.pill-replied { background: var(--warning-bg); color: #fcd34d; border: 1px solid var(--warning); }
.pill-stop { background: var(--danger-bg); color: #fca5a5; border: 1px solid var(--danger); }

/* Creator Card */
.creator-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.creator-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.creator-title { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.creator-handle { font-size: 1.25rem; font-weight: 700; color: #fff; }
.creator-name { font-size: 1rem; color: var(--text-muted); }
.creator-email { font-size: 0.9rem; color: #93c5fd; }
.creator-why { font-style: italic; color: #cbd5e1; font-size: 0.95rem; margin-top: 0.25rem; }

.card-actions-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface-alt);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}

.messages-list { display: flex; flex-direction: column; gap: 0.75rem; }
.message-box {
  background: #111722;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
}
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.message-subject { font-weight: 600; color: #fff; margin-bottom: 0.35rem; font-size: 0.95rem; }
.message-body {
  width: 100%;
  background: #090d13;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.4;
}
.message-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; margin-bottom: 0.35rem; font-weight: 600; font-size: 0.9rem; color: #cbd5e1; }
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  background: #111722;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

/* Card and Page Utility Classes (ADR-149 strict CSP, zero inline styles) */
.card-login {
  max-width: 480px;
  margin: 3rem auto;
}
.card-settings {
  max-width: 600px;
  margin: 1.5rem auto;
}
.card-title {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}
.card-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.btn-block {
  width: 100%;
}
.form-reply-inline {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}
.form-action-right {
  display: inline;
  margin-left: auto;
}
.btn-copy-inline {
  margin-left: 0.5rem;
}
.empty-card {
  text-align: center;
  padding: 3rem 1rem;
}
.empty-card-text {
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.settings-version {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---- P0 UI: list, tabs, drawer, detail (plan 2026-10-28) ---- */
:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.mut { color: var(--text-muted); }
.copy-fallback { position: fixed; top: -9999px; left: -9999px; }

.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { padding: 0.5rem 0.9rem; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 600; }
.tab:hover { color: #fff; }
.tab-on { color: #fff; border-bottom-color: var(--primary); }
.tab-n { background: var(--surface-alt); border-radius: 9999px; padding: 0.05rem 0.45rem; font-size: 0.8rem; margin-left: 0.25rem; }

.creator-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1.5rem; }
.creator-row { display: flex; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); }
.creator-row:last-child { border-bottom: 0; }
.creator-row:hover { background: var(--surface-alt); }
.creator-row:has(input:checked) { background: #1d3557; }
.row-pick { display: flex; align-items: center; justify-content: center; width: 48px; min-height: 44px; margin: 0; cursor: pointer; flex: none; }
.row-pick input { width: 20px; height: 20px; }
.row-link {
  flex: 1; min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) 100px minmax(0, 3fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 1rem 0.6rem 0;
  min-height: 64px;
  color: var(--text);
  text-decoration: none;
}
.row-link[aria-current="true"] { background: #1d3557; }
.row-who { display: flex; flex-direction: column; min-width: 0; }
.row-who .creator-handle { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-who .creator-name { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-why { color: #cbd5e1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-bottom: 1.5rem; }

/* Detail (drawer body and full page) */
.detail { display: flex; flex-direction: column; gap: 1rem; }
.d-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem; }
.d-head h2 { font-size: 1.4rem; }
.d-head h2:focus { outline: none; }
.contact-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.d-section { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.d-section h3 { display: inline; font-size: 1rem; }
.d-section summary { cursor: pointer; margin-bottom: 0.5rem; }
.timeline { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.form-inline { display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.message-footer .form-inline { margin-left: auto; }

/* Drawer: native dialog, right panel on desktop, full screen sheet on mobile */
dialog.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(540px, 100vw);
  max-width: none;
  height: 100vh;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  flex-direction: column;
}
dialog.drawer[open] { display: flex; }
dialog.drawer::backdrop { background: rgba(0, 0, 0, 0.5); }
.drawer-bar { display: flex; gap: 0.5rem; justify-content: flex-end; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); }
.drawer-close { margin-left: 0.5rem; }
.drawer-body { padding: 1rem; overflow-y: auto; flex: 1; }

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #0b3d2e;
  border: 1px solid var(--success);
  color: #d1fae5;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}
.toast-on { opacity: 1; }

@media (max-width: 720px) {
  .row-link {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who band" "why why";
    gap: 0.25rem 0.75rem;
  }
  .row-who { grid-area: who; }
  .row-band { grid-area: band; justify-self: end; }
  .row-why { grid-area: why; }
  dialog.drawer { width: 100vw; border-left: 0; }
  .message-footer .form-inline { margin-left: 0; }
}

/* ---- P1 UI: header, search, settings, touch targets, focus ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nav-email { color: var(--text-muted); font-size: 0.8rem; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--primary); }
.header-inner { flex-wrap: nowrap; gap: 0.75rem; }
.brand { white-space: nowrap; }
input, select, textarea, button, summary, a { outline-offset: 2px; }
.search-form { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.search-form input[type="search"] {
  flex: 1 1 220px; max-width: 360px; background: #111722; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 0.55rem 0.75rem; font-size: 0.95rem;
}
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1rem 0.25rem; margin-bottom: 1.25rem; }
legend { padding: 0 0.5rem; font-weight: 700; color: #fff; }
.help { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.settings-note { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }

@media (max-width: 720px) {
  header { padding: 0.5rem 0.75rem; }
  .brand-sub, .nav-email { display: none; }
  nav { gap: 0.5rem; }
  nav > a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.25rem; }
  .btn, .btn-sm, .tab, input[type="text"], input[type="email"], input[type="search"], select { min-height: 44px; }
  .tab { display: inline-flex; align-items: center; }
  summary { padding-block: 0.7rem; }
}

/* ---- V1: week groups, selection, export ---- */
.js-only { display: none; }
.js .js-only { display: inline-flex; }
.week { margin-bottom: 1.5rem; }
.week-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.week-title { font-size: 1.05rem; }
.pick-all { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; margin: 0; min-height: 44px; cursor: pointer; }
.pick-all input { width: 20px; height: 20px; }
.export-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.week .creator-list { margin-bottom: 0; }


/* ---- Options Catalog (ADR-149 / ADR-151 amendment, 2026-10-29) ---- */
.catalog-container {
  margin-bottom: 0.75rem;
}
.catalog-scroll {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: #111722;
}
.catalog-filter-box {
  margin-bottom: 0.5rem;
}
.catalog-filter {
  width: 100%;
  max-width: 360px;
  min-height: 44px;
  background: #111722;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
}
.catalog-group {
  margin-bottom: 1rem;
}
.catalog-group:last-child {
  margin-bottom: 0.25rem;
}
.catalog-group-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
  margin-bottom: 0.35rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border);
}
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.25rem 0.5rem;
}
.catalog-item {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
}
.catalog-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.catalog-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.catalog-item span {
  font-size: 0.9rem;
  line-height: 1.2;
}
.catalog-item-custom span {
  font-style: italic;
  color: #93c5fd;
}
.add-new-group {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.add-new-group input[type="text"] {
  min-height: 44px;
  width: 100%;
  max-width: 360px;
}
.is-hidden {
  display: none !important;
}
