/* vayu.term : theme terminal, mobile d'abord */

:root {
  --bg: #000000;
  --panel: #101410;
  --line: #1d231d;
  --txt: #e6e8e6;
  --dim: #808a80;
  --dim2: #565e56;
  --acc: #3fdd5d;
  --acc-soft: rgba(63, 221, 93, .12);
  --blue: #7aa2f7;
  --amber: #f5c451;
  --red: #f26d6d;
  --fs: 15px;
  --pad: 26px; /* marge laterale : respire sur mobile */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", Consolas, monospace;
}
:root[data-accent="ambre"] { --acc: #f5c451; --acc-soft: rgba(245, 196, 81, .12); --blue: #f08c3c; }
:root[data-accent="cyan"] { --acc: #4dd8e0; --acc-soft: rgba(77, 216, 224, .12); --blue: #7aa2f7; }
:root[data-fs="small"] { --fs: 13px; }
:root[data-fs="large"] { --fs: 17px; }
:root[data-fs="largest"] { --fs: 19px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: 1.45;
  background: var(--bg);
  color: var(--txt);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 0 0;
}
#app, .screen { max-width: 560px; margin: 0 auto; }

.hidden { display: none !important; }
.acc { color: var(--acc); }
.blue { color: var(--blue); }
.dim { color: var(--dim); }
.dim2 { color: var(--dim2); }
.red { color: var(--red); }
.amber { color: var(--amber); }

/* ---------- ecrans auth ---------- */

.screen { display: flex; min-height: 90dvh; align-items: center; justify-content: center; padding: 24px var(--pad); }
.boot-box { text-align: center; }
.blink::after { content: "_"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.auth-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-box label { display: flex; flex-direction: column; gap: 6px; color: var(--txt); }

input, textarea, select {
  font: inherit;
  color: var(--txt);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--acc); }
textarea { resize: vertical; min-height: 120px; }

/* iOS : les champs date/heure ont une largeur native qui deborde de l'ecran.
   appearance:none rend la main au CSS ; on garde la hauteur des autres champs. */
input[type="date"], input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: calc(1.45em + 22px);
  text-align: left;
}

button, .btn-acc, .btn-dim {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--txt);
  -webkit-tap-highlight-color: transparent;
}
.btn-acc, .btn-dim {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
}
.btn-acc { color: var(--acc); background: var(--acc-soft); }
.btn-acc:active { opacity: .7; }
.btn-dim { color: var(--dim); background: var(--panel); }

.form-error { color: var(--red); }

/* ---------- navigation ---------- */

#tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
#tabs::-webkit-scrollbar { display: none; }
#tabs { padding: 0 10px; }
.tab {
  flex: 1 0 auto;
  padding: 14px 16px 11px;
  color: var(--dim);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active { color: var(--acc); font-weight: 700; border-bottom-color: var(--acc); }

.prompt-line { padding: 14px var(--pad) 6px; font-weight: 700; }

/* ligne de commande integree au prompt */
#prompt { display: flex; align-items: baseline; gap: 6px; }
#prompt .blue { flex-shrink: 0; }
#cmdline {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-weight: 700;
  caret-color: var(--acc);
}
#cmdline::placeholder { color: var(--txt); opacity: 1; font-weight: 700; }
#cmdline:focus::placeholder { color: var(--dim2); }
#cmd-out { padding: 0 var(--pad) 4px; font-size: .9em; }
#cmd-out::before { content: "> "; color: var(--dim2); }
#cmd-out.err { color: var(--red); }

/* bandeau focus (pomodoro) */
#focus-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px var(--pad) 0;
  padding: 8px 12px;
  border: 1px solid var(--acc);
  border-radius: 8px;
  background: var(--acc-soft);
  font-weight: 700;
}
#focus-banner .time { color: var(--acc); font-variant-numeric: tabular-nums; }
#focus-banner .grow { flex: 1; }

/* ---------- contenu ---------- */

main#view { padding: 8px var(--pad) calc(96px + env(safe-area-inset-bottom)); }

