/* ============================================================
   Routines (Phase R) - token-driven Brand OS, light-mode-clean.
   ============================================================ */
.rt-hero { padding:clamp(24px,4vw,38px); border-radius:var(--radius-lg); border:1px solid var(--line);
  background:linear-gradient(180deg, var(--surface), var(--surface-grad-2)); margin-bottom:14px; }
.rt-kicker { display:inline-flex; align-items:center; gap:8px; font-family:var(--mono); font-size:11px; font-weight:700;
  letter-spacing:.18em; text-transform:uppercase; color:var(--gold); margin-bottom:14px; }
.rt-dot { width:7px; height:7px; border-radius:50%; background:var(--gold); box-shadow:0 0 12px var(--glow); }
.rt-hero h1 { margin:0; font-family:var(--serif); font-size:clamp(30px,4.2vw,50px); line-height:1.04; letter-spacing:-.02em; max-width:760px; }
.rt-hero .sub { margin:12px 0 0; color:var(--muted); font-size:14.5px; line-height:1.6; max-width:68ch; }
.rt-path { display:flex; flex-wrap:wrap; gap:8px; margin-top:20px; }
.rt-path .rt-chip { display:inline-flex; align-items:center; gap:7px; padding:7px 14px; border-radius:999px; border:1px solid var(--line);
  background:var(--surface); color:var(--ivory); font-size:12.5px; font-weight:600; cursor:pointer; transition:transform .15s, border-color .15s, box-shadow .15s; }
.rt-path .rt-chip:hover { transform:translateY(-1px); border-color:var(--gold-line); box-shadow:0 6px 18px -10px var(--glow); }
.rt-path .rt-chip:focus-visible { outline:none; border-color:var(--gold-2); box-shadow:0 0 0 3px var(--gold-soft); }
.rt-chip-num { font-family:var(--mono); font-size:10px; color:var(--gold); }
.rt-drawer { margin:0 0 18px; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface); overflow:hidden; }
.rt-drawer > summary { display:flex; align-items:center; gap:14px; padding:16px 20px; list-style:none; cursor:pointer; user-select:none; }
.rt-drawer > summary::-webkit-details-marker { display:none; }
.rt-drawer > summary:hover { background:var(--surface-grad-2); }
.rt-drawer > summary span { color:var(--ivory); font-size:14px; font-weight:700; }
.rt-drawer > summary small { flex:1; color:var(--muted); font-size:12.5px; }
.rt-drawer > summary b { color:var(--gold); font-family:var(--mono); font-size:18px; transition:transform .2s ease; }
.rt-drawer[open] > summary b { transform:rotate(45deg); }
.rt-drawer-body { display:grid; gap:8px; padding:0 20px 18px; }
.rt-drawer-body .rt-sub { margin:0; line-height:1.55; }
.rt-sub { color:var(--muted); font-size:12.5px; margin:3px 0 0; max-width:64ch; }
.rt-work-section, #rt-streaks, #rt-monk-mode { scroll-margin-top:18px; }

.rt-tabs { display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap; }
.rt-tab { padding:9px 16px; border-radius:999px; border:1px solid var(--line-2); background:var(--surface);
  color:var(--muted); font-size:13px; font-weight:600; cursor:pointer; transition:all .15s; }
.rt-tab:hover { border-color:var(--gold-line); }
.rt-tab.on { background:var(--gold-soft); border-color:var(--gold-line); color:var(--gold); }

/* shared bits */
.rt-in { width:100%; padding:9px 11px; border-radius:9px; border:1px solid var(--line-2);
  background:var(--surface); color:var(--ivory); font-size:13.5px; font-family:inherit; }
.rt-in:focus { outline:none; border-color:var(--gold-2); box-shadow:0 0 0 2px var(--gold-soft); }
.rt-ta { resize:vertical; min-height:44px; line-height:1.5; }
.rt-in-sm { width:120px; }
.rt-btn { padding:9px 15px; border-radius:9px; border:1px solid var(--line-2); background:var(--surface); color:var(--ivory);
  font-size:13px; font-weight:600; cursor:pointer; transition:transform .15s, border-color .15s; }
