/* Lar — style « Réglages » (iPhone first). Neutral base, one accent colour (dark blue),
   soft colours for the agendas, automatic dark mode. */

:root {
  color-scheme: light dark;
  --bg: #F2F2F7; --card: #FFFFFF; --text: #1C1C1E; --muted: #8A8A8E; --faint: #C4C4C9; --sep: #E3E3E8;
  --accent: #1F3B63; --accent-soft: #E6ECF4; --on-accent: #FFFFFF;
  --danger: #C2412F; --danger-soft: #FBE9E6; --warn: #8A6100; --warn-soft: #FBF1DA;
  --tab-bg: rgba(249, 249, 251, .92); --badge-bg: #EEEEF1; --badge-text: #55565C;
  --seg-bg: #E4E4E9; --seg-on: #FFFFFF; --input-bg: #FFFFFF;
  --ev-a: #6E8DB5; --ev-b: #B4879C; --ev-f: #B39567; --ev-t: #7D8590; --ev-h: #B9837A;
  --work: #E9E9EE; --free: #E6ECF4;
  --backdrop: rgba(0, 0, 0, .28);
  --tabbar: 83px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --text: #F2F2F7; --muted: #8D8D93; --faint: #55555A; --sep: #323236;
    --accent: #8FB1DE; --accent-soft: #1D2838; --on-accent: #0B1525;
    --danger: #E5735F; --danger-soft: #3A1E1A; --warn: #E2B65C; --warn-soft: #33290F;
    --tab-bg: rgba(22, 22, 24, .92); --badge-bg: #2C2C2F; --badge-text: #C7C7CC;
    --seg-bg: #2A2A2D; --seg-on: #48484C; --input-bg: #2A2A2D;
    --ev-a: #7F9CC2; --ev-b: #C298AC; --ev-f: #BFA27A; --ev-t: #8E96A1; --ev-h: #C8958C;
    --work: #232326; --free: #1D2838;
    --backdrop: rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.35 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }

main { max-width: 640px; margin: 0 auto;
       padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px); }

/* --- Page header: large title, actions on the right --- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 6px 4px 12px; }
.top h1 { font-size: 34px; font-weight: 700; letter-spacing: -.4px; line-height: 1.1; }
.top .date { font-size: 15px; color: var(--muted); font-weight: 500; margin-bottom: 3px; }
.top .actions { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.round { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
         display: grid; place-items: center; flex: none; }
.backlink { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 17px; padding: 4px 0 0; }

/* --- Grouped lists (as in Réglages) --- */
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
               padding: 20px 16px 7px; font-weight: 500; display: flex; justify-content: space-between; align-items: baseline; }
.group-title a { text-transform: none; letter-spacing: 0; font-size: 15px; }
.group-note { font-size: 13px; color: var(--muted); padding: 7px 16px 0; }
.card { background: var(--card); border-radius: 12px; overflow: hidden; }
.card + .card { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 46px; position: relative;
       background: var(--card); color: var(--text); width: 100%; text-align: left; }
.row + .row::before, .row + form > .row::before, form + .row::before, form + form > .row::before {
  content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: .5px solid var(--sep); }
.swipe + .swipe > .row::before, .row + .swipe > .row::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: .5px solid var(--sep); z-index: 2; }
.row.flat + .row::before, .row + .row.flat::before, .card.flat .row::before { left: 16px !important; }
a.row:active, button.row:active, .row[data-detail]:active { background: var(--seg-bg); }
.row .t { flex: 1; min-width: 0; }
.row .t b { font-weight: 400; display: block; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 2px; }
.row .end { color: var(--muted); font-size: 15px; display: flex; align-items: center; gap: 4px; flex: none; }
.row .chev { color: var(--faint); }
.row .lead { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; background: var(--accent); }
.time { width: 46px; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--muted); flex: none; }
.small { font-size: 15px; }
.muted { color: var(--muted); }
.late { color: var(--danger); }
.empty { padding: 14px 16px; color: var(--muted); font-size: 15px; }
.done-title { text-decoration: line-through; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--badge-text);
         background: var(--badge-bg); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--c, var(--muted)); }
.c-a { --c: var(--ev-a); } .c-b { --c: var(--ev-b); } .c-f { --c: var(--ev-f); } .c-t { --c: var(--ev-t); } .c-h { --c: var(--ev-h); }
.circle { width: 24px; height: 24px; border-radius: 50%; border: 1.6px solid var(--faint); flex: none; display: grid; place-items: center; color: transparent; }
.circle:active, .circle.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* --- Buttons and fields --- */
.btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 13px 16px; border-radius: 12px;
       background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 17px; }
