/* =====================================================================
   APP SHELL — shared styles for authenticated views.
   Scoped under .app-layout so marketing/landing rules in theme.css
   are never accidentally overridden.
   ===================================================================== */

/* ----- Header ----- */
.app-header {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header--minimal .container {
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 24px; }
.header-nav { display: flex; gap: 24px; flex-wrap: wrap; }
.header-nav a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.header-nav a:hover { color: var(--text); }
.header-nav a.is-active { color: var(--text); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-email {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ----- Buttons (app context) ----- */
.app-layout .btn-primary {
  background: var(--brand);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.app-layout .btn-primary:hover { background: var(--brand-dim); }
.app-layout .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.app-layout .btn-primary--sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.app-layout .btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
}
.app-layout .btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }
.app-layout .btn-secondary--accent {
  border-color: var(--accent);
  color: var(--accent);
}
.app-layout .btn-secondary--accent:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: var(--accent-light);
  color: var(--accent-light);
}
.app-layout .btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.app-layout .btn-danger-solid {
  background: var(--danger);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.app-layout .btn-danger-solid:hover { background: #c81640; }
.app-layout .btn-danger-solid:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-back {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

/* ----- Page layout ----- */
.page { padding: 48px 0 80px; }
.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.page-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.page-title-row { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }

.dashboard { padding: 48px 0 80px; }
.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.02em; }
.dash-date { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.dash-sub { color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: var(--content-width-form);
}
.card h2 { font-size: 1.1rem; margin-bottom: 6px; }
.card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }
.card + .card { margin-top: 24px; }

/* ----- Form controls ----- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: var(--content-width-form);
}
.form-section { margin-bottom: 36px; }
.form-section:last-of-type { margin-bottom: 0; }
.form-section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.form-section-num {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.form-section-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.form-section-body { padding-left: 38px; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 0 0 36px; }
.form-actions {
  display: flex; gap: 12px; margin-top: 32px;
  padding-top: 24px; border-top: 1px solid var(--border);
}

.field { margin-bottom: 28px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: block;
}
.field-input,
.field-textarea,
.select-input,
.month-day-input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}
.field-textarea { resize: vertical; min-height: 72px; }
.select-input { width: auto; padding: 8px 12px; font-size: 0.9rem; }
.month-day-input { width: 100px; padding: 10px 14px; }
.field-input:focus,
.field-textarea:focus,
.select-input:focus,
.month-day-input:focus {
  border-color: rgba(var(--brand-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}
.field-input::placeholder,
.field-textarea::placeholder { color: var(--text-muted); }
.field-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

.category-options,
.schedule-options,
.day-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.schedule-options { gap: 12px; }

.category-chip,
.schedule-btn,
.day-chip {
  padding: 8px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.schedule-btn { flex: 1; border-radius: var(--radius-md); padding: 10px; font-size: 0.85rem; }
.day-chip { border-radius: var(--radius-md); padding: 8px 12px; font-size: 0.8rem; }
.category-chip:hover,
.schedule-btn:hover,
.day-chip:hover { border-color: var(--text-muted); color: var(--text); }
.category-chip.active,
.schedule-btn.active,
.day-chip.active {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(var(--brand-rgb), 0.1);
}
/* Visually hidden but still focusable/tabbable — display:none would drop
   these radio/checkbox inputs from the tab order entirely, making the
   category/schedule/day chips impossible to select by keyboard. Same
   clip-rect technique as .item-checkbox-input in checklist-presentations.css. */
.category-chip input,
.schedule-btn input,
.day-chip input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.category-chip:has(input:focus-visible),
.schedule-btn:has(input:focus-visible),
.day-chip:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.recurrence-sub { margin-top: 14px; }

.items-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.item-row-form { display: flex; gap: 8px; align-items: center; }
.item-grip { color: var(--text-muted); cursor: grab; font-size: 1.1rem; padding: 4px; }
.item-grip:active { cursor: grabbing; }
.item-row-ghost { opacity: 0.4; }
.item-input-wrap { flex: 1; position: relative; }
.item-input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 40px 10px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.item-input:focus {
  border-color: rgba(var(--brand-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}
.item-delete {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 1.1rem; padding: 6px; border-radius: var(--radius-sm); transition: all 0.1s;
}
.item-delete:hover { color: var(--danger); background: rgba(var(--danger-rgb), 0.1); }
.btn-add-item {
  background: none; border: 1px dashed var(--border); border-radius: var(--radius-md);
  color: var(--text-muted); font-family: var(--font-mono); font-size: 0.8rem;
  padding: 10px; width: 100%; cursor: pointer; transition: all 0.15s;
}
.btn-add-item:hover { border-color: var(--text-muted); color: var(--text); }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 8px; display: none; }
.error-msg.show { display: block; }

/* ----- Appearance picker (Settings) ----- */
.appearance-section { max-width: var(--content-width-form); margin-bottom: 24px; }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
}
.theme-swatch:hover { border-color: var(--border-highlight); }
.theme-swatch.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.theme-swatch__preview {
  display: flex;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.theme-swatch__preview span { flex: 1; }
.theme-swatch__name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.theme-swatch.is-selected .theme-swatch__name { color: var(--text); font-weight: 600; }
.theme-save-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
  min-height: 1.2em;
}
.theme-save-status.is-success { color: var(--success); }
.theme-save-status.is-error { color: var(--danger); }

.font-picker-heading { margin-top: 28px; }
.font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.font-swatch {
  display: flex;
  align-items: center;
  padding: 16px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
}
.font-swatch:hover { border-color: var(--border-highlight); }
.font-swatch.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.font-swatch__name {
  font-size: var(--text-md);
  color: var(--text-muted);
}
.font-swatch.is-selected .font-swatch__name { color: var(--text); font-weight: 600; }

/* ----- Danger zone ----- */
.danger-zone {
  background: var(--surface);
  border: 1px solid rgba(var(--danger-rgb), 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: var(--content-width-form);
  margin-top: 24px;
}
.danger-zone-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--danger);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.danger-zone h2 { font-size: 1.1rem; margin-bottom: 6px; }
.danger-zone p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; margin-bottom: 16px; }

/* ----- Delete confirmation modal ----- */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.delete-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  text-align: left;
}
.delete-dialog h3 { font-size: 1.15rem; margin-bottom: 10px; color: var(--danger); }
.delete-dialog .warning-lede { font-weight: 600; font-size: 0.92rem; margin: 0 0 14px; line-height: 1.5; }
.delete-dialog .warning-list {
  margin: 0 0 20px; padding-left: 20px;
  color: var(--text-muted); font-size: 0.88rem; line-height: 1.8;
}
.delete-dialog .field { margin-bottom: 16px; }
.delete-dialog label {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; display: block;
}
.delete-dialog input {
  width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-md); font-family: var(--font-body);
  font-size: 0.9rem; box-sizing: border-box;
}
.delete-dialog input:focus { outline: none; border-color: var(--danger); }
.delete-dialog .field-error { color: var(--danger); font-size: 0.82rem; margin-top: 6px; min-height: 1.2em; }
.delete-dialog .actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* Stat cards with icons (stats page) */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 40px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.stat-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card__value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-card__label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 8px; }
.stat-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.header-nav__mobile-actions { display: none; }
@media (max-width: 768px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .header-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding-top: 12px;
  }
  .header-nav.is-open { display: flex; }
  .header-left { flex-wrap: wrap; width: 100%; }
  .header-actions--desktop { display: none; }
  .header-nav__mobile-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .header-email { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 16px 0; }
  .table-wrap .table { min-width: 520px; }
}