.rt-btn:hover { transform:translateY(-1px); border-color:var(--gold-line); }
.rt-btn.ghost { background:transparent; } .rt-btn.sm { padding:7px 12px; font-size:12.5px; }
.rt-btn.primary { background:var(--gold-soft); border-color:var(--gold-line); color:var(--gold); }
.rt-btn.danger { color:var(--red); border-color:var(--red); background:transparent; }
.rt-x { flex:0 0 auto; width:28px; height:28px; border-radius:7px; border:1px solid transparent; background:transparent; color:var(--muted); cursor:pointer; font-size:15px; }
.rt-x:hover { color:var(--red); border-color:var(--red); }
.rt-empty { text-align:center; padding:34px 20px; color:var(--muted); border:1px dashed var(--line-2); border-radius:var(--radius-lg); }
.rt-empty-ic { font-size:26px; margin-bottom:8px; } .rt-empty-sm { color:var(--muted); font-size:12px; font-style:italic; }
.rt-hint { color:var(--muted); font-size:12px; margin-top:8px; }
.rt-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.rt-btn.danger-text { color:var(--red); }

/* builder */
.rt-builder-head { display:flex; align-items:center; justify-content:flex-end; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
/* Single-column compact rows (2026-07-02): the old auto-fill card grid crushed
   titles against the fixed-width action buttons and stretched cards into giant
   blank bodies. Rows keep every routine the same quiet height. */
.rt-routines { display:flex; flex-direction:column; gap:10px; }
.rt-card { padding:16px; border-radius:var(--radius-lg); border:1px solid var(--line); background:linear-gradient(180deg, var(--surface), var(--surface-grad-2)); }
.rt-card.rt-rowcard { padding:12px 16px; }
.rt-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:0; }
.rt-card-main { flex:1 1 auto; min-width:0; }
.rt-title-line { display:flex; align-items:center; gap:9px; min-width:0; }
.rt-card-title { margin:0; font-size:15px; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.rt-card-actions { display:flex; align-items:center; gap:7px; flex:0 0 auto; }
.rt-chips { margin-top:5px; }
.rt-steps-drawer { margin-top:8px; }
.rt-steps-drawer summary { list-style:none; cursor:pointer; display:inline-flex; align-items:center; gap:6px; font-family:var(--mono); font-size:11.5px; letter-spacing:.04em; color:var(--muted); padding:3px 0; }
.rt-steps-drawer summary::-webkit-details-marker { display:none; }
.rt-steps-drawer summary::after { content:'+'; font-size:13px; color:var(--muted); }
.rt-steps-drawer[open] summary::after { content:'\2212'; }
.rt-steps-drawer summary:hover { color:var(--ivory); }
.rt-steps-drawer .rt-steps { margin:6px 0 2px; }
.rt-nosteps { margin:6px 0 0; }
.rt-routine-name { font-weight:700; font-size:15px; }
.rt-steps { display:flex; flex-direction:column; gap:7px; margin-bottom:10px; }
.rt-step { display:flex; align-items:center; gap:7px; }
.rt-step-time { flex:0 0 88px; width:88px; }
.rt-step-act { flex:1 1 auto; }
.rt-step-read { display:grid; grid-template-columns:88px minmax(0, 1fr); gap:8px; align-items:start; padding:8px 0; border-bottom:1px solid var(--line); }
.rt-step-read.rt-notime { grid-template-columns:minmax(0, 1fr); }
.rt-step-read:last-child { border-bottom:0; }
.rt-step-read .rt-step-time { width:auto; font-family:var(--mono); font-size:11.5px; color:var(--gold); }
.rt-step-read .rt-step-act { color:var(--ivory); font-size:13.5px; line-height:1.4; word-break:break-word; }
.rt-chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:7px; }
.rt-chip { display:inline-flex; align-items:center; max-width:100%; padding:4px 7px; border-radius:8px; border:1px solid var(--line-2); color:var(--muted); font-size:11.5px; line-height:1.25; }
.rt-chip.lab { color:var(--gold); border-color:var(--gold-line); background:var(--gold-soft); }
.rt-gfield { margin-bottom:12px; }
.rt-gfield .rt-in { margin-top:7px; }
.rt-step-guide { display:grid; grid-template-columns:140px minmax(0, 1fr); gap:10px; align-items:start; }
.rt-guide-note { color:var(--muted); font-size:12px; line-height:1.45; margin:8px 0 0; }
.rt-pop-real { display:flex; flex-direction:column; gap:12px; min-width:260px; }
.rt-pop-group h4 { margin:0 0 6px; font-size:12px; color:var(--gold); }
.rt-pop-item { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:6px 0; border-bottom:1px solid var(--line); }
.rt-pop-item:last-child { border-bottom:0; }
.rt-pop-item span { color:var(--ivory); font-size:12.5px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rt-pop-item em, .rt-pop-empty { color:var(--muted); font-size:12px; font-style:normal; }

/* monk mode */
.rt-monk { display:flex; flex-direction:column; gap:18px; }
.rt-monk-top { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap;
  padding:18px 20px; border-radius:var(--radius-lg); border:1px solid var(--line); background:linear-gradient(180deg, var(--surface), var(--surface-grad-2)); }
.rt-monk-top h3 { margin:0; font-size:18px; }
.rt-version { font-family:var(--mono); font-size:12px; color:var(--muted); }
.rt-monk-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.rt-monk-day { font-family:var(--mono); font-size:13px; color:var(--gold); }
.rt-monk-streak { font-family:var(--mono); font-size:13px; color:var(--green); margin-left:10px; }
.rt-monk-off { font-size:13px; color:var(--muted); }
.rt-monk-rules h4, .rt-monk-projects h4 { margin:0 0 10px; font-size:14px; }
.rt-rules { display:flex; flex-wrap:wrap; gap:10px; }
.rt-rule-row { display:inline-flex; align-items:stretch; gap:4px; max-width:100%; }
.rt-rule { display:flex; align-items:center; gap:8px; padding:10px 14px; border-radius:10px; border:1px solid var(--line-2); background:var(--surface); font-size:13.5px; cursor:pointer; }
.rt-rule span { overflow-wrap:anywhere; }
.rt-rule input { width:16px; height:16px; accent-color:var(--gold); }
.rt-rule input:disabled { opacity:.5; cursor:not-allowed; }
.monk-rule-remove { align-self:stretch; height:auto; }
.rt-monk-add-row { display:grid; grid-template-columns:minmax(0, 1fr) auto; gap:8px; align-items:center; margin-top:10px; }
.rt-proj-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:8px; }
.rt-field label { display:block; font-size:12.5px; color:var(--muted); margin-bottom:5px; }
.rt-field > span { display:block; font-size:12.5px; color:var(--muted); margin-bottom:5px; }
.rt-monk-grid { display:flex; gap:16px; flex-wrap:wrap; }
.rt-planbar { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.rt-planbar .rt-field { flex:1 1 260px; margin:0; }
.rt-template-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; }
.rt-template { text-align:left; padding:12px; border-radius:8px; border:1px solid var(--line-2); background:var(--surface); color:var(--ivory); cursor:pointer; }
.rt-template:hover { border-color:var(--gold-line); transform:translateY(-1px); }
.rt-template b { display:block; font-size:13px; margin-bottom:3px; }
.rt-template span { color:var(--muted); font-size:12px; }
.rt-monk-summary { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:10px; }
.rt-monk-summary > div { padding:12px; border-radius:8px; border:1px solid var(--line); background:var(--surface); min-width:0; }
.rt-monk-summary span { display:block; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.05em; margin-bottom:5px; }
.rt-monk-summary b { display:block; color:var(--ivory); font-size:13px; line-height:1.35; font-weight:600; overflow-wrap:anywhere; }
.rt-notes { padding:13px 15px; border-radius:8px; border:1px solid var(--line); background:var(--surface); }
.rt-notes h4 { margin:0 0 6px; font-size:13px; }
.rt-notes p { margin:0; color:var(--muted); font-size:13px; line-height:1.45; }

