/* Cockpit — console de pilotage. Thème sombre par défaut, variante claire pilotée par Telegram. */
:root {
  --bg: #0e0f13;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #1b1d27 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 0%, #161922 0%, transparent 55%);
  --surface: #161821;
  --surface-2: #1d2029;
  --line: #262a35;
  --text: #ece9e1;
  --muted: #8b8e9b;
  --faint: #5b5e6b;
  --accent: #e8b04b;
  --accent-ink: #2a1f06;
  --pos: #6cc28d;
  --neg: #e0696f;
  --info: #6fa8dc;
  --shadow: 0 12px 40px -16px rgba(0, 0, 0, 0.7);
  --radius: 16px;
  --radius-sm: 11px;
  --maxw: 620px;
}
[data-theme='light'] {
  --bg: #f4f1ea;
  --bg-grad: radial-gradient(1100px 600px at 85% -10%, #fffaf0 0%, transparent 55%),
    radial-gradient(800px 500px at -5% 0%, #fbf4e7 0%, transparent 50%);
  --surface: #ffffff;
  --surface-2: #f6f2e9;
  --line: #e7e1d4;
  --text: #1b1c22;
  --muted: #6f7180;
  --faint: #a6a392;
  --accent: #c98a16;
  --accent-ink: #fff6e2;
  --pos: #2f9e63;
  --neg: #c8453f;
  --info: #2f6fb0;
  --shadow: 0 16px 40px -22px rgba(60, 50, 20, 0.4);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--maxw);
  margin: 0 auto;
}

/* Top bar */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  background: linear-gradient(var(--bg) 62%, transparent);
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(150deg, var(--accent), #b97f1f);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 6px 16px -6px var(--accent);
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-text strong {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.brand-text span {
  font-size: 12px;
}

/* Views */
#view {
  flex: 1;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 92px);
  animation: fade 0.28s ease both;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.boot {
  display: grid;
  place-items: center;
  height: 50vh;
  color: var(--muted);
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 2px 10px;
}
.section-title h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card {
  margin-top: 12px;
}
.pad {
  padding: 16px;
}

/* Hero recap */
.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 18px 18px;
}
.hero .eyebrow {
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
}
.hero .big {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: clamp(46px, 17vw, 76px);
  line-height: 0.92;
  margin: 8px 0 2px;
  letter-spacing: -1px;
}
.hero .big small {
  font-size: 0.34em;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
.hero .sub {
  font-size: 14px;
  color: var(--muted);
}
.streak {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

/* Chart */
.chart {
  width: 100%;
  height: 96px;
  display: block;
  margin-top: 14px;
}
.chart rect {
  transition: height 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), y 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.chart .axis {
  fill: var(--faint);
  font-size: 9px;
  font-family: 'IBM Plex Mono', monospace;
}

/* Stat grid */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
}
.stat .n {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1;
}
.stat .l {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}
.stat.alert .n {
  color: var(--neg);
}

/* Lists / rows */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.row:last-child {
  border-bottom: 0;
}
.row-main {
  flex: 1;
  min-width: 0;
}
.row-title {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-title.done {
  color: var(--faint);
  text-decoration: line-through;
}
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}
.chip {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.due-over {
  color: var(--neg);
  border-color: color-mix(in srgb, var(--neg) 40%, var(--line));
}
.chip.accent {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.pri {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.pri-1 {
  background: var(--neg);
}
.pri-2 {
  background: var(--faint);
}
.pri-3 {
  background: transparent;
  border: 1px solid var(--faint);
}

/* Round check */
.check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--faint);
  background: transparent;
  flex: none;
  display: grid;
  place-items: center;
  color: transparent;
  cursor: pointer;
  transition: all 0.18s;
}
.check:active {
  transform: scale(0.86);
}
.check.on {
  background: var(--pos);
  border-color: var(--pos);
  color: #06210f;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: linear-gradient(160deg, var(--accent), #c4881d);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn-ghost {
  background: transparent;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}
.btn-danger {
  color: var(--neg);
  border-color: color-mix(in srgb, var(--neg) 35%, var(--line));
}
.row-actions {
  display: flex;
  gap: 7px;
  flex: none;
}
.icon-btn {
  font: inherit;
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:active {
  transform: scale(0.94);
}

/* Banners */
.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.4;
  margin-bottom: 12px;
}
.banner.warn {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.banner.hi {
  background: color-mix(in srgb, var(--neg) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--neg) 35%, var(--line));
}

/* Bottom nav */
#nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--maxw);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.nav-btn {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: 11px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.nav-btn .nav-ico {
  font-size: 17px;
  line-height: 1;
}
.nav-btn.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* FAB */
.fab {
  position: fixed;
  right: max(16px, calc(50% - var(--maxw) / 2 + 16px));
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  font-size: 26px;
  color: var(--accent-ink);
  background: linear-gradient(160deg, var(--accent), #c4881d);
  box-shadow: 0 12px 28px -10px var(--accent);
  cursor: pointer;
  z-index: 25;
}
.fab:active {
  transform: scale(0.92);
}

/* Empty */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 18px;
  font-size: 14px;
}
.empty .ic {
  font-size: 30px;
  opacity: 0.5;
  display: block;
  margin-bottom: 8px;
}

/* Sheet (bottom modal) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s ease both;
}
.sheet {
  width: 100%;
  max-width: var(--maxw);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.6);
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  max-height: 88vh;
  overflow-y: auto;
}
@keyframes rise {
  from {
    transform: translateY(100%);
  }
}
.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 8px auto 14px;
}
.sheet h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  margin: 0 0 16px;
  font-size: 20px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.input,
.select,
textarea.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}
.field-row {
  display: flex;
  gap: 10px;
}
.field-row > .field {
  flex: 1;
}
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.seg button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}
.seg button.on {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  border-color: var(--accent);
  color: var(--accent);
}
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.sheet-actions .btn {
  flex: 1;
}

/* Toast */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: toast 0.25s ease both;
}
.toast.err {
  background: var(--neg);
  color: #fff;
}
@keyframes toast {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Journal timeline */
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 2px 8px;
  font-size: 13px;
}
.day-head .d {
  font-weight: 600;
}
.day-head .s {
  color: var(--muted);
  font-size: 12px;
}
.tl {
  position: relative;
}
.tl-item {
  position: relative;
  padding: 7px 0 11px 22px;
  font-size: 14px;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}
.tl-item:last-child::before {
  bottom: auto;
  height: 13px;
}
.tl-item::after {
  content: '';
  position: absolute;
  left: 1px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--pos);
}
.tl-item .t {
  color: var(--muted);
  font-size: 12px;
}