/* Completion celebration */
.celebration-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.celebration-burst {
  position: absolute; width: 80px; height: 80px;
  transform: translate(-50%, -50%);
  animation: celebration-burst 800ms ease-out forwards;
}
@keyframes celebration-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.5); }
}
.celebration-burst__ring { width: 100%; height: 100%; border: 3px solid var(--success); border-radius: 50%; }
.confetti-piece {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  animation: confetti-fall 900ms ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(120px) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .celebration-burst, .confetti-piece { animation: none !important; display: none; }
}

/* Upgrade pricing */
.upgrade-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; }
.upgrade-header { text-align: center; margin-bottom: 40px; }
.upgrade-badge { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 16px; }
.upgrade-title { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
.upgrade-grid { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; max-width: 820px; width: 100%; }
.pricing-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 32px; flex: 1; min-width: 280px; display: flex; flex-direction: column; }
.pricing-card--pro { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow-md); }
.pricing-card__badge { background: var(--accent); color: #fff; font-size: var(--text-xs); font-weight: 700; padding: 4px 12px; border-radius: var(--radius-full); display: inline-block; margin-bottom: 12px; align-self: flex-start; }
.pricing-card__price { font-size: var(--text-2xl); font-weight: 700; margin: 8px 0; }
.pricing-card__price span { font-size: var(--text-sm); color: var(--text-muted); font-weight: 400; }
.pricing-card__features { list-style: none; margin: 24px 0; display: flex; flex-direction: column; gap: 10px; font-size: var(--text-sm); flex: 1; }
.pricing-card__features li { display: flex; gap: 8px; align-items: flex-start; }
.pricing-card__features li::before { content: '✓'; color: var(--brand); font-weight: 700; }

.actions-zone { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-width: var(--content-width-form); margin-top: 24px; }
.actions-zone-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 12px; }
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; }
.app-layout .btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); font-size: 0.8rem; padding: 8px 16px; border-radius: var(--radius-md); cursor: pointer; }
.app-layout .btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.presentation-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.presentation-chip { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; min-width: 72px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font-size: var(--text-xs); color: var(--text-muted); transition: all 0.15s; }
.presentation-chip.active { border-color: var(--brand); color: var(--brand); background: rgba(var(--brand-rgb), 0.06); }
/* Visually hidden but still focusable/tabbable — see the same fix on
   .category-chip/.schedule-btn/.day-chip input above. */
.presentation-chip input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.presentation-chip:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .app-header .container { flex-wrap: wrap; row-gap: 12px; }
  .header-left { flex-wrap: wrap; row-gap: 8px; }
  .header-email { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

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