/* testing lab */
.rt-lab-head { display:flex; align-items:center; justify-content:flex-end; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
.rt-tests { display:flex; flex-direction:column; gap:12px; }
.rt-test { padding:14px 16px; border-radius:var(--radius-lg); border:1px solid var(--line); background:linear-gradient(180deg, var(--surface), var(--surface-grad-2)); }
.rt-test-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.rt-test-name { font-weight:600; flex:1; }
.rt-test-date { font-family:var(--mono); font-size:11.5px; color:var(--muted); }
.rt-test-linked { display:inline-flex; margin:-2px 0 10px; padding:4px 7px; border-radius:8px; border:1px solid var(--gold-line); background:var(--gold-soft); color:var(--gold); font-size:11.5px; }
.rt-test-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.rt-test-grid label { display:block; font-size:11.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }
.rt-test-grid textarea { margin-top:5px; }

/* streak badge on routine cards */
.rt-streak-badge { display:inline-flex; align-items:center; padding:3px 8px; border-radius:999px;
  background:var(--gold-soft); border:1px solid var(--gold-line); color:var(--gold);
  font-family:var(--mono); font-size:11px; font-weight:600; margin-left:6px; }

/* recurrence + reminder chips (extend the existing .rt-chip pattern) */
.rt-chip.sched { color:var(--ivory); border-color:var(--line-2); }
.rt-chip.remind { color:var(--muted); border-color:var(--line-2); }

/* provenance note under a step activity */
.rt-provenance { display:block; color:var(--muted); font-size:11px; font-style:italic; margin-top:2px; }

/* step editor overlay footer */
.rt-sep-foot { display:flex; align-items:center; justify-content:flex-end; gap:10px;
  padding:14px 20px; border-top:1px solid var(--line); }
/* step editor rows inside the panel */
.rt-sep-steps { display:flex; flex-direction:column; gap:10px; }
.rt-sep-row { display:grid; grid-template-columns:minmax(0,1fr) 32px; gap:8px; align-items:start;
  padding:10px 0; border-bottom:1px solid var(--line); }
.rt-sep-row:last-child { border-bottom:0; }
.rt-sep-inputs { display:grid; grid-template-columns:130px minmax(0,1fr); gap:8px; }
.rt-sep-time { font-family:var(--mono); font-size:12px; }

/* multi-link editor */
.rt-ml-editor { display:flex; flex-direction:column; gap:10px; }
.rt-ml-list { display:flex; flex-direction:column; gap:6px; }
.rt-ml-row { display:flex; align-items:center; gap:8px; padding:7px 10px; border-radius:8px;
  border:1px solid var(--line-2); background:var(--surface); }
.rt-ml-label { flex:1; font-size:13px; color:var(--ivory); min-width:0; overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; }
.rt-ml-add-row { display:flex; align-items:center; gap:8px; }
.rt-ml-select { flex:1; }
.rt-ml-hidden { display:none; }

/* day-of-week recurrence picker */
.rt-day-picker { display:flex; flex-wrap:wrap; gap:8px; }
.rt-day-check { display:flex; align-items:center; gap:5px; padding:7px 11px; border-radius:8px;
  border:1px solid var(--line-2); background:var(--surface); font-size:12.5px; cursor:pointer; }
.rt-day-check input { width:14px; height:14px; accent-color:var(--gold); }

/* reminder row inside guided builder step */
.rt-reminder-row { display:flex; align-items:center; gap:14px; flex-wrap:wrap; margin-top:8px; }

/* testing lab - linked routine + step selectors */
.rt-test-links { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:10px; }
.rt-test-links .rt-field { margin:0; }

/* monk mode plan cards */
.rt-plan-cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:10px; margin-bottom:10px; }
.rt-plan-card { padding:12px 14px; border-radius:var(--radius-lg); border:1px solid var(--line-2);
  background:var(--surface); cursor:pointer; transition:border-color .15s, transform .12s; }