.btn.light { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.inline { width: auto; display: inline-flex; padding: 8px 14px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .55; }
.btns { display: grid; gap: 10px; margin-top: 14px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.link { color: var(--accent); font-size: 15px; }
.field { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 46px; position: relative; background: var(--card); }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.field > span { flex: none; min-width: 92px; }
.field input, .field select, .field textarea { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
       font: inherit; font-size: 17px; padding: 12px 0; text-align: right; outline: none; -webkit-appearance: none; appearance: none; }
.field textarea { text-align: left; resize: none; min-height: 70px; }
.field.wide input, .field.wide textarea { text-align: left; }
.field select { direction: rtl; }
input, select, textarea { font: inherit; color: var(--text); }
.seg { display: flex; background: var(--seg-bg); border-radius: 9px; padding: 2px; font-size: 13px; font-weight: 500; }
.seg > * { flex: 1; text-align: center; padding: 6px 0; border-radius: 7px; color: var(--text); }
.seg > .on { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
.search { display: flex; align-items: center; gap: 6px; background: var(--seg-bg); border-radius: 10px; padding: 0 10px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; padding: 9px 0; font-size: 17px; outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--card); color: var(--text); font-size: 15px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--on-accent); }

/* --- Messages (toasts at the top) --- */
.msg { padding: 11px 14px; border-radius: 12px; margin: 0 0 10px; background: var(--accent-soft); color: var(--text); font-size: 15px;
       animation: drop .25s ease-out; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.warning { background: var(--warn-soft); color: var(--warn); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* --- Writing zone with the mic --- */
.capture { background: var(--card); border-radius: 12px; padding: 6px 6px 6px 14px; }
.capture .line { display: flex; align-items: flex-end; gap: 8px; }
.capture textarea { flex: 1; border: 0; background: transparent; resize: none; font: inherit; font-size: 17px; padding: 8px 0;
                    min-height: 40px; max-height: 180px; outline: none; color: var(--text); }
.capture textarea::placeholder { color: var(--muted); }
.mic { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; margin: 2px 0; }
.mic.listening { background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--danger) 25%, transparent); } }
.capture .tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 2px; }
.capture .tools[hidden] { display: none; }
.lang { display: inline-flex; background: var(--seg-bg); border-radius: 8px; padding: 2px; font-size: 13px; font-weight: 600; }
.lang button { padding: 3px 9px; border-radius: 6px; color: var(--muted); }
.lang button.on { background: var(--seg-on); color: var(--text); }
.capture .hint { font-size: 13px; color: var(--muted); flex: 1; }
.capture .send { width: auto; padding: 8px 16px; font-size: 15px; border-radius: 10px; }

/* --- Next appointment --- */
.next { margin-top: 14px; display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.next .box { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.next small { color: var(--accent); font-weight: 600; font-size: 13px; display: block; }
.next b { display: block; font-size: 17px; font-weight: 600; }

/* --- Tab bar (iPhone) / side menu (computer) --- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 7px 4px calc(env(safe-area-inset-bottom) + 4px);
          display: flex; justify-content: space-around; background: var(--tab-bg);
          -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--sep); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); width: 64px; font-weight: 500; }
.tabbar a.on { color: var(--accent); }
.tabbar .brand { display: none; }
@media (min-width: 900px) {
  main { margin-left: 240px; padding-top: 28px; }
  .tabbar { top: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; gap: 2px;
            border-top: 0; border-right: .5px solid var(--sep); padding: 22px 12px; }
  .tabbar .brand { display: block; font-weight: 700; font-size: 22px; padding: 0 12px 16px; color: var(--text); }
  .tabbar a { flex-direction: row; width: auto; gap: 12px; font-size: 16px; padding: 9px 12px; border-radius: 10px; }
  .tabbar a.on { background: var(--accent-soft); }
}

/* --- Sheet rising from the bottom --- */
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
               border: 0; border-radius: 14px 14px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 18px);
               background: var(--bg); color: var(--text); overscroll-behavior: contain; }
dialog.sheet[open] { animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: var(--backdrop); animation: fade .2s ease-out; }
dialog.sheet.closing { animation: sink .2s ease-in forwards; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sink { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--faint); margin: 0 auto 10px; }
.sheet .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet .head h2 { font-size: 22px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.sheet .head p { color: var(--muted); font-size: 15px; margin-top: 3px; }
.sheet .x { width: 30px; height: 30px; border-radius: 50%; background: var(--seg-bg); color: var(--muted); display: grid; place-items: center; flex: none; }
.sheet .group-title { padding-left: 4px; }
.sheet .warning { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 11px 14px; font-size: 15px; margin-bottom: 12px; }
.actions-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 14px; }
.actions-grid button, .actions-grid a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px 9px;
       border-radius: 12px; background: var(--card); color: var(--accent); font-size: 12px; font-weight: 500; }
.actions-grid .danger { color: var(--danger); }

/* --- Swipe a task: right = done, left = postpone / delete --- */
.swipe { position: relative; overflow: hidden; }
.swipe > .row { transition: transform .22s ease; touch-action: pan-y; z-index: 1; }
.swipe.dragging > .row { transition: none; }
.swipe .under { position: absolute; inset: 0; display: flex; justify-content: space-between; }
.swipe .under .left { display: flex; align-items: center; gap: 6px; padding-left: 20px; background: var(--accent); color: var(--on-accent);
                      font-weight: 600; font-size: 15px; flex: 1; }
