/* ============================================================
   PublishHQ — Global Styles
   ============================================================ */

/* ---------- Theme: Blush & Sage (default) ---------- */
:root,
[data-theme="blush"] {
  --bg-main: #FAF7F5;
  --bg-secondary: #F6EEEB;
  --bg-card: #FFFDFC;
  --bg-card-elevated: #F8F0EE;

  --text-primary: #2F2F2F;
  --text-secondary: #6B605B;
  --text-muted: #736862;

  --border: #E8DDD9;
  --divider: #DDD1CD;

  --accent-primary: #EFD6D2;
  --accent-hover: #D8A7A0;
  --accent-light-bg: #F7E8E5;
  --accent-text: #7A5E59;

  --accent-secondary: #BFCABF;
  --accent-secondary-hover: #7E927F;
  --accent-secondary-light-bg: #EEF3EF;
  --accent-secondary-text: #566556;

  --btn-primary-bg: #D8A7A0;
  --btn-primary-text: #542F2A;
  --btn-primary-hover-bg: #7A5E59;
  --btn-primary-hover-text: #FFFFFF;
  --btn-danger-bg: #8A4740;
  --btn-danger-text: #FFFFFF;

  --success: #B1BEB2;
  --success-text: #4E5F4F;
  --warning: #E2B59B;
  --warning-text: #7A5642;
  --error: #D8A7A0;
  --error-text: #7A4A44;
  --info: #9BAE9C;
  --info-text: #4A5C4A;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10);
}

/* ---------- Theme: Rainbow Pastel ----------
   Soft lilac-gray menu with a rainbow stripe; the colour lives in the stripe,
   the menu icons, progress bars and charts, never in big panels. */
[data-theme="rainbow"] {
  --bg-main: #FAFAFA;
  --bg-secondary: #F1EFF3;
  --bg-card: #FFFFFF;
  --bg-card-elevated: #F6F4FA;

  --text-primary: #2F2D3A;
  --text-secondary: #5A5768;
  --text-muted: #63606F;

  --border: #ECEAF0;
  --divider: #E1DEE8;

  --accent-primary: #D8D4F2;
  --accent-hover: #8F87C4;
  --accent-light-bg: #ECE9F8;
  --accent-text: #463E86;

  --accent-secondary: #C9DDF2;
  --accent-secondary-hover: #6F9BCB;
  --accent-secondary-light-bg: #E0EBF8;
  --accent-secondary-text: #264E7C;

  --btn-primary-bg: #C9DDF2;
  --btn-primary-text: #1F3A5C;
  --btn-primary-hover-bg: #B5CFEC;
  --btn-primary-hover-text: #1F3A5C;
  --btn-danger-bg: #8A3A22;
  --btn-danger-text: #FFFFFF;

  --success: #A8D0B6;
  --success-text: #2F5C40;
  --warning: #EDC690;
  --warning-text: #77501C;
  --error: #F2B9A3;
  --error-text: #8A3A22;
  --info: #A6C6E8;
  --info-text: #264E7C;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10);

  --rainbow: linear-gradient(90deg, #F6D1C1, #F3D8B5, #F1E4B3, #CFE3D6, #C9DDF2, #D8D4F2);
}

/* ---------- Theme: Neutral ---------- */
[data-theme="neutral"] {
  --bg-main: #F6F5F3;
  --bg-secondary: #ECEBE7;
  --bg-card: #FFFFFF;
  --bg-card-elevated: #F0EFEC;

  --text-primary: #2E3135;
  --text-secondary: #5D636B;
  --text-muted: #626871;

  --btn-primary-bg: #487197;
  --btn-primary-text: #FFFFFF;
  --btn-primary-hover-bg: #2E5378;
  --btn-primary-hover-text: #FFFFFF;
  --btn-danger-bg: #8A4740;
  --btn-danger-text: #FFFFFF;

  --border: #E4E7EA;
  --divider: #D8DCE0;

  --accent-primary: #7C92A6;
  --accent-hover: #487197;
  --accent-light-bg: #E6EDF3;
  --accent-text: #2E5378;

  --accent-secondary: #A9BAB0;
  --accent-secondary-hover: #708F80;
  --accent-secondary-light-bg: #E8EFEB;
  --accent-secondary-text: #445547;

  --success: #7D9482;
  --success-text: #3B5343;
  --warning: #C1AF88;
  --warning-text: #6B5B34;
  --error: #C08B85;
  --error-text: #7A3E38;
  --info: #7C92A6;
  --info-text: #2E5378;
}

/* ---------- Theme: Dark ---------- */
[data-theme="dark"] {
  --bg-main: #1A1B1D;
  --bg-secondary: #222426;
  --bg-card: #36383B;
  --bg-card-elevated: #42454A;

  --text-primary: #FFFFFF;
  --text-secondary: #FCFBF8;
  --text-muted: #DBD8D3;

  --btn-primary-bg: #A3AE99;
  --btn-primary-text: #1E2419;
  --btn-primary-hover-bg: #C0C9B6;
  --btn-primary-hover-text: #1E2419;
  --btn-danger-bg: #C07A6B;
  --btn-danger-text: #2B1512;

  --border: #4A4D51;
  --divider: #42454A;

  --accent-primary: #8E9B84;
  --accent-hover: #A3AE99;
  --accent-light-bg: #394137;
  --accent-text: #DFE5D9;

  --accent-secondary: #A3AE99;
  --accent-secondary-hover: #C0C9B6;
  --accent-secondary-light-bg: #3B4239;
  --accent-secondary-text: #DFE5D9;

  --success: #8FA784;
  --success-text: #DFE5D9;
  --warning: #C5A37A;
  --warning-text: #FFE9C6;
  --error: #C07A6B;
  --error-text: #FFD9CE;
  --info: #8294A8;
  --info-text: #D6DFEC;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
}

/* ---------- Base Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}
img, svg, canvas { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }

/* ---------- Typography Helpers ---------- */
.font-display { font-family: 'DM Serif Display', Georgia, serif; letter-spacing: -0.01em; }
.text-display-xl { font-family: 'DM Serif Display', Georgia, serif; font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; }
.text-display-lg { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.5rem; line-height: 1.3; letter-spacing: -0.01em; }
.text-display-md { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.25rem; line-height: 1.35; letter-spacing: -0.01em; }
.text-body-lg { font-size: 1rem; line-height: 1.6; }
.text-body-md { font-size: 0.9375rem; line-height: 1.5; }
.text-body-sm { font-size: 0.875rem; line-height: 1.4; }
.text-body-xs { font-size: 0.8125rem; line-height: 1.3; font-weight: 300; }
.text-label {
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.text-stat { font-size: 1.75rem; line-height: 1; font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-error { color: var(--error-text); }

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  transition: transform 0.25s ease, width 0.25s ease;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-primary);
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 0.9375rem;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.125rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.sidebar-author-name {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
}
.sidebar-nav-group {
  margin-bottom: 12px;
}
.sidebar-nav-group-label {
  padding: 6px 10px;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  min-height: 40px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
}
@media (hover: hover) { .sidebar-nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
} }
.sidebar-nav-item.active {
  background: var(--accent-light-bg);
  color: var(--accent-text);
}
.sidebar-nav-item svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke-width: 2;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.app-topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar-hamburger {
  width: 40px; height: 40px;
  display: none;
  align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-secondary);
}
@media (hover: hover) { .topbar-hamburger:hover { background: var(--bg-secondary); color: var(--text-primary); } }
.topbar-title {
  flex: 1;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.125rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topbar-icon-btn {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}
@media (hover: hover) { .topbar-icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); } }
.topbar-icon-btn svg { width: 20px; height: 20px; }

