/* Components: Buttons, Cards, Pills, Chips, Panels, Inputs, Effort Ledger, and Sheets */

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--s-2) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--t-small);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: transform var(--dur-fast) var(--ease),
              background-color var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  background: var(--surface-raised);
  border-color: var(--accent);
}

.button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: transparent;
  font-weight: 700;
}

.button.primary:hover,
.button.primary:focus-visible {
  background: var(--accent-strong);
  color: var(--bg);
}

.button:disabled,
.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Eyebrow badge */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  display: none;
}

/* Pill Chip */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 28px;
  padding: var(--s-1) var(--s-3);
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: var(--t-label);
  font-weight: 500;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: var(--t-label);
  font-weight: 600;
  font-family: var(--font-num);
}

/* Metric Card */
.metric-card {
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  box-sizing: border-box;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-4);
}

.metric-label,
.mono-label {
  color: var(--text-muted);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value {
  margin: var(--s-2) 0;
  font-size: var(--t-figure);
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.metric-card p {
  margin: 0;
  font-size: var(--t-small);
}

/* Panels */
.panel {
  padding: var(--s-4);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: var(--surface-1);
  box-sizing: border-box;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.panel-header h3 {
  margin: 0;
  font-size: var(--t-h2);
  font-weight: 600;
}

.panel-header p {
  margin: var(--s-2) 0 0;
  font-size: var(--t-small);
  line-height: 1.6;
}

.section-title {
  margin: 0 0 var(--s-2);
  font-size: var(--t-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-weight: 600;
}

/* HUD Progress display */
.hud {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-width: 140px;
}

.hud strong {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--t-h1);
  font-weight: 600;
  color: var(--accent);
}

/* Selectors: Month & Week Chips */
.month-selector,
.week-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.month-chip,
.week-chip {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  box-sizing: border-box;
  transition: background-color var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              transform var(--dur-fast) var(--ease);
}

.month-chip b,
.week-chip b {
  display: block;
  font-size: var(--t-small);
  font-weight: 600;
}

.month-chip span,
.week-chip span {
  display: block;
  font-size: var(--t-label);
  color: var(--text-muted);
}

.month-chip:hover,
.month-chip:focus-visible,
.week-chip:hover,
.week-chip:focus-visible {
  transform: translateY(-1px);
  background: var(--surface-raised);
  border-color: var(--line-strong);
}

.month-chip.active,
.week-chip.active {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.month-chip.active b,
.week-chip.active b {
  color: var(--accent-strong);
}

/* Week Focus Banner */
.week-focus {
  margin-bottom: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: var(--t-small);
  line-height: 1.6;
}

.week-focus strong {
  display: block;
  margin-bottom: var(--s-1);
  color: var(--accent);
  font-size: var(--t-body);
}

/* Phase List */
.phase-list {
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-3);
  align-items: start;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}

.phase-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.phase-index {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--accent-wash);
  color: var(--accent);
  font-size: var(--t-label);
  font-weight: 600;
}

.phase-item strong {
  display: block;
  font-size: var(--t-small);
  margin-bottom: var(--s-1);
}

.phase-item span {
  font-size: var(--t-label);
  color: var(--text-muted);
}

/* Cards (Rule, Notes, Download) */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-3);
}

.notes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-3);
}

.rule-card,
.notes-card,
.download-card {
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-sizing: border-box;
}

.rule-card strong,
.notes-card strong,
.download-card strong {
  display: block;
  margin: var(--s-1) 0 var(--s-2);
  font-size: var(--t-h3);
  color: var(--text);
}

.rule-card p,
.notes-card p,
.download-card p {
  margin: 0;
  font-size: var(--t-small);
  line-height: 1.6;
}

.download-card {
  text-decoration: none;
  min-height: var(--tap);
  transition: transform var(--dur-fast) var(--ease),
              border-color var(--dur-base) var(--ease),
              background-color var(--dur-base) var(--ease);
}

.download-card:hover,
.download-card:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--surface-raised);
}

/* Empty / Error States */
.empty-state {
  padding: var(--s-6);
  text-align: center;
  color: var(--text-muted);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-1);
  font-size: var(--t-body);
}

.empty-state.error-state {
  border-color: var(--danger);
  background: var(--surface-2);
  color: var(--text);
}

.empty-state.error-state strong {
  display: block;
  color: var(--danger);
  margin-bottom: var(--s-2);
}