.swipe .under .right { display: flex; }
.swipe .under .right button { width: 76px; display: grid; place-items: center; align-content: center; gap: 2px; color: #fff; font-size: 12px; }
.swipe .under .later { background: #8E8E93; } .swipe .under .del { background: var(--danger); }
.swipe.leaving > .row { transform: translateX(110%) !important; }
.swipe.gone { animation: collapse .25s ease forwards; }
@keyframes collapse { to { height: 0; opacity: 0; } }

/* --- Agenda --- */
.cal-head { display: flex; padding-left: 32px; margin: 8px 0 6px; }
.cal-head a { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.cal-head a b { display: block; margin: 3px auto 0; width: 30px; height: 30px; line-height: 30px; border-radius: 50%;
                font-size: 17px; font-weight: 500; color: var(--text); }
.cal-head a.today b { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-head a.weekend b { color: var(--muted); }
.allday { display: flex; padding-left: 32px; gap: 0; margin-bottom: 4px; }
.allday > div { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 1px; min-width: 0; }
.allday .ev-chip { font-size: 10.5px; padding: 2px 4px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
                   background: color-mix(in srgb, var(--c) 22%, var(--card)); color: color-mix(in srgb, var(--c) 70%, var(--text)); font-weight: 600; }
.grid { position: relative; margin-bottom: 8px; }
.grid .hour { position: absolute; left: 32px; right: 0; border-top: .5px solid var(--sep); }
.grid .hour span { position: absolute; left: -32px; top: -7px; font-size: 10.5px; color: var(--muted); width: 28px; }
.grid .cols { position: absolute; left: 32px; right: 0; top: 0; bottom: 0; display: flex; }
.grid .col { flex: 1; position: relative; min-width: 0; }
.grid .col + .col { border-left: .5px solid color-mix(in srgb, var(--sep) 60%, transparent); }
.grid .col.free { background: color-mix(in srgb, var(--free) 55%, transparent); }
.ev { position: absolute; left: 1px; right: 1px; border-radius: 6px; padding: 3px 4px; overflow: hidden; font-size: 10.5px; line-height: 1.2;
      font-weight: 600; background: color-mix(in srgb, var(--c) 22%, var(--card)); border-left: 3px solid var(--c);
      color: color-mix(in srgb, var(--c) 70%, var(--text)); text-align: left; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.ev small { display: block; font-weight: 500; opacity: .8; }
.ev.task { border-left-style: dashed; }
.ev.work { background: repeating-linear-gradient(135deg, var(--work) 0 6px, color-mix(in srgb, var(--work) 45%, var(--bg)) 6px 10px);
           border-left: 0; color: var(--muted); font-weight: 500; z-index: 0; }
.ev.busy-free { opacity: .6; }
.now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 3; }
.now::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.free-banner { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }
.free-banner b { color: var(--accent); }
.weeknav { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 2px; }
.weeknav a { display: inline-flex; align-items: center; color: var(--accent); font-size: 15px; padding: 4px 0; }
.weeknav strong { font-size: 15px; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--card); border-radius: 12px; overflow: hidden; padding: 6px 4px; }
.month .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0 6px; }
.month button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0 7px; border-radius: 10px; min-height: 50px; }
.month button b { width: 30px; height: 30px; line-height: 30px; border-radius: 50%; font-weight: 500; font-size: 16px; }
.month button.out b { color: var(--faint); }
.month button.today b { color: var(--accent); font-weight: 700; }
.month button.sel b { background: var(--accent); color: var(--on-accent); }
.month button.free { background: color-mix(in srgb, var(--free) 80%, transparent); }
.month .dots { display: flex; gap: 3px; height: 6px; }
.month .dots .dot { width: 5px; height: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); padding: 10px 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
body.hide-person-a .l-person-a, body.hide-person-b .l-person-b, body.hide-household .l-household,
body.hide-work .l-work, body.hide-tasks .l-tasks, body.hide-holiday .l-holiday, body.hide-sessions .l-sessions { display: none !important; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--seg-bg); transition: background .2s; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
                   box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

/* --- Sensitive values --- */
.secret { font-family: ui-monospace, "SF Mono", monospace; letter-spacing: .5px; }
pre.report { white-space: pre-wrap; font: 13px/1.5 ui-monospace, "SF Mono", monospace; margin: 0; padding: 12px 16px; overflow-x: auto; }
table.plain { border-collapse: collapse; width: 100%; font-size: 15px; }
table.plain td, table.plain th { text-align: left; padding: 9px 16px; border-top: .5px solid var(--sep); vertical-align: top; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Polish */
.sheet .x:focus, .sheet .x:focus-visible { outline: none; }
.btn.inline { white-space: nowrap; font-size: 14px; padding: 7px 12px; }
