:root { --blue: #204660; --blue-soft: #e8eef2; --text: #333; --muted: #6b6f60; --bg: #f7f7f7; --line: #e4e4e0; --coral: #f36a55; --coral-soft: #fdebe8; --gold: #c99f22; --gold-soft: #f8f1dc; --olive: #737665; --ok: #2e7d57; --ok-soft: #e7f2ec; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: "Work Sans", system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--blue); }

header { background: var(--blue); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
header img { height: 38px; display: block; }
header nav { margin-left: auto; display: flex; gap: 18px; align-items: center; }
header nav a { color: #fff; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; opacity: .85; }
header nav a:hover, header nav a[aria-current] { opacity: 1; box-shadow: 0 2px 0 var(--coral); }
header .who { margin-left: auto; font-size: 13px; opacity: .9; text-align: right; overflow-wrap: anywhere; }
header nav + .who { margin-left: 0; }
header .who button { background: none; border: 0; color: #fff; text-decoration: underline; padding: 0; font-size: 13px; }
main { max-width: 980px; margin: 0 auto; padding: 32px 16px 64px; }
.bar { width: 100px; height: 4px; background: var(--coral); margin-bottom: 14px; }
h1 { font-family: "Crimson Text", Georgia, serif; font-weight: 600; color: var(--blue); font-size: clamp(32px, 6vw, 46px); line-height: 1.05; margin: 0 0 10px; }
h2 { font-family: "Crimson Text", Georgia, serif; font-weight: 600; color: var(--blue); font-size: 26px; line-height: 1.15; margin: 0 0 6px; }
h3 { font-family: "Crimson Text", Georgia, serif; font-weight: 600; color: var(--blue); font-size: 21px; margin: 0; }
p { line-height: 1.55; margin: 0 0 12px; }
.lead { font-size: 18px; color: #444; max-width: 640px; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: #b3261e; font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--blue); color: #fff; border: 0; border-radius: 10px; padding: 13px 22px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 14px; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: #fff; color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue); }
.btn.small { padding: 8px 13px; font-size: 12px; }
.btn.danger { background: #fff; color: #b3261e; box-shadow: inset 0 0 0 1.5px #e3b3ad; }
.btn:disabled { opacity: .45; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; font-size: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-top: 22px; }
.field { border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; min-width: 0; }
.field:focus { border-color: var(--blue); outline: none; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--olive); margin-bottom: 8px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--text); }
.chip[aria-pressed=true], .chip.on { border-color: var(--blue); background: var(--blue); color: #fff; }
.chip small { font-size: 11px; opacity: .75; margin-left: 4px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--blue); color: #fff; padding: 13px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 14px; max-width: calc(100vw - 32px); z-index: 20; }
.toast.bad { background: #8c2a1e; }
.demo { background: var(--gold-soft); border: 1px solid #ead9a3; color: #6d5410; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 18px; }
.empty { padding: 26px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #d6d6d0; border-radius: 14px; margin-top: 18px; }

/* ---------- Accesso ---------- */
.login { max-width: 460px; }
.login form { display: grid; gap: 12px; margin-top: 22px; }
.login .field { width: 100%; font-size: 17px; padding: 13px 14px; }
.login .code { font-size: 28px; letter-spacing: .4em; text-align: center; font-weight: 600; color: var(--blue); }
.login .alt { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Giorni e turni ---------- */
.daystrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 18px 0 4px; scrollbar-width: thin; }
.daystrip a { flex: none; text-decoration: none; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 12px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; min-width: 66px; }
.daystrip a b { display: block; font-size: 20px; color: var(--blue); letter-spacing: 0; }
.daystrip a.has-mine { border-color: var(--gold); box-shadow: inset 0 -3px 0 var(--gold); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; margin-top: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--blue); }

.day { margin-top: 26px; scroll-margin-top: 12px; }
.day > .dhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.day > .dhead h2 { margin: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; border-radius: 6px; padding: 3px 7px; background: var(--coral); color: #fff; vertical-align: middle; }
.tag.soft { background: var(--blue-soft); color: var(--blue); }
.tag.warn { background: var(--coral-soft); color: #b3261e; }
.op { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
.op > .ohead { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; }
.op > .ohead .grow { flex: 1; min-width: 200px; }
.op > .ohead p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.op.skipped { opacity: .6; }
.slots { list-style: none; margin: 0; padding: 0; }
.slot { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot .time { font-weight: 600; color: var(--blue); font-variant-numeric: tabular-nums; white-space: nowrap; }
.slot .where { min-width: 0; }
.slot .where b { font-weight: 600; font-size: 16px; }
.people { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.person { background: var(--bg); border-radius: 999px; padding: 3px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.person.me { background: var(--gold-soft); box-shadow: inset 0 0 0 1.5px var(--gold); font-weight: 600; }
.person .x { border: 0; background: none; color: var(--muted); padding: 0 0 0 2px; font-size: 15px; line-height: 1; }
.person .x:hover { color: #b3261e; }
.person small { color: var(--muted); }
.nobody { font-size: 13px; color: #c2412f; font-weight: 500; }
.slot.mine { background: #fffdf6; box-shadow: inset 4px 0 0 var(--gold); }
.slot.past { opacity: .5; }
.slot.empty-slot .time { color: #c2412f; }
.slot .act { display: flex; gap: 8px; }
.joined { display: inline-flex; align-items: center; gap: 6px; color: #8a6a10; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- I miei turni ---------- */
.mine-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.mine-list li { display: flex; align-items: center; gap: 8px 16px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; flex-wrap: wrap; }
.mine-list .when { font-weight: 600; color: var(--blue); min-width: 200px; }
.mine-list .what { flex: 1; min-width: 160px; }
.mine-list .what small { display: block; color: var(--muted); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 24px 60px rgba(16, 39, 56, .3); color: var(--text); }
dialog::backdrop { background: rgba(16, 39, 56, .5); }
dialog form { padding: 24px; display: grid; gap: 16px; }
dialog .head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
dialog .head h2 { margin: 0; }
dialog .close { border: 0; background: var(--bg); border-radius: 10px; width: 38px; height: 38px; font-size: 20px; flex: none; }
dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
dialog .field { width: 100%; }
.foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.foot .err { margin-right: auto; }

/* ---------- Per postazione ---------- */
.seg { display: inline-flex; border: 1.5px solid var(--blue); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; color: var(--blue); padding: 8px 14px; font-weight: 600; font-size: 13px; }
.seg button[aria-pressed=true] { background: var(--blue); color: #fff; }
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; padding: 14px; background: #fafaf8; }
.post { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 12px; overflow: hidden; align-self: start; }
.post.has-mine { border-top-color: var(--gold); }
.post .phead { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.post .phead h4 { margin: 0; font-family: "Crimson Text", Georgia, serif; font-size: 20px; font-weight: 600; color: var(--blue); }
.post .phead span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.post .slot { grid-template-columns: 1fr auto; padding: 10px 14px; }
.post .slot .where { grid-column: 1 / -1; grid-row: 2; }
.post .slot .people { margin-top: 0; }
.clash { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }
.btn.busy { background: #eceee9; color: var(--muted); }

@media (max-width: 640px) {
  main { padding-top: 24px; }
  .posts { grid-template-columns: 1fr; padding: 10px; }
  .slot { grid-template-columns: 1fr auto; padding: 12px 14px; }
  .slot .time { grid-column: 1; }
  .slot .where { grid-column: 1 / -1; grid-row: 2; }
  .slot .act { grid-column: 2; grid-row: 1; }
  .op > .ohead { padding: 12px 14px; }
  header nav { gap: 12px; }
  header nav + .who #whoName, header nav + .who br { display: none; }
}