/* Effort Ledger Primitive (§1) */
.ledger-row {
  display: flex;
  align-items: center;
  width: 100%;
  height: 10px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

.ledger-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.ledger-tail-dots {
  height: 100%;
  background-image: radial-gradient(var(--accent-dim) 2px, transparent 2px);
  background-size: 8px 8px;
  opacity: 0.4;
}

.ledger-tail-cap {
  width: 4px;
  height: 100%;
  background: var(--accent-strong);
}

.ledger-tail-hatch {
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--unknown),
    var(--unknown) 2px,
    transparent 2px,
    transparent 6px
  );
}

/* Sheet & Modal Overlays (UX-37, UX-38) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 17, 0.85);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
}

.sheet-panel {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-sheet);
  padding: var(--s-5);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--s-3);
}

.sheet-head h3 {
  margin: 0;
  font-size: var(--t-h2);
  font-weight: 600;
}

.sheet-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}

.sheet-close-btn:hover,
.sheet-close-btn:focus-visible {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

.close-icon {
  width: 22px;
  height: 22px;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.sheet-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--s-4);
}

.sheet-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* Auth Status Row in Overflow */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.auth-status-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-badge {
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--text-muted);
}

.auth-badge.verified {
  color: var(--success);
}

.auth-status-info small {
  font-size: var(--t-label);
  color: var(--text-faint);
}

/* System Status Indicator */
.api-status-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-small);
  color: var(--text-muted);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-indicator.online {
  background: var(--success);
}

.status-indicator.offline {
  background: var(--danger);
}

/* Credential Form Sheet */
.credential-intro {
  margin: 0;
  font-size: var(--t-small);
  color: var(--text-muted);
  line-height: 1.5;
}

.credential-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: var(--t-label);
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: var(--t-body);
  outline: none;
  box-sizing: border-box;
}

.form-input:focus {
  border-color: var(--accent-strong);
}

.remember-label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-small);
  color: var(--text);
  cursor: pointer;
  min-height: var(--tap);
}

.remember-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.sheet-actions {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-2);
}

@media (min-width: 768px) {
  .sheet-backdrop {
    align-items: center;
    padding: var(--s-5);
  }

  .sheet-panel {
    border-radius: var(--r-xl);
  }
}

/* PWA Update Banner */
.sw-update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-raised);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-3);
  box-sizing: border-box;
}

.sw-update-copy {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-small);
  color: var(--text);
  font-weight: 500;
}

.sw-update-icon {
  width: 20px;
  height: 20px;
  stroke: var(--accent);
  flex-shrink: 0;
}

.sw-update-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Offline Sync Status Banner */
.offline-sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  background: var(--surface-sunken);
  border: 1px solid var(--warning);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-3);
  box-sizing: border-box;
}

.offline-sync-copy {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-label);
  color: var(--warning);
  font-weight: 600;
}

.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
  flex-shrink: 0;
}

.offline-sync-btn {
  min-height: 36px;
  padding: var(--s-1) var(--s-3);
  font-size: var(--t-label);
}

/* Settings Toggles Grid (UX-20) */
.settings-toggles-grid {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  color: var(--text);
  min-height: var(--tap);
  cursor: pointer;
  box-sizing: border-box;
}

.toggle-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Wakelock Status Row (UX-22) */
.wakelock-status-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
}

.wakelock-note {
  font-size: var(--t-label);
  color: var(--text-muted);
  line-height: 1.4;
}

/* Privacy Box (Control 4) */
.privacy-control-box {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.privacy-notice-text {
  margin: 0;
  font-size: var(--t-small);
  color: var(--text-muted);
  line-height: 1.45;
}

.privacy-actions-row {
  display: flex;
  gap: var(--s-2);
}

/* Danger Button */
.button.danger-btn {
  background: var(--surface-2);
  color: var(--danger);
  border-color: var(--danger);
}

.button.danger-btn:hover,
.button.danger-btn:focus-visible {
  background: rgba(226, 124, 117, 0.15);
  border-color: var(--danger);
}

/* Install Row */
.install-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.install-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.install-info small {
  color: var(--text-muted);
  font-size: var(--t-label);
}

/* Reschedule Form (T077, UX-32) */
.reschedule-intro {
  margin: 0 0 var(--s-3);
  font-size: var(--t-small);
  color: var(--text-muted);
  line-height: 1.5;
}

.reschedule-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.reschedule-target-info {
  padding: var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  color: var(--text);
}

.reschedule-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  background: var(--accent-wash);
  color: var(--accent);
  font-size: var(--t-label);
  font-weight: 600;
  margin-top: 4px;
}

/* iOS Install Steps */
.ios-install-steps {
  margin: var(--s-3) 0;
  padding-left: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: var(--t-small);
  color: var(--text);
  line-height: 1.5;
}

.ios-install-steps strong {
  color: var(--accent);
}

