/*
 * Base components of the v2 art direction. Values come from the mockups in
 * pilotage-design-v2/screens; colours only from tokens.css.
 */

/* ---------- Application shell ---------- */
/* Content widths: the HANDOFF values (1040–1200 px, side column 340 px)
   up to large screens, then wider so a big monitor is not half empty. */
:root {
  --content-max: 1200px; /* Aujourd'hui, Projets, session. */
  --reading-max: 1080px; /* Notes, Bilan: long text lines stay readable. */
  --side-max: 340px;     /* Right-hand column. */
}
@media (min-width: 1680px) {
  :root {
    --content-max: 1600px;
    --reading-max: 1320px;
    --side-max: 400px;
  }
}
.app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}
.main-col {
  flex: 999 1 640px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  padding: 28px 32px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}
.col-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.col-side { flex: 1 1 280px; max-width: var(--side-max); display: flex; flex-direction: column; gap: 16px; }

/* ---------- Sidebar ---------- */
.sidebar {
  flex: 1 1 232px;
  max-width: 256px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand-mark .ring { stroke: var(--accent); }
.brand-mark .core { fill: var(--accent); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item .label { flex: 1 1 auto; }
.nav-count { font-size: 12px; color: var(--muted); }
.sb-section { display: flex; flex-direction: column; gap: 2px; }
.sb-heading { margin: 0 0 4px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-item.small { min-height: 32px; font-size: 13px; font-weight: 400; }
.sb-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ntfy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  min-height: 60px;
  padding: 10px 32px;
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; flex: 1 1 auto; min-width: 0; }
.topbar-title h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-sub { font-size: 13px; color: var(--muted); }
.search-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  min-width: 220px;
  padding: 0 8px 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text); }
.search-btn .label { flex: 1 1 auto; text-align: left; }
.mobile-only { display: none; }
.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ---------- Mobile tab bar (under 900 px, on every app screen) ---------- */
.tabbar {
  display: none;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
}
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.pad { gap: 12px; padding: 18px; }
.card.pad-lg { gap: 20px; padding: 20px 22px; }
.card.clip { overflow: hidden; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-title.sm { font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.xs { min-height: 28px; padding: 0 10px; font-size: 12px; }
/* Primary: one per screen. */
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.95); }
.btn-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon.lg { width: 44px; height: 44px; }
.link { color: var(--accent-text); text-decoration: none; font-size: 12px; }
.link:hover { text-decoration: underline; }

/* ---------- kbd ---------- */
kbd {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  line-height: 1.3;
}
.btn-primary kbd {
  padding: 1px 5px;
  border: 0;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
}

/* ---------- Segmented control (buttons with aria-pressed, or radios) ---------- */
.seg {
  display: flex;
  padding: 2px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.seg > button, .seg label > span {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.seg > button:hover, .seg label:hover > span { color: var(--text); }
.seg > button[aria-pressed="true"], .seg input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}
.seg label { flex: 1 1 auto; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- List row ---------- */
.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 18px 10px 10px;
}
.row-item + .row-item { border-top: 1px solid var(--border); }
.row-item:hover { background: var(--hover); }
.row-item.current { background: var(--accent-soft); }
.row-item .grip {
  flex: none;
  width: 24px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
}
.row-item .reveal { opacity: 0; }
.row-item:hover .grip, .row-item .grip:focus-visible,
.row-item:hover .reveal, .row-item .reveal:focus-within, .row-item .reveal[open] { opacity: 1; }
@media (hover: none) {
  .row-item .grip, .row-item .reveal { opacity: 1; }
}
.row-item .title { font-size: 14px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
}
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: inset 0 2px 0 var(--accent); }

/* Done checkbox as a button, so it submits without JavaScript. */
.check {
  flex: none;
  position: relative;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.check::after { content: ""; position: absolute; inset: -8px; } /* 32 px target. */
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); }

/* ---------- Task attributes, never by colour alone ---------- */
/* Estimate: one dot per Pomodoro, outlined; filled muted when done. */
.dots { display: flex; gap: 4px; flex: none; }
.dot-est {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
}
.dot-est.done { border-color: var(--muted); background: var(--muted); }
/* Weight: filled circle = heavy, hollow = light, always with the word. */
.weight, .proj { display: inline-flex; align-items: center; gap: 6px; }
.weight::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}
.weight.heavy::before { background: var(--muted); }
/* Project: 8 px rounded square in the project's colour, with its name. */
.proj-sq { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--project-1); }
.proj-sq.p2 { background: var(--project-2); }
.proj-sq.p3 { background: var(--project-3); }