.section { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.section-title { font-weight: 700; margin-bottom: 4px; }
.section-title .ico { color: var(--acc); margin-right: 8px; }
.comment { color: var(--dim); }
.comment::before { content: "// "; color: var(--dim2); }

.row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .meta { color: var(--dim); font-size: .86em; margin-top: 2px; }
.row.done .title { color: var(--dim2); text-decoration: line-through; }

.check {
  color: var(--dim);
  padding: 2px 4px;
  font-weight: 700;
  flex-shrink: 0;
}
.check.on { color: var(--acc); }

.mini { color: var(--dim); font-size: .86em; padding: 4px 2px; }
.mini:active, .check:active { opacity: .6; }
.mini.danger { color: var(--red); }

.tag { color: var(--blue); }
.tag.travail { color: #f08c3c; }
.tag.dev { color: var(--acc); }
.tag.jeu { color: #c792ea; }
.tag.sorties { color: var(--amber); }
.tag.perso { color: var(--blue); }

.prio-high { color: var(--red); font-weight: 700; }
.prio-low { color: var(--dim2); }
.overdue { color: var(--red); }

/* liseré de couleur selon la priorité de la tâche */
.row[class*="prio-"] { border-left: 2px solid transparent; padding-left: 10px; }
.row.prio-2 { border-left-color: var(--red); }
.row.prio-0 { border-left-color: var(--dim2); }
.row.done[class*="prio-"] { border-left-color: transparent; }

/* couleurs du sélecteur de priorité dans la modale */
#t-prio [data-v="0"].on { color: var(--dim); }
#t-prio [data-v="2"].on { color: var(--red); }

/* selecteurs style [option] */
.opts { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.opt { color: var(--dim); padding: 4px 0; }
.opt.on { color: var(--acc); font-weight: 700; }

/* bandeau semaine */
.week { display: flex; align-items: center; gap: 2px; margin: 10px 0 4px; }
.week .cell { flex: 1; text-align: center; }
.week .dow { color: var(--dim); font-size: .8em; }
.week .num { padding: 3px 0; border-radius: 7px; margin-top: 2px; }
.week .num.today { background: var(--acc); color: #000; font-weight: 700; }
.week .dot { height: 6px; font-size: .6em; color: var(--acc); }
.week .nav { color: var(--acc); padding: 0 6px; font-weight: 700; }

/* barres stats */
.bar-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.bar-row .lbl { width: 3ch; color: var(--dim); flex-shrink: 0; }
.bar-row .pct { width: 5ch; text-align: right; flex-shrink: 0; }
.bar { flex: 1; height: 12px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--acc); border-radius: 3px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.kv .v { color: var(--acc); font-weight: 700; text-align: right; }

/* heatmap habitudes (colonnes = semaines, lignes = jours) */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  width: max-content;
  margin-top: 8px;
}
.heatmap i { width: 11px; height: 11px; border-radius: 2px; background: var(--panel); }
.heatmap i.off { background: transparent; }
.heatmap i.lvl1 { background: color-mix(in srgb, var(--acc) 25%, var(--panel)); }
.heatmap i.lvl2 { background: color-mix(in srgb, var(--acc) 50%, var(--panel)); }
.heatmap i.lvl3 { background: color-mix(in srgb, var(--acc) 75%, var(--panel)); }
.heatmap i.lvl4 { background: var(--acc); }
.heatmap i.today { outline: 1px solid var(--txt); }
.heatmap-legend { display: flex; align-items: center; gap: 4px; margin-top: 6px; color: var(--dim2); font-size: .8em; }
.heatmap-legend i { width: 11px; height: 11px; border-radius: 2px; background: var(--panel); display: inline-block; }
.heatmap-legend i.lvl2 { background: color-mix(in srgb, var(--acc) 50%, var(--panel)); }
.heatmap-legend i.lvl4 { background: var(--acc); }

/* ---------- barre d'actions ---------- */

#actionbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
#actionbar:empty { display: none; }
#actionbar .spacer { flex: 1; }
#actionbar button { font-weight: 700; padding: 10px 14px; border-radius: 8px; }
#actionbar .primary { color: var(--acc); background: var(--acc-soft); }
#actionbar .secondary { color: var(--blue); background: rgba(122, 162, 247, .12); }
#actionbar .ghost { color: var(--dim); }

/* ---------- modale ---------- */

#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
#modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: #060806;
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#modal-box label { display: flex; flex-direction: column; gap: 6px; }
#modal-box .modal-actions { display: flex; gap: 8px; margin-top: 6px; }
#modal-box .modal-actions button { flex: 1; white-space: nowrap; min-width: 0; padding: 11px 6px; }

/* jours de la semaine (habitudes) */
.days-picker { display: flex; gap: 6px; }
.days-picker button {
  flex: 1;
  padding: 8px 0;
  border-radius: 7px;
  background: var(--panel);
  color: var(--dim);
}
.days-picker button.on { background: var(--acc-soft); color: var(--acc); font-weight: 700; }

/* ---------- notes ---------- */

.note-open { text-align: left; min-width: 0; }
.note-open .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note-editor { display: flex; flex-direction: column; gap: 10px; }
.note-editor textarea { min-height: 45dvh; }

/* rendu markdown (aperçu des notes) */
.md { display: flex; flex-direction: column; gap: 8px; min-height: 45dvh; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { color: var(--acc); }
.md h1 { font-size: 1.25em; }
.md h2 { font-size: 1.12em; }
.md h3 { font-size: 1em; }
.md ul, .md ol { padding-left: 22px; display: flex; flex-direction: column; gap: 2px; }
.md code { background: var(--panel); border-radius: 4px; padding: 1px 5px; }
.md pre { background: var(--panel); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 2px solid var(--acc); padding-left: 10px; color: var(--dim); }
.md a { color: var(--blue); }
.md hr { border: none; border-top: 1px solid var(--line); }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 9px 16px;
  z-index: 30;
  max-width: 90vw;
}
#toast.err { color: var(--red); }
#toast button { color: var(--acc); font-weight: 700; margin-left: 12px; padding: 0; }

/* surlignage recherche */
mark { background: var(--acc-soft); color: var(--acc); }

/* petit confort tactile */
@media (pointer: coarse) {
  .mini { padding: 8px 6px; }
  .check { padding: 6px 8px; }
}