/* Pen-name switcher */
.topbar-scope-select {
  width: auto;
  max-width: 11rem;
  height: 36px;
  padding-top: 0; padding-bottom: 0;
  font-size: 0.8125rem;
  text-overflow: ellipsis;
}
.topbar-scope-select.is-filtered {
  background-color: var(--accent-light-bg, var(--bg-secondary));
  border-color: var(--accent-hover);
  color: var(--text-primary);
  font-weight: 500;
}
@media (max-width: 480px) {
  .topbar-scope-select { max-width: 6.25rem; padding-left: 8px; padding-right: 26px; background-position: right 8px center; }
  .topbar-actions { gap: 4px; }
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }
@media (hover: hover) { ::-webkit-scrollbar-thumb:hover { background: var(--divider); } }

/* ---------- Card ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
@media (hover: hover) { .card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); } }
.card-elevated { background: var(--bg-card-elevated); }
.card-flush { padding: 0; overflow: hidden; }
.card-sm { padding: 14px; border-radius: 12px; }
.card-lg { padding: 28px; border-radius: 20px; }

/* ---------- Inputs ---------- */
.input-base, .input, .select, .textarea {
  width: 100%;
  padding: 9px 13px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 80px; resize: vertical; padding: 10px 13px; line-height: 1.5; }
.input:focus, .input-base:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-light-bg);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

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

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field-help { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  min-height: 40px;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid transparent;
  font-weight: 600;
}
@media (hover: hover) { .btn-primary:hover { background: var(--btn-primary-hover-bg); color: var(--btn-primary-hover-text); text-decoration: none; } }

/* Solid destructive button (confirm dialogs) — per-theme AA-safe pair */
.btn-danger-solid {
  background: var(--btn-danger-bg) !important;
  color: var(--btn-danger-text) !important;
}
@media (hover: hover) { .btn-danger-solid:hover { filter: brightness(0.92); } }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
@media (hover: hover) { .btn-secondary:hover { background: var(--accent-light-bg); text-decoration: none; } }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 0.8125rem;
}
@media (hover: hover) { .btn-ghost:hover { background: var(--bg-secondary); color: var(--text-primary); text-decoration: none; } }

.btn-danger {
  background: transparent;
  color: var(--error-text);
  border: 1px solid var(--border);
}
@media (hover: hover) { .btn-danger:hover { background: rgba(216, 167, 160, 0.12); text-decoration: none; } }

