:root {
  --accent: #2456c7; --accent-fg: #fff; --bg: #f7f7f5; --surface: #fff; --text: #1f2328;
  --radius: 10px; --fs: 15px; --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --muted: color-mix(in srgb, var(--text) 66%, var(--bg));
  --border: color-mix(in srgb, var(--text) 18%, var(--bg));
  --soft: color-mix(in srgb, var(--text) 6%, var(--surface));
  --danger: #b42318;
}
* { box-sizing: border-box; }
html { font-size: var(--fs); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1 { font-size: 1.8rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
[hidden] { display: none !important; }

#app { display: flex; min-height: 100vh; }
#nav { flex: 0 0 215px; padding: 16px 10px; background: var(--soft); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav .brand { font-weight: 700; font-size: 1.1rem; padding: 6px 10px 12px; }
#nav a { display: flex; align-items: center; min-height: 42px; padding: 6px 10px; border-radius: calc(var(--radius) * .8); color: var(--text); text-decoration: none; font-weight: 500; }
#nav a:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
#nav a.on { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--text); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
#nav .sep { flex: 1; min-height: 10px; }
#main { flex: 1; min-width: 0; padding: 22px 26px 60px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 820px) {
  #app { flex-direction: column; }
  #nav { flex: none; flex-direction: row; height: auto; position: sticky; z-index: 5; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--border); background: var(--bg); }
  #nav .brand, #nav .sep { display: none; }
  #nav a { white-space: nowrap; }
  #nav a.on { box-shadow: inset 0 -3px 0 var(--accent); }
  #main { padding: 14px 12px 60px; }
}

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1 1 160px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.empty { color: var(--muted); padding: 6px 2px; margin: 0; }

.btn, .plus, .tab, select, input, textarea { min-height: 40px; border: 1px solid var(--border); border-radius: calc(var(--radius) * .8); background: var(--surface); padding: 6px 12px; }
.btn { font-weight: 500; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover, .tab:hover { background: var(--soft); }
.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; min-height: 40px; border-radius: calc(var(--radius) * .8); padding: 6px 14px; border-style: solid; border-width: 1px; }
.danger { color: var(--danger); }
.plus { min-width: 42px; min-height: 42px; padding: 0; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-size: 1.5rem; font-weight: 600; line-height: 1; }
.plus.mini { min-width: 26px; min-height: 26px; width: 26px; height: 26px; font-size: 1.05rem; border-radius: 6px; background: transparent; color: var(--muted); border-color: transparent; }
.plus.mini:hover, .cal-c:hover .plus.mini, .cal-week .col:hover .plus.mini { background: var(--soft); color: var(--text); border-color: var(--border); }
@media (hover: none) { .plus.mini { background: var(--soft); color: var(--text); } }
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.cal-c.over, .cal-week .col.over { outline: 2px solid var(--accent); outline-offset: -2px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.chip[draggable=true] { cursor: grab; }
.chip.ext { opacity: .82; border: 1px dashed currentColor; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { font-weight: 550; }
.tab.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
input[type=checkbox] { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); padding: 0; }
input[type=color] { padding: 2px; width: 46px; }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; font-weight: 600; color: var(--muted); min-width: 0; }
label.f > * { font-size: 1rem; font-weight: 400; color: var(--text); }

.menu { position: fixed; z-index: 50; min-width: 210px; max-height: 60vh; overflow: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 2px; }
.menu .hd { padding: 4px 8px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.menu button { min-height: 42px; text-align: left; border: 0; background: none; border-radius: calc(var(--radius) * .6); padding: 6px 10px; }
.menu button:hover { background: var(--soft); }

.list { display: flex; flex-direction: column; gap: 4px; }
.item { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; min-height: 44px; padding: 6px 10px; border: 0; border-radius: calc(var(--radius) * .6); background: var(--soft); text-align: left; width: 100%; }
button.item:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.item .t { flex: 1 1 180px; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.item .t.done { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 9%, var(--surface)); white-space: nowrap; }
.tag button { border: 0; background: none; padding: 0 2px; min-height: 0; font-size: 1rem; line-height: 1; }
.late { color: var(--danger); font-weight: 600; }
.linkbtn { border: 0; background: none; padding: 0; min-height: 0; font-weight: 550; text-align: left; color: var(--text); }
.linkbtn:hover { color: var(--accent); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: .85rem; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t th button { border: 0; background: none; padding: 0; font-weight: 600; color: inherit; min-height: 0; }
table.t td { padding: 5px 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
table.t tr.click:hover td { background: var(--soft); cursor: pointer; }
.scroll { overflow-x: auto; }
table.t td input, table.t td select { width: 100%; min-width: 90px; border-color: transparent; background: transparent; padding: 4px 6px; min-height: 36px; }
table.t td input:hover, table.t td select:hover, table.t td input:focus { border-color: var(--border); background: var(--surface); }
table.t td input[type=checkbox] { width: 20px; min-width: 0; }

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.pcard { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.pcard:hover { border-color: var(--accent); }
.pcard .cover { height: 110px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.pcard .cover img { width: 100%; height: 100%; object-fit: cover; }
.pcard .in { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.banner { height: 190px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; min-width: 620px; }
.cal-month.compact { min-width: 0; }
.cal-h { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 2px 4px; }
.cal-c { min-height: 96px; padding: 4px; border: 1px solid var(--border); border-radius: calc(var(--radius) * .5); background: var(--surface); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.compact .cal-c { min-height: 64px; }
.cal-c.out { background: transparent; }
.cal-c.out .n { color: var(--muted); }
.cal-c.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-c .n { border: 0; background: none; padding: 0 4px; min-height: 26px; font-weight: 600; font-size: .85rem; text-align: left; align-self: flex-start; border-radius: 6px; }
.cal-c .n:hover { background: var(--soft); }
.chip { border: 0; border-radius: 5px; padding: 2px 5px; min-height: 24px; font-size: .78rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; min-width: 760px; }
.cal-week .col { min-height: 280px; padding: 6px; border: 1px solid var(--border); border-radius: calc(var(--radius) * .6); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.cal-week .col.today { border-color: var(--accent); }
.cal-week .chip { white-space: normal; min-height: 40px; padding: 4px 6px; font-size: .85rem; }
.cal-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.cal-year button { text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.cal-year .mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; font-size: .7rem; text-align: center; }
.cal-year .mini span { padding: 2px 0; border-radius: 4px; }
.cal-year .mini .has { background: var(--accent); color: var(--accent-fg); }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.board .col { background: var(--soft); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; border: 2px solid transparent; }
.board .col.over { border-color: var(--accent); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .7); padding: 10px; display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: grab; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); padding: 0; max-width: min(960px, 96vw); width: 100%; max-height: 94vh; }
dialog::backdrop { background: rgba(0,0,0,.42); }
dialog.small { max-width: min(460px, 94vw); }
.dlg { display: flex; flex-direction: column; max-height: 94vh; }
.dlg > header, .dlg > footer { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dlg > header { border-bottom: 1px solid var(--border); }
.dlg > footer { border-top: 1px solid var(--border); }
.dlg > .body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.ed-title { width: 100%; font-size: 1.5rem; font-weight: 700; border: 0; background: transparent; padding: 4px 0; }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.props .wide { grid-column: 1 / -1; }
.props label.f > input, .props label.f > select { width: 100%; }
.md { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .8); padding: 12px 14px; min-height: 120px; overflow-wrap: anywhere; }
.md img { max-width: 100%; border-radius: 6px; }
.md img[src^="/files/dessin-"] { border: 1px dashed var(--border); cursor: pointer; }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--border); padding: 4px 8px; }
.md pre { background: var(--soft); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.wikilink.missing { color: var(--muted); text-decoration: line-through; }
.embed-base { border: 1px solid var(--border); border-radius: calc(var(--radius) * .6); padding: 8px; margin: 8px 0; overflow-x: auto; }
textarea.src { min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; }
.imgfield img { width: 120px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

dialog.draw { max-width: 100vw; width: 100vw; height: 100vh; max-height: 100vh; border: 0; border-radius: 0; }
dialog.draw .dlg { height: 100vh; max-height: 100vh; }
dialog.draw canvas { flex: 1; min-height: 0; width: 100%; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.swatch { width: 36px; height: 36px; min-height: 0; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--text); }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.on { opacity: 1; }
#login { max-width: 340px; margin: 14vh auto; padding: 24px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
#login-msg { color: var(--danger); margin: 0; min-height: 1.4em; }
#print { display: none; }

@media print {
  #nav, #toast, dialog, .noprint, .plus { display: none !important; }
  body { background: #fff; color: #000; }
  #main { padding: 0; }
  body.print-item #app { display: none !important; }
  body.print-item #print { display: block; }
  .card, .md { border-color: #bbb; break-inside: avoid; }
  #print .md { border: 0; padding: 0; }
}