/* Status: 7 px dot + word. */
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.status.done::before { background: var(--success); }
.status.doing::before { background: var(--accent); }
.dot7 { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.dot7.ok { background: var(--success); }
.dot7.bad { background: var(--danger); }
.dot6 { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Segmented gauge: one cell per Pomodoro of the threshold. */
.seg-gauge { display: flex; gap: 4px; }
.seg-gauge span {
  flex: 1 1 0;
  height: 6px;
  border-radius: 2px;
  background: var(--track);
}
.seg-gauge .done { background: var(--accent); }
.seg-gauge .planned { background: var(--accent-soft); border: 1px solid var(--accent-line); }
.seg-gauge .over { background: var(--danger-soft); border: 1px solid var(--danger-line); }

/* Thin bar gauge, drawn in SVG (sizes are attributes: no inline styles). */
.bar-gauge { display: block; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; }
.bar-gauge .track { fill: var(--track); }
.bar-gauge .fill { fill: var(--accent); }
.bar-gauge .fill.over { fill: var(--danger); }

/* ---------- Alert, with a direct action ---------- */
.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  font-size: 13px;
}
.alert > svg { color: var(--danger); }
.alert .text { flex: 1 1 260px; }
.alert strong { font-weight: 600; color: var(--danger); }

/* ---------- Radio cards (evening review) ---------- */
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.radio-card input { margin: 2px 0 0; accent-color: var(--accent); }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 14px;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.textarea { padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }

/* ---------- Popover menus (details/summary) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu-list button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--hover); }
.menu-list button[aria-current="true"] { color: var(--accent-text); font-weight: 600; }
.menu-list.confirm { min-width: 240px; max-width: 280px; gap: 8px; padding: 12px; }
.menu-text { font-size: 13px; line-height: 1.45; color: var(--text); white-space: normal; }
.menu-list button.confirm-btn { background: var(--accent); color: var(--on-accent); font-weight: 600; text-align: center; }

/* Flash message after an invalid form. */
.flash { margin: 16px 32px 0; }

/* ---------- Narrow screens: tab bar instead of the sidebar ---------- */
@media (max-width: 899px) {
  .sidebar { display: none; }
  .tabbar {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
  }
  .app.with-tabs { padding-bottom: 72px; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 32px; }
  .search-btn { min-width: 0; }
  .mobile-only { display: inline-flex; }
  .flash { margin: 12px 16px 0; }
}

/* Theme switch: the icon shows the theme it switches to. */
.theme-btn { justify-content: flex-start; width: 100%; padding: 0 10px; }
.if-light { display: none; }
:root[data-theme="light"] .if-dark { display: none; }
:root[data-theme="light"] .if-light { display: inline-flex; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .if-dark { display: none; }
  :root:not([data-theme]) .if-light { display: inline-flex; }
}
.if-dark, .if-light { align-items: center; }
.solo-main { flex: 1 1 auto; display: flex; flex-direction: column; }
.app.solo { flex-direction: column; }

/* ---------- Full-screen header (check-in, focus) ---------- */
.solo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 32px;
  border-bottom: 1px solid var(--border);
}
.solo-header .btn-icon.framed { width: 34px; height: 34px; border: 1px solid var(--border); }
.app.solo { min-height: 100vh; }

/* Keyboard hints are useless on touch screens. */
@media (hover: none) {
  .kbd-hint, .option kbd, .btn-primary kbd { display: none; }
}
@media (max-width: 899px) {
  .solo-header { padding: 10px 16px; }
}

/* ---------- Command palette (Ctrl K) ---------- */
.palette {
  width: min(560px, calc(100vw - 32px));
  margin-top: 12vh;
  padding: 0;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
.palette::backdrop { background: rgba(0, 0, 0, 0.45); }
.palette-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.palette-input:focus-visible { outline: none; }
.palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-list li {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}
.palette-list li[aria-selected="true"] { background: var(--active); }
.palette-list .palette-empty { color: var(--muted); cursor: default; }
.palette-help { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.new-project { margin-top: -14px; }

/* Empty state inside a card. */
.empty { padding: 16px 18px; }

/* Links in a popover menu (mobile project list). */
.menu-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.menu-link:hover { background: var(--hover); }
.menu-link[aria-current="page"] { color: var(--accent-text); font-weight: 600; }

.nav-sep { height: 1px; margin: 8px 10px; background: var(--border); }
.proj-sq.domain { background: var(--muted); }
.cat-inbox {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  border: 1px dashed var(--border-strong);
  font-size: 12px;
  white-space: nowrap;
  color: var(--muted);
}

/* ---------- Voice recorder ---------- */
[hidden] { display: none !important; }
.rec-btn[data-recording] { border: 1px solid var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.rec-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 18px 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
}
.rec-status.ready { border-color: var(--accent-line); background: var(--accent-soft); }
.rec-status.ready .rec-dot { background: var(--accent); }
.rec-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.rec-wave { flex: 1 1 auto; max-width: 100%; }
.rec-wave rect { fill: var(--danger); }
.rec-status.ready .rec-wave rect { fill: var(--accent); }
.rec-time { font-size: 13px; }
.rec-big { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0; }
.mic-big {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-big[data-recording] { border: 0; background: var(--danger); color: #FFFFFF; box-shadow: 0 0 0 6px var(--danger-soft); }
.rec-big .rec-time { font-size: 14px; }