.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 0.8125rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; min-height: 48px; font-size: 0.9375rem; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 40px; padding: 0; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge-sm { font-size: 0.6875rem; padding: 2px 7px; }
.badge-lg { font-size: 0.8125rem; padding: 4px 11px; }
.badge-idea { background: var(--bg-secondary); color: var(--text-secondary); }
.badge-writing { background: var(--accent-secondary-light-bg); color: var(--accent-secondary-text); }
.badge-editing { background: rgba(226, 181, 155, 0.25); color: var(--warning-text); }
.badge-formatting { background: var(--accent-light-bg); color: var(--accent-text); }
.badge-published { background: rgba(177, 190, 178, 0.35); color: var(--success-text); }
.badge-paused { background: var(--bg-secondary); color: var(--text-muted); }
.badge-idea-dot::before,
.badge-writing-dot::before,
.badge-editing-dot::before,
.badge-formatting-dot::before,
.badge-published-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-accent { background: var(--accent-light-bg); color: var(--accent-text); }
.badge-success { background: rgba(177,190,178,0.35); color: var(--success-text); }
.badge-warning { background: rgba(226,181,155,0.30); color: var(--warning-text); }
.badge-error { background: rgba(216,167,160,0.30); color: var(--error-text); }
.badge-info { background: var(--accent-secondary-light-bg); color: var(--accent-secondary-text); }

/* Priority dots */
.priority-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.priority-high { background: var(--error); }
.priority-medium { background: var(--warning); }
.priority-low { background: var(--text-muted); }

/* ---------- Progress bar ---------- */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-hover);
  border-radius: 9999px;
  transition: width 0.4s ease-out;
  width: 0;
}
.progress-fill.progress-secondary { background: var(--accent-secondary-hover); }
.progress-fill.progress-success { background: var(--success); }
.progress-fill.progress-warning { background: var(--warning); }
.progress-lg { height: 10px; }

/* ---------- Page structure ---------- */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.page-subtitle {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.page-hero-ribbon {
  position: relative;
  padding: 4px 0 24px;
}
.page-hero-ribbon::before {
  content: '';
  position: absolute;
  left: -24px; right: -24px; top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-primary) 0%, transparent 100%);
}
.section {
  margin-bottom: 32px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.section-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.375rem;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* ---------- Grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto-260 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-auto-200 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-dashboard { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; }
.grid-dashboard > * { min-width: 0; }

@media (max-width: 1023px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-dashboard { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto-260 { grid-template-columns: 1fr; }
  .grid-4-mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px; }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.hidden { display: none !important; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.rounded { border-radius: 10px; }
.rounded-lg { border-radius: 12px; }
.rounded-full { border-radius: 9999px; }
.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }

/* ---------- Focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}
.modal {
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease-out;
  overflow: hidden;
}
.modal-md { max-width: 720px; }
.modal-lg { max-width: 960px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.modal-close {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}
@media (hover: hover) { .modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); } }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-card);
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
  font-size: 0.875rem;
}
.toast.hiding { animation: toastOut 0.15s ease-in forwards; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success-text); }
.toast-error .toast-icon { color: var(--error-text); }
.toast-info .toast-icon { color: var(--info-text); }
.toast-warning .toast-icon { color: var(--warning-text); }

@media (max-width: 640px) {
  #toast-container { bottom: 80px; right: 12px; left: 12px; }
  .toast { min-width: 0; max-width: none; }
}

/* ---------- Banners ---------- */
.banner {
  padding: 12px 20px;
  background: var(--accent-light-bg);
  color: var(--accent-text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
}
.banner-warning { background: rgba(226,181,155,0.25); color: var(--warning-text); }
.banner button { color: inherit; }
.banner-actions { margin-left: auto; display: flex; gap: 6px; }
.banner-inline { border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.banner-inline > span { flex: 1 1 16rem; }
.banner-inline .banner-actions { flex-wrap: wrap; }

/* ---------- Free demo (inert unless html.is-demo) ---------- */
html.is-demo .demo-hide { display: none !important; }
.demo-bar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 8px 12px;
  padding: 6px 16px;
  background: var(--accent-light-bg);
  color: var(--accent-text);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
.demo-card { border: 2px solid var(--accent-hover); background: var(--accent-light-bg); }
@media print { .demo-bar { display: none !important; } }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state-icon {
  width: 56px; height: 56px;
  color: var(--accent-primary);
  margin: 0 auto 16px;
}
.empty-state-icon svg { width: 56px; height: 56px; }
.empty-state-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.empty-state-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Stat card ---------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-card-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent-light-bg);
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg { width: 16px; height: 16px; }
.stat-card-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
}
.stat-card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.stat-card-trend {
  font-size: 0.75rem;
  font-weight: 500;
}
.stat-card-trend.up { color: var(--success-text); }
.stat-card-trend.down { color: var(--error-text); }

/* ---------- Book card ---------- */
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
@media (hover: hover) { .book-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); } }
.book-cover {
  aspect-ratio: 3/4;
  background: var(--bg-secondary);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  width: 100%; height: 100%;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem;
  color: var(--accent-text);
  background: linear-gradient(160deg, var(--accent-primary), var(--accent-secondary-light-bg));
}
.book-card-body {
  padding: 14px 16px 16px;
  display: flex; flex-direction: column;
  gap: 6px;
  flex: 1;
}
.book-card-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.book-card-meta { font-size: 0.75rem; color: var(--text-secondary); }
.book-status-corner {
  position: absolute;
  top: 8px; right: 8px;
}

