/* thePhaze shared components. Every value comes from phaze-tokens.css custom properties. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ph { margin: 0; font-family: var(--ph-font); font-size: var(--ph-text-md); line-height: 1.45;
  background: var(--ph-bg); color: var(--ph-text); }
.ph :focus-visible { outline: 2px solid var(--ph-focus); outline-offset: 2px; }
.ph a { color: var(--ph-accent); }
.ph-muted { color: var(--ph-text-muted); }
.ph-faint { color: var(--ph-text-faint); }
.ph-hidden { display: none !important; }

/* Brand */
.ph-wordmark { font-weight: var(--ph-weight-bold); letter-spacing: -0.01em; display: inline-flex; align-items: baseline; gap: var(--ph-space-xs); }
.ph-wordmark .ph-wordmark-app { color: var(--ph-accent); }
.ph-partof { font-size: var(--ph-text-xs); color: var(--ph-text-faint); }
.ph-partof::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ph-accent); margin-right: 6px; vertical-align: middle; }

/* Surfaces */
.ph-card { background: var(--ph-surface); border: 1px solid var(--ph-border); border-radius: var(--ph-radius-md); padding: var(--ph-space-md) var(--ph-space-lg); }
.ph-card.ph-tap { cursor: pointer; transition: border-color var(--ph-motion-fast), transform var(--ph-motion-fast); }
.ph-card.ph-tap:hover { border-color: var(--ph-accent); }
.ph-card.ph-tap:active { transform: scale(0.995); }
.ph-section { margin: var(--ph-space-xl) 0 var(--ph-space-sm); font-size: var(--ph-text-sm); font-weight: var(--ph-weight-bold);
  text-transform: uppercase; letter-spacing: .06em; color: var(--ph-text-muted); display: flex; align-items: center; gap: var(--ph-space-sm); }
.ph-section .ph-count { font-weight: var(--ph-weight-medium); color: var(--ph-text-faint); }
.ph-empty { padding: var(--ph-space-xl); text-align: center; color: var(--ph-text-faint); border: 1px dashed var(--ph-border); border-radius: var(--ph-radius-md); }

/* Buttons */
.ph-btn { appearance: none; font: inherit; font-weight: var(--ph-weight-medium); min-height: var(--ph-touch); padding: 0 var(--ph-space-lg);
  border-radius: var(--ph-radius-md); border: 1px solid var(--ph-border); background: var(--ph-surface); color: var(--ph-text);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ph-space-sm); cursor: pointer;
  transition: background var(--ph-motion-fast), border-color var(--ph-motion-fast); }
.ph-btn:hover { border-color: var(--ph-accent); }
.ph-btn:disabled { opacity: .5; cursor: default; }
.ph-btn.ph-primary { background: var(--ph-accent); border-color: var(--ph-accent); color: var(--ph-on-accent); }
.ph-btn.ph-ghost { background: transparent; border-color: transparent; }
.ph-btn.ph-danger { color: var(--ph-danger); }
.ph-btn.ph-icon { width: var(--ph-touch); padding: 0; }
.ph-btn.ph-sm { min-height: 36px; padding: 0 var(--ph-space-md); font-size: var(--ph-text-sm); }

/* Inputs */
.ph-input, .ph-select, .ph-textarea { font: inherit; width: 100%; min-height: var(--ph-touch); padding: var(--ph-space-sm) var(--ph-space-md);
  border-radius: var(--ph-radius-md); border: 1px solid var(--ph-border); background: var(--ph-surface); color: var(--ph-text); }
.ph-textarea { min-height: 96px; resize: vertical; }
.ph-input:focus, .ph-select:focus, .ph-textarea:focus { border-color: var(--ph-accent); outline: none; }
.ph-label { display: block; font-size: var(--ph-text-sm); color: var(--ph-text-muted); margin: var(--ph-space-md) 0 var(--ph-space-xs); }

/* Chips, pills, dots */
.ph-chip { display: inline-flex; align-items: center; gap: var(--ph-space-xs); min-height: 28px; padding: 0 var(--ph-space-sm);
  border-radius: var(--ph-radius-pill); background: var(--ph-surface2); color: var(--ph-text-muted); font-size: var(--ph-text-xs);
  border: 1px solid transparent; white-space: nowrap; }
button.ph-chip { cursor: pointer; font: inherit; font-size: var(--ph-text-xs); }
.ph-chip.ph-on { background: var(--ph-accent); color: var(--ph-on-accent); }
.ph-chip.ph-ai { color: var(--ph-ai); border-color: var(--ph-ai); background: transparent; }
.ph-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ph-status-open); }
.ph-status-open { --ph-status: var(--ph-status-open); }
.ph-status-active { --ph-status: var(--ph-status-active); }
.ph-status-done { --ph-status: var(--ph-status-done); }
.ph-status-cancelled { --ph-status: var(--ph-status-cancelled); }
.ph-dot[class*="ph-status-"] { background: var(--ph-status); }
.ph-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--ph-space-sm); border-radius: var(--ph-radius-pill);
  font-size: var(--ph-text-xs); font-weight: var(--ph-weight-medium); color: var(--ph-status, var(--ph-text-muted));
  background: color-mix(in srgb, var(--ph-status, var(--ph-text-muted)) 14%, transparent); }
.ph-prio-1 { color: var(--ph-priority1); } .ph-prio-2 { color: var(--ph-priority2); }
.ph-prio-3 { color: var(--ph-priority3); } .ph-prio-4 { color: var(--ph-priority4); }