.rt-plan-card:hover { border-color:var(--gold-line); transform:translateY(-1px); }
.rt-plan-card.selected { border-color:var(--gold-line); background:var(--gold-soft); }
.rt-plan-card.active { border-color:var(--green, #4caf50); }
.rt-plan-card-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.rt-plan-rename { flex:1; background:transparent; border:1px solid transparent; padding:4px 6px;
  border-radius:6px; font-size:14px; font-weight:700; color:var(--ivory); }
.rt-plan-rename:focus { background:var(--surface); border-color:var(--gold-2); outline:none; }
.rt-plan-card-meta { font-size:12px; color:var(--muted); line-height:1.35; }
.rt-plan-cards-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.rt-plan-cards-head h4 { margin:0; font-size:14px; }

/* monk rules header with edit button */
.rt-monk-rules-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.rt-monk-rules-head h4 { margin:0; font-size:14px; }

/* monk mode quick-links to other tabs */
.rt-monk-links { display:flex; gap:8px; flex-wrap:wrap; padding-top:4px; border-top:1px solid var(--line); }

/* WO-3.1: habit strength meter on a routine card (reuses the app-wide
   .progress bar shape used elsewhere, e.g. life-rank.js and community.js) */
.rt-strength { display:flex; align-items:center; gap:8px; margin-top:8px; }
.rt-strength-label { font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); flex-shrink:0; }
.rt-strength .progress { flex:1; height:6px; }
.rt-strength-pct { font-family:var(--mono); font-size:11px; color:var(--muted); flex-shrink:0; width:32px; text-align:right; }

/* WO-3.1: streak-freeze token note, subtle, next to the streak badge */
.rt-freeze-chip { display:inline-flex; align-items:center; padding:3px 8px; border-radius:999px;
  border:1px solid var(--line-2); color:var(--muted); font-size:11px; margin-left:6px; }
.rt-freeze-chip.used { color:var(--gold); border-color:var(--gold-line); }

/* WO-3.1: "Start from a template" empty-state label above the template grid */
.rt-tpl-head { margin:14px 0 8px; font-size:12.5px; color:var(--muted); }

/* WO-3.1: skip-reason popover chips */
.rt-skip-reasons { display:flex; gap:8px; flex-wrap:wrap; }

/* WO-3.1: optional completion-detail sheet (mood/energy/friction) */
.rt-detail-sheet { display:flex; flex-direction:column; gap:12px; min-width:220px; }
.rt-scale-row { display:flex; gap:6px; }
.rt-scale-btn { min-width:32px; text-align:center; }
.rt-scale-btn.selected { background:var(--gold-soft); border-color:var(--gold-line); color:var(--gold); }

@media (max-width:760px) {
  .rt-hero { padding:22px 18px; }
  .rt-drawer > summary { align-items:flex-start; flex-wrap:wrap; }
  .rt-drawer > summary small { flex-basis:100%; }
  .rt-test-grid { grid-template-columns:1fr; }
  .rt-test-links { grid-template-columns:1fr; }
  .rt-routines { grid-template-columns:1fr; }
  .rt-step-guide { grid-template-columns:1fr; }
  .rt-monk-summary { grid-template-columns:1fr; }
  .rt-monk-actions { justify-content:flex-start; }
  .rt-plan-cards { grid-template-columns:1fr; }
  .rt-sep-inputs { grid-template-columns:1fr; }
  .rt-monk-add-row { grid-template-columns:1fr; }
  .rt-day-picker { gap:5px; }
}