/* ---------- Task item ---------- */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: box-shadow 0.15s ease;
}
@media (hover: hover) { .task-item:hover { box-shadow: var(--shadow-sm); } }
.task-checkbox {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  background: var(--bg-card);
}
@media (hover: hover) { .task-checkbox:hover { border-color: var(--accent-hover); } }
.task-checkbox.checked {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  animation: checkPulse 0.25s ease-out;
}
.task-checkbox svg { width: 14px; height: 14px; opacity: 0; }
.task-checkbox.checked svg { opacity: 1; }
.task-body { flex: 1; min-width: 0; }
.task-name {
  font-size: 0.875rem;
  color: var(--text-primary);
  word-wrap: break-word;
}
.task-item.completed .task-name {
  color: var(--text-muted);
  text-decoration: line-through;
  transition: color 0.25s ease;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  align-items: center;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(4px); }
}
@keyframes checkPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.animate-in { animation: fadeInUp 0.25s ease-out; }
.animate-fade { animation: fadeIn 0.2s ease-out; }

/* Loading skeletons */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-card-elevated) 50%, var(--bg-secondary) 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) { .tab:hover { color: var(--text-primary); } }
.tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-hover);
}

/* ---------- Segmented ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-secondary);
  border-radius: 10px;
}
.segmented button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented button.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ---------- Chips (tag input) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-light-bg);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 500;
}
.chip-close {
  cursor: pointer;
  opacity: 0.7;
  margin-left: 2px;
}
@media (hover: hover) { .chip-close:hover { opacity: 1; } }

.chip-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  min-height: 42px;
}
.chip-input-wrap input {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.875rem;
  color: var(--text-primary);
  padding: 2px 4px;
}

/* ---------- Table ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
@media (hover: hover) { .data-table tr:hover td { background: var(--bg-secondary); } }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 40;
  justify-content: space-around;
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  padding: 4px;
  transition: color 0.15s ease;
}
.bottom-nav-item.active { color: var(--accent-text); }
.bottom-nav-item svg { width: 22px; height: 22px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 49;
}
.sidebar-backdrop.visible { display: block; }

/* ---------- Mobile responsive ----------
   Phones, and any touch screen under 1024px or without a mouse (iPads too), get the
   bottom bar and the slide-out menu. The bar's clearance padding is in this same
   block, so the two can never disagree. */
@media (max-width: 767px), (max-width: 1023px) and (pointer: coarse), (hover: none) and (pointer: coarse) {
  .app-sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 50;
    transform: translateX(-100%);
  }
  .app-sidebar.open { transform: translateX(0); }
  .topbar-hamburger { display: flex; }
  .app-main { padding: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .app-topbar { padding: 0 16px; }
  .bottom-nav { display: flex; }
  .page-hero-ribbon::before { left: -16px; right: -16px; }
  .page-title { font-size: 1.5rem; }
  .section-title { font-size: 1.25rem; }
}

/* ---------- Larger text option ----------
   On the root, as a percentage: every font size is in rem, so all text grows.
   Never a px size here (that would ignore the reader's own browser setting). */
html[data-fontsize="large"] { font-size: 112.5%; }

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

/* ---------- Utility: circular progress ring ---------- */
.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring-track { stroke: var(--bg-secondary); }
.progress-ring-fill {
  stroke: var(--accent-hover);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease-out;
}
.progress-ring-text {
  position: absolute;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--text-primary);
}

/* ---------- Sparkline ---------- */
.sparkline {
  width: 100%;
  height: 32px;
  display: block;
}

/* ---------- Utility inputs ---------- */
.checkbox {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) { .checkbox:hover { border-color: var(--accent-hover); } }
.checkbox.checked {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.checkbox svg { width: 12px; height: 12px; opacity: 0; }
.checkbox.checked svg { opacity: 1; }

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--divider);
  margin: 24px 0;
}

/* ---------- Kanban board ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.kanban-col {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  min-height: 200px;
}
.kanban-col-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}
.kanban-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
@media (hover: hover) { .kanban-item:hover { box-shadow: var(--shadow-sm); } }
@media (max-width: 767px) { .kanban { grid-template-columns: 1fr; } }

/* ---------- Habit contribution grid ---------- */
.habit-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 2px;
  overflow-x: auto;
  padding: 8px 0;
}
.habit-cell {
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--bg-secondary);
}
.habit-cell.level-1 { background: var(--accent-primary); opacity: 0.5; }
.habit-cell.level-2 { background: var(--accent-primary); }
.habit-cell.level-3 { background: var(--accent-hover); }
.habit-cell.level-4 { background: var(--accent-text); }