/* Check control (one-tap complete) */
.ph-check { appearance: none; width: 26px; height: 26px; flex: none; margin: 0; border-radius: 50%; border: 2px solid var(--ph-status, var(--ph-border));
  background: transparent; cursor: pointer; display: grid; place-items: center; transition: background var(--ph-motion-fast); }
.ph-check:checked { background: var(--ph-status-done); border-color: var(--ph-status-done); }
.ph-check:checked::after { content: ""; width: 7px; height: 12px; border: solid var(--ph-surface); border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }

/* Progress roll-up */
.ph-progress { height: 6px; border-radius: var(--ph-radius-pill); background: var(--ph-surface2); overflow: hidden; }
.ph-progress > span { display: block; height: 100%; background: var(--ph-status-done); transition: width var(--ph-motion-normal); }

/* Status indicator (synced / saving / offline / error / recording) */
.ph-sync { display: inline-flex; align-items: center; gap: 6px; font-size: var(--ph-text-xs); color: var(--ph-text-muted); }
.ph-sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ph-sync-synced); }
.ph-sync[data-state="saving"]::before { background: var(--ph-sync-saving); animation: ph-pulse 1s infinite; }
.ph-sync[data-state="offline"]::before { background: var(--ph-sync-offline); }
.ph-sync[data-state="error"]::before { background: var(--ph-sync-error); }
.ph-sync[data-state="recording"]::before { background: var(--ph-recording); animation: ph-pulse .8s infinite; }
@keyframes ph-pulse { 50% { opacity: .35; } }

/* Menus, sheets, toasts */
.ph-menu { position: absolute; z-index: 50; min-width: 200px; background: var(--ph-surface); border: 1px solid var(--ph-border);
  border-radius: var(--ph-radius-md); padding: var(--ph-space-xs); box-shadow: 0 10px 30px var(--ph-overlay); }
.ph-menu button { display: flex; width: 100%; align-items: center; gap: var(--ph-space-sm); min-height: 40px; padding: 0 var(--ph-space-md);
  border: 0; border-radius: var(--ph-radius-sm); background: transparent; color: var(--ph-text); font: inherit; cursor: pointer; text-align: left; }
.ph-menu button:hover { background: var(--ph-surface2); }
.ph-scrim { position: fixed; inset: 0; z-index: 40; background: var(--ph-overlay); }
.ph-sheet { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--ph-surface);
  border-radius: var(--ph-radius-lg) var(--ph-radius-lg) 0 0; padding: var(--ph-space-lg); box-shadow: 0 -10px 30px var(--ph-overlay); }
@media (min-width: 900px) { .ph-sheet { left: auto; top: 0; width: 520px; max-height: none; border-radius: 0; } }
.ph-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--ph-nav-height) + var(--ph-space-lg)); transform: translateX(-50%);
  background: var(--ph-text); color: var(--ph-bg); border-radius: var(--ph-radius-md); padding: var(--ph-space-sm) var(--ph-space-lg);
  display: flex; gap: var(--ph-space-md); align-items: center; max-width: calc(100vw - 32px); }
.ph-toast button { background: none; border: 0; color: var(--ph-accent); font: inherit; font-weight: var(--ph-weight-bold); cursor: pointer; }

/* Layout: top bar, bottom nav (small screens), side nav (wide) */
.ph-topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--ph-space-sm);
  padding: var(--ph-space-sm) var(--ph-space-lg); background: var(--ph-bg); border-bottom: 1px solid var(--ph-border); min-height: 56px; }
.ph-grow { flex: 1; min-width: 0; }
.ph-bottomnav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: var(--ph-nav-height); display: flex;
  background: var(--ph-surface); border-top: 1px solid var(--ph-border); padding-bottom: env(safe-area-inset-bottom); }
.ph-bottomnav button { flex: 1; border: 0; background: none; color: var(--ph-text-muted); font: inherit; font-size: var(--ph-text-xs);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; position: relative; }
.ph-bottomnav button[aria-current="page"] { color: var(--ph-accent); font-weight: var(--ph-weight-bold); }
.ph-bottomnav .ph-badge { position: absolute; top: 8px; left: calc(50% + 6px); }
.ph-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--ph-radius-pill); background: var(--ph-accent); color: var(--ph-on-accent);
  font-size: 11px; font-weight: var(--ph-weight-bold); display: inline-grid; place-items: center; }
.ph-fab { position: fixed; z-index: 31; right: var(--ph-space-lg); bottom: calc(var(--ph-nav-height) + var(--ph-space-lg));
  width: 56px; height: 56px; border-radius: var(--ph-radius-lg); border: 0; background: var(--ph-accent); color: var(--ph-on-accent);
  font-size: 28px; cursor: pointer; box-shadow: 0 6px 18px var(--ph-overlay); }
.ph-main { max-width: var(--ph-max-content); margin: 0 auto; padding: var(--ph-space-lg) var(--ph-space-lg) calc(var(--ph-nav-height) + 96px); }
@media (min-width: 900px) {
  .ph-bottomnav { top: 56px; bottom: 0; right: auto; width: 88px; height: auto; flex-direction: column; justify-content: flex-start;
    border-top: 0; border-right: 1px solid var(--ph-border); padding-top: var(--ph-space-md); }
  .ph-bottomnav button { flex: none; height: 64px; }
  .ph-main { padding-left: calc(88px + var(--ph-space-xl)); padding-bottom: var(--ph-space-xxl); }
  .ph-fab { bottom: var(--ph-space-xl); }
  .ph-toast { bottom: var(--ph-space-xl); }
}
