:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2430; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2563eb; --ok: #16a34a; --ok-bg: #dcfce7; --warn: #f59e0b; --warn-bg: #fef3c7;
  --danger: #dc2626; --bar: #93c5fd;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; max-width: 720px; margin: 0 auto; }
header form { margin: 0; }
h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
main { max-width: 720px; margin: 0 auto; padding: 0 1rem 3rem; }
main.login { padding-top: 3rem; max-width: 360px; }
main.login h1 { margin-bottom: 1.5rem; text-align: center; }
main.login form { display: flex; flex-direction: column; gap: .75rem; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .9rem; margin: .25rem 0 .75rem; }
input, button { font: inherit; }
input { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
button { padding: .55rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.link { border: 0; background: none; padding: .3rem .4rem; color: var(--primary); }
button.danger { color: var(--danger); }
#name-form { display: flex; gap: .5rem; }
#name-form input { flex: 1; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.range label { display: flex; align-items: center; gap: .4rem; flex: 1 1 10rem; }
.range input { flex: 1; }
.range button { margin-left: auto; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.actions .primary { margin-left: auto; }
.msg { min-height: 1.4em; margin: .5rem 0; font-size: .9rem; color: var(--ok); }
.msg.error { color: var(--danger); }
ul { margin: 0; padding-left: 1.2rem; }
li { margin: .2rem 0; }
li.hint { list-style: none; margin-left: -1.2rem; }
#all li::marker { color: var(--ok); }
#all-but-one li::marker { color: var(--warn); }

/* Frise */
.timeline { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; }
.tl-inner { padding: .5rem; }
.tl-row { display: flex; align-items: center; height: 28px; }
.tl-row.months { height: 22px; font-size: .75rem; color: var(--muted); }
.tl-label { flex: 0 0 90px; padding-right: .5rem; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-row.common .tl-label { font-weight: 600; }
.tl-track { flex: 1; position: relative; height: 18px; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% - 1px)); border-bottom: 1px dashed var(--line); }
.tl-bar { position: absolute; top: 0; height: 100%; border-radius: 4px; background: var(--bar); }
.tl-bar.all { background: var(--ok); }
.tl-bar.partial { background: var(--warn); opacity: .8; }
.tl-tick { position: absolute; top: 0; border-left: 1px solid var(--line); padding-left: 3px; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .8rem; color: var(--muted); margin-top: .5rem; }
.legend i { display: inline-block; width: 14px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.lg-bar { background: var(--bar); } .lg-all { background: var(--ok); } .lg-partial { background: var(--warn); }
.hard { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.55) 0 3px, transparent 3px 6px); }
.tl-bar.hard { opacity: 1; }
.who { color: var(--muted); }

/* Sélecteur de niveau */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: .6rem; }
.seg button { border: 0; border-radius: 0; background: #fff; padding: .45rem .8rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: #fff; }
.seg button.on[data-level="hard"] { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.25) 0 3px, transparent 3px 6px); }
.range select { padding: .5rem .4rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }

/* Calendrier */
.cal { user-select: none; -webkit-user-select: none; margin-bottom: .5rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.cal-head button { font-size: 1.4rem; line-height: 1; padding: .2rem .8rem; }
.cal-head strong { text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; touch-action: none; }
.cal-grid .wd { text-align: center; font-size: .75rem; color: var(--muted); padding: .2rem 0; }
.cal-grid .day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: .9rem; cursor: pointer; background: var(--bg); }
.cal-grid .day.other { color: var(--muted); opacity: .6; }
.cal-grid .day.past { color: var(--muted); opacity: .45; }
.cal-grid .day.today { outline: 1px solid var(--primary); outline-offset: -1px; }
.cal-grid .day.mine { background: var(--bar); color: #0b3a75; opacity: 1; }
.cal-grid .day.mine.hard { background-color: var(--bar); }
.cal-grid .day.sel { background-color: var(--primary); background-image: none; color: #fff; opacity: 1; }
.cal-grid .day.sel.sel-hard { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.3) 0 3px, transparent 3px 6px); }

/* Hachures "compliqué" : règles spécifiques, placées en dernier pour gagner sur les raccourcis background */
.cal-grid .day.mine.hard, .tl-bar.hard, .tl-bar.all.hard, .tl-bar.partial.hard, .lg-bar.hard {
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.55) 0 3px, transparent 3px 6px);
}