/* ---------- Utility scroll ---------- */
.scroll-x { overflow-x: auto; }

/* ---------- Editor: cover concept ---------- */
.cover-thumb {
  aspect-ratio: 3/4;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Confirm dialog ---------- */
.confirm-body {
  padding: 20px 24px 8px;
}
.confirm-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  margin-bottom: 8px;
}
.confirm-text { font-size: 0.875rem; color: var(--text-secondary); }

/* ---------- Utility color swatches ---------- */
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-block;
  cursor: pointer;
}

/* ---------- Print ---------- */
@media print {
  /* Hide all app chrome — only the page's data should print */
  .app-sidebar,
  .app-topbar,
  .bottom-nav,
  .sidebar-backdrop,
  #toast-container,
  #modal-root,
  #update-banner,
  #install-banner,
  .btn,
  .segmented,
  .tabs {
    display: none !important;
  }

  /* Undo the fixed-height app shell so content paginates naturally */
  .app-shell,
  .main-wrapper,
  .app-main {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  .app-main { padding: 0 !important; }

  body {
    background: #fff !important;
    color: #000 !important;
  }
  .card, .stat-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }
  .table-wrap { overflow: visible !important; border: none !important; }
  tr { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ---------- Rainbow Pastel signature ---------- */
[data-theme="rainbow"] .app-sidebar {
  background: #EFEDF5;
  border-top: 6px solid transparent;
  border-image: var(--rainbow) 1;
}
[data-theme="rainbow"] .sidebar-nav-item { color: #36305E; }
[data-theme="rainbow"] .sidebar-nav-group-label { color: #5A5574; }
@media (hover: hover) { [data-theme="rainbow"] .sidebar-nav-item:hover { background: #E6E3F0; color: #2B2552; } }
[data-theme="rainbow"] .sidebar-nav-item.active {
  background: #FFFFFF;
  color: #2B2552;
  box-shadow: inset 3px 0 0 #6B62A8;
}
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+1) svg { color: #7E3B22; }
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+2) svg { color: #77501C; }
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+3) svg { color: #655619; }
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+4) svg { color: #2F5C40; }
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+5) svg { color: #264E7C; }
[data-theme="rainbow"] .sidebar-nav-item:nth-child(6n+6) svg { color: #463E86; }
[data-theme="rainbow"] .progress-fill:not(.progress-success):not(.progress-warning):not(.progress-secondary) {
  background: var(--rainbow);
  box-shadow: inset 0 0 0 1px rgba(143, 135, 196, 0.35);
}

/* Theme picker swatches (Settings) */
.theme-swatches { display: flex; justify-content: center; gap: 4px; margin-top: 8px; }
.theme-swatches span { width: 14px; height: 14px; border-radius: 9999px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }

/* ---------- Dashboard welcome panel ----------
   Greeting + today's line on the left, the illustration (components/hero-art.js)
   on the right. Laid out by the panel's own width (container query): narrow
   panels keep the picture small so the stat cards stay near the top. */
.ph-hero {
  container-type: inline-size;
  position: relative;
  overflow: hidden;
  background: var(--hero-bg);
  border: 1px solid var(--hero-border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.ph-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  padding: 16px;
}
.ph-hero__text { min-width: 0; }
.ph-hero__art { line-height: 0; }
.ph-hero__art svg { width: 100%; height: auto; display: block; }
.ph-hero__eyebrow {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--hero-eyebrow-bg);
  color: var(--hero-eyebrow-text);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.ph-hero__title {
  margin-top: 8px;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem; line-height: 1.2;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.ph-hero__line { margin-top: 4px; font-size: 0.875rem; line-height: 1.45; color: var(--text-secondary); }
@container (min-width: 600px) {
  .ph-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); gap: 16px 24px; padding: 20px 28px; }
  .ph-hero__title { font-size: 1.875rem; }
  .ph-hero__line { font-size: 0.9375rem; }
}
@container (min-width: 880px) {
  .ph-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
}
@media print {
  .ph-hero { background: #fff; box-shadow: none; }
  .ph-hero__art { display: none; }
  .ph-hero__grid { grid-template-columns: minmax(0, 1fr); }
}

/* Illustration fills (classes, not fill attributes: Safari won't resolve var() there) */
.pa-glow { fill: var(--art-glow); }
.pa-shadow { fill: var(--art-shadow); opacity: 0.08; }
.pa-leaf { fill: var(--art-leaf); } .pa-leaf2 { fill: var(--art-leaf2); }
.pa-pot { fill: var(--art-pot); }
.pa-pot-band { fill: var(--art-ink); opacity: 0.08; }
.pa-book1 { fill: var(--art-book1); } .pa-book2 { fill: var(--art-book2); } .pa-book3 { fill: var(--art-book3); }
.pa-pages { fill: var(--art-page); opacity: 0.9; }
.pa-spine { fill: var(--art-ink); opacity: 0.08; }
.pa-cover { fill: var(--art-book2); }
.pa-page { fill: var(--art-page); }
.pa-fold { fill: var(--art-ink); opacity: 0.1; }
.pa-ribbon { fill: var(--art-ribbon); }
.pa-card { fill: var(--art-page); }
.pa-line { fill: var(--art-ink); opacity: 0.22; } .pa-line--soft { opacity: 0.12; }
.pa-bar1 { fill: var(--art-bar1); } .pa-bar2 { fill: var(--art-bar2); }
.pa-bar3 { fill: var(--art-bar3); } .pa-bar4 { fill: var(--art-bar4); }
.pa-trend { fill: none; stroke: var(--art-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.pa-dot { fill: var(--art-ink); opacity: 0.7; }
.pa-mug { fill: var(--art-mug); }
.pa-mug-band { fill: var(--art-page); opacity: 0.55; }
.pa-handle { fill: none; stroke: var(--art-mug); stroke-width: 6; }
.pa-spark { fill: var(--art-spark); } .pa-spark--soft { opacity: 0.55; }
.pa-steam path {
  fill: none; stroke: var(--art-steam); stroke-width: 3; stroke-linecap: round; opacity: 0.45;
  animation: paSteam 3.6s ease-in-out infinite;
}
.pa-steam path + path { animation-delay: 1.8s; }
@keyframes paSteam {
  0% { transform: translateY(5px); opacity: 0; }
  40% { opacity: 0.45; }
  100% { transform: translateY(-7px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .pa-steam path { animation: none; } }

/* Welcome-panel tokens per theme: pointed at each theme's own colours, so a
   theme edit carries through. Paper stays light in Dark, so its ink is dark. */
:root, [data-theme="blush"] {
  --hero-bg: linear-gradient(118deg, var(--accent-light-bg) 0%, var(--bg-card) 55%, var(--accent-secondary-light-bg) 100%);
  --hero-border: var(--border); --hero-eyebrow-bg: var(--accent-light-bg); --hero-eyebrow-text: var(--accent-text);
  --art-glow: var(--accent-primary); --art-page: var(--bg-card); --art-ink: var(--text-primary); --art-steam: var(--text-muted); --art-shadow: var(--text-primary);
  --art-book1: var(--accent-hover); --art-book2: var(--accent-secondary); --art-book3: var(--warning); --art-ribbon: var(--accent-secondary-hover);
  --art-bar1: var(--accent-primary); --art-bar2: var(--accent-secondary); --art-bar3: var(--accent-hover); --art-bar4: var(--accent-secondary-hover);
  --art-mug: var(--accent-secondary-hover); --art-leaf: var(--accent-secondary-hover); --art-leaf2: var(--accent-secondary); --art-pot: var(--warning); --art-spark: var(--accent-hover);
}
[data-theme="rainbow"] {
  --hero-bg: linear-gradient(118deg, var(--accent-light-bg) 0%, var(--bg-card) 55%, var(--accent-secondary-light-bg) 100%);
  --hero-border: var(--border); --hero-eyebrow-bg: var(--accent-light-bg); --hero-eyebrow-text: var(--accent-text);
  --art-glow: #F1E4B3; --art-page: var(--bg-card); --art-ink: var(--text-primary); --art-steam: var(--text-muted); --art-shadow: var(--text-primary);
  --art-book1: var(--error); --art-book2: var(--info); --art-book3: var(--warning); --art-ribbon: var(--accent-hover);
  --art-bar1: var(--error); --art-bar2: var(--warning); --art-bar3: var(--success); --art-bar4: var(--accent-secondary-hover);
  --art-mug: var(--accent-primary); --art-leaf: var(--success); --art-leaf2: #CFE3D6; --art-pot: var(--warning); --art-spark: var(--accent-hover);
}
[data-theme="neutral"] {
  --hero-bg: linear-gradient(118deg, var(--accent-light-bg) 0%, var(--bg-card) 55%, var(--accent-secondary-light-bg) 100%);
  --hero-border: var(--border); --hero-eyebrow-bg: var(--accent-light-bg); --hero-eyebrow-text: var(--accent-text);
  --art-glow: var(--accent-light-bg); --art-page: var(--bg-card); --art-ink: var(--text-primary); --art-steam: var(--text-muted); --art-shadow: var(--text-primary);
  --art-book1: var(--accent-hover); --art-book2: var(--accent-secondary); --art-book3: var(--warning); --art-ribbon: var(--error);
  --art-bar1: var(--accent-primary); --art-bar2: var(--accent-secondary); --art-bar3: var(--accent-hover); --art-bar4: var(--accent-secondary-hover);
  --art-mug: var(--accent-secondary-hover); --art-leaf: var(--accent-secondary-hover); --art-leaf2: var(--accent-secondary); --art-pot: var(--warning); --art-spark: var(--accent-hover);
}
[data-theme="dark"] {
  --hero-bg: linear-gradient(118deg, var(--accent-light-bg) 0%, var(--bg-card) 55%, var(--bg-card-elevated) 100%);
  --hero-border: var(--border); --hero-eyebrow-bg: var(--accent-light-bg); --hero-eyebrow-text: var(--accent-text);
  --art-glow: var(--bg-card-elevated); --art-page: #E8E6E3; --art-ink: #25272E; --art-steam: var(--text-muted); --art-shadow: #000000;
  --art-book1: var(--error); --art-book2: var(--accent-primary); --art-book3: var(--warning); --art-ribbon: var(--info);
  --art-bar1: var(--info); --art-bar2: var(--success); --art-bar3: var(--warning); --art-bar4: var(--error);
  --art-mug: var(--info); --art-leaf: var(--success); --art-leaf2: var(--accent-secondary-hover); --art-pot: var(--warning); --art-spark: var(--warning);
}

/* ---------- Money pages (calculator, profit, payments, tax year) ---------- */
.link-card { text-decoration: none; color: inherit; transition: border-color 0.15s ease; }
@media (hover: hover) { .link-card:hover { border-color: var(--accent-hover); text-decoration: none; } }
.calc-grid { align-items: start; }
.calc-result .calc-big {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2.125rem; line-height: 1.1; color: var(--text-primary);
}
.calc-result-warn { border-color: var(--error-text); }
.calc-lines { margin-top: 10px; padding-left: 18px; list-style: disc; line-height: 1.6; color: var(--text-secondary); font-size: 0.875rem; }
.calc-lines li + li { margin-top: 4px; }
.calc-result + .calc-result, .card + .calc-result { margin-top: 12px; }
.row-muted td { color: var(--text-secondary); }
.tax-grid { align-items: start; }
.tax-table { width: 100%; }
.tax-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tax-table .tax-total td { font-weight: 600; border-top: 2px solid var(--divider); }
@media print {
  .no-print { display: none !important; }
  .tax-grid { display: block; }
  .tax-grid > .card, .tax-summary { break-inside: avoid; margin-bottom: 12px; }
}

/* ---------- Phase 4: keyword history and book timeline ---------- */
.kv-row { padding: 10px 0; border-top: 1px solid var(--divider); }
.kv-row:first-of-type { border-top: 0; }
.chip-added { background: var(--accent-secondary-light-bg); color: var(--accent-secondary-text); box-shadow: inset 0 0 0 1px var(--accent-secondary-hover); }
.timeline-table td { vertical-align: top; }
.tl-spike td:first-child { box-shadow: inset 3px 0 0 var(--accent-secondary-hover); }
.tl-events { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 0.8125rem; }
.tl-events li { padding-left: 14px; position: relative; color: var(--text-secondary); }
.tl-events li::before { content: ''; position: absolute; left: 0; top: 0.5em; width: 7px; height: 7px; border-radius: 9999px; background: var(--accent-hover); }
.tl-events .tl-launch::before { background: var(--success-text); }
.tl-events .tl-promo::before { background: var(--warning-text); }
.tl-events .tl-ad::before { background: var(--accent-secondary-hover); }
.tl-events .tl-keywords::before { background: var(--info-text); }
.tl-events .tl-newsletter::before { background: var(--accent-text); }
.tl-events .tl-arc::before, .tl-events .tl-rank::before { background: var(--text-muted); }

/* ---------- Phase 5: release planner, writing schedule, audiobooks, direct ---------- */
.banner-danger { background: rgba(216,167,160,0.30); color: var(--error-text); }
.rp-countdown { text-align: right; }
.rp-countdown__num { font-family: 'DM Serif Display', serif; font-size: 2.125rem; line-height: 1.1; color: var(--accent-text); }
@media (max-width: 640px) { .rp-countdown { text-align: left; } }
.rp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 12px; }
.rp-stat { padding: 10px 12px; border: 1px solid var(--divider); border-radius: 10px; min-width: 0; }
.rp-stat__value { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); }
.rp-ms { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--divider); }
.rp-ms:first-child { border-top: 0; }
.rp-ms__check { flex: none; }
.rp-ms__date { text-align: right; font-size: 0.875rem; white-space: nowrap; }
.rp-ms__actions { display: flex; gap: 2px; }
.rp-ms--done .rp-ms__main .font-medium { text-decoration: line-through; color: var(--text-muted); }
.rp-ms--deadline .rp-ms__check { width: 22px; display: inline-flex; justify-content: center; color: var(--error-text); }
.rp-ms--deadline .rp-ms__check svg { width: 18px; height: 18px; }
@media (max-width: 520px) {
  .rp-ms { grid-template-columns: auto minmax(0, 1fr) auto; }
  .rp-ms__date { grid-column: 2; text-align: left; }
  .rp-ms__actions { grid-column: 3; grid-row: 1; }
}
.wt-day { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; padding: 8px 10px; border-radius: 9999px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.wt-day input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wt-day.is-on { background: var(--accent-secondary-light-bg); color: var(--accent-secondary-text); border-color: var(--accent-secondary-hover); }
.wt-day:focus-within { outline: 2px solid var(--focus-ring, var(--accent-text)); outline-offset: 2px; }
.wt-sprint.is-running { border-color: var(--accent-secondary-hover); }
.wt-sprint__clock { font-family: 'DM Serif Display', serif; font-size: 2.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.ab-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.ab-steps li { font-size: 0.75rem; padding: 3px 9px; border-radius: 9999px; border: 1px solid var(--divider); color: var(--text-muted); }
.ab-steps li.is-done { color: var(--accent-secondary-text); background: var(--accent-secondary-light-bg); border-color: transparent; }
.ab-steps li.is-now { color: var(--accent-text); background: var(--accent-light-bg); border-color: var(--accent-hover); font-weight: 600; }
.dp-pl td { padding-top: 6px; padding-bottom: 6px; }
.dp-pl .text-right { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dp-pl .dp-sub td { font-weight: 600; border-top: 1px solid var(--divider); }
.dp-pl .dp-total td { font-weight: 700; border-top: 2px solid var(--divider); }
@media print { .wt-sprint, #wt-sprint { display: none !important; } }

/* ---------- Phase 6: Luna Sync (Settings card + linking modals) ---------- */
.sync-code {
  font-family: 'DM Mono', 'SF Mono', Consolas, monospace;
  font-size: 2.25rem; font-weight: 500; letter-spacing: 0.12em;
  text-align: center; margin: 4px 0 12px; color: var(--text-primary);
  background: var(--bg-card-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.sync-code-input { font-family: 'DM Mono', 'SF Mono', Consolas, monospace; font-size: 1.5rem; letter-spacing: 0.15em; text-align: center; }
.sync-pics { display: flex; justify-content: center; gap: 20px; margin: 8px 0 16px; flex-wrap: wrap; }
.sync-pics > span { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sync-pic { font-size: 2.5rem; line-height: 1; }
.sync-key {
  display: block; width: 100%; text-align: left;
  font-family: 'DM Mono', 'SF Mono', Consolas, monospace; font-size: 0.9375rem; line-height: 1.6; word-break: break-all;
  background: var(--bg-card-elevated); color: var(--text-primary); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
.sync-key-hidden { color: transparent; text-shadow: 0 0 8px var(--text-muted); cursor: pointer; user-select: none; }
.sync-status { display: inline-block; white-space: normal; line-height: 1.45; padding: 6px 12px; }
.sync-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-row-end { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }


/* ---------- Release fixes (2.6.1, from the v2.6.0 audit) ---------- */
/* A display rule (.flex, .grid) must never beat the hidden attribute */
[hidden] { display: none !important; }

/* iOS would otherwise inflate text by itself */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* iPhone Safari draws date and month boxes at its own width and ignores width:100%,
   pushing the page sideways. Its value also centres, and an empty box collapses. */
input[type="date"], input[type="time"], input[type="datetime-local"],
input[type="month"], input[type="week"] {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; min-width: 0; max-width: 100%; text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.25em; }
/* Grid and flex children may shrink (a long value wraps instead of pushing the page out); buttons keep their size */
.grid > *, .flex > :not(.btn):not(button) { min-width: 0; }
.modal > *, .modal-body { min-width: 0; }   /* a dialog's body is a flex child too */
.main-wrapper, .app-main { min-width: 0; }   /* the page column sits in the shell's flex row */

/* iPhone zooms in on any field under 16px */
@media (pointer: coarse) {
  .input, .select, .textarea, .input-base { font-size: max(16px, 1rem); }
}

/* Tabs wrap onto a second line instead of hiding behind an invisible scroll bar */
.tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }

/* Calendar week: seven columns on a wide screen, a list of days on a phone */
.cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-week-chip { white-space: normal; text-align: left; justify-content: flex-start; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .cal-week > .card { min-height: 0 !important; }
}

/* Print: dark ink on white whatever the theme (Dark would print pale text) */
@media print {
  html[data-theme], :root {
  --bg-main: #FAF7F5;
  --bg-secondary: #F6EEEB;
  --bg-card: #FFFDFC;
  --bg-card-elevated: #F8F0EE;
  --text-primary: #2F2F2F;
  --text-secondary: #6B605B;
  --text-muted: #736862;
  --border: #E8DDD9;
  --divider: #DDD1CD;
  --accent-primary: #EFD6D2;
  --accent-hover: #D8A7A0;
  --accent-light-bg: #F7E8E5;
  --accent-text: #7A5E59;
  --accent-secondary: #BFCABF;
  --accent-secondary-hover: #7E927F;
  --accent-secondary-light-bg: #EEF3EF;
  --accent-secondary-text: #566556;
  --btn-primary-bg: #D8A7A0;
  --btn-primary-text: #542F2A;
  --btn-primary-hover-bg: #7A5E59;
  --btn-primary-hover-text: #FFFFFF;
  --btn-danger-bg: #8A4740;
  --btn-danger-text: #FFFFFF;
  --success: #B1BEB2;
  --success-text: #4E5F4F;
  --warning: #E2B59B;
  --warning-text: #7A5642;
  --error: #D8A7A0;
  --error-text: #7A4A44;
  --info: #9BAE9C;
  --info-text: #4A5C4A;
  }
}
