@font-face {
  font-family: Manrope;
  src: url("./assets/manrope.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "SafeZone Symbols";
  src: url("./assets/symbols.woff2") format("woff2");
  font-display: block;
}

:root {
  color-scheme: light dark;
  font: 15px/1.55 Manrope, system-ui, sans-serif;
  --ink: light-dark(#202b24, #edf2ea);
  --muted: light-dark(#536155, #bccabf);
  --canvas: light-dark(#f6f5ef, #17221c);
  --paper: light-dark(#fffefa, #202f27);
  --input: light-dark(#fffefa, #1b2821);
  --line: light-dark(#e0e4d9, #3f5448);
  --border: light-dark(#a3b1a4, #738d7d);
  --soft: light-dark(#e6eee4, #2c4538);
  --badge-ink: light-dark(#274d3c, #d5eddb);
  --pine: light-dark(#184738, #96c6a8);
  --on-pine: light-dark(#fff, #132b20);
  --focus: light-dark(#9b4d25, #f0ab82);
  --clay: light-dark(#944020, #ffb48c);
  --warm: light-dark(#f3e6d7, #50392d);
  --blue: light-dark(#e4efee, #283e40);
  --blue-ink: light-dark(#315c5b, #bfe0df);
  --chat: light-dark(#edf1e8, #1a2821);
  --own-bubble: light-dark(#dcecdf, #28523f);
  --shadow: 0 2px 6px #142b1a07, 0 14px 32px #142b1a07;
  --edge: clamp(20px, 4vw, 54px);
  background: var(--canvas);
  color: var(--ink);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
main:focus { outline: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 800; line-height: 1.15; letter-spacing: -.035em; overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
p { overflow-wrap: anywhere; }
.symbol {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1em;
  height: 1em;
  overflow: hidden;
  font: 400 22px/1 "SafeZone Symbols", sans-serif;
  font-feature-settings: "liga";
  letter-spacing: normal;
  white-space: nowrap;
}

.sign-in { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); }
.welcome {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 120px;
  min-width: 0;
  padding: clamp(32px, 5.5vw, 80px);
  color: #fff;
  background: linear-gradient(180deg, #152d24aa 0%, #152d2412 34%, #132c24b8 63%, #112820 100%),
    #243f31 url("./assets/quartiere.webp") center 44% / cover no-repeat;
}
.welcome-top, .brand { display: flex; gap: 12px; align-items: center; font-size: 1.32rem; font-weight: 800; letter-spacing: -.035em; }
.welcome-top img, .brand img { border-radius: 11px; flex: none; }
.welcome-copy { padding-block: 0 clamp(4px, 3vw, 40px); }
.welcome h1 { max-width: 12ch; font-size: clamp(2.8rem, 5.6vw, 5.7rem); line-height: 1.03; letter-spacing: -.07em; }
.welcome p { max-width: 37ch; margin-top: 20px; color: #edf3e9; font-size: clamp(1rem, 1.45vw, 1.17rem); }
.access { display: grid; place-items: center; padding: clamp(24px, 5vw, 90px); background: var(--paper); }
.access-content { width: min(100%, 370px); }
.access h2 { font-size: clamp(1.8rem, 3vw, 2.55rem); }
.access p { margin: 12px 0 28px; color: var(--muted); }
.access > div > .button { width: 100%; min-height: 50px; }
.google-login { gap: 10px; }
.google-mark {
  font-family: system-ui, sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: light-dark(#2356aa, #a8c7fa);
}
.access p.access-status { margin: 14px 0 0; min-height: 1.5em; color: var(--clay); font-size: .92rem; }
.email-access, .facebook-login { margin-top: 14px; }
.email-access { border-top: 1px solid var(--line); }
.email-access summary { cursor: pointer; font-weight: 750; padding-block: 15px; }
.email-access form { display: grid; gap: 12px; }
.email-access .toolbar { margin-top: 4px; }
.email-access .toolbar .button { flex: 1 1 130px; }
.email-access label { font-size: .88rem; font-weight: 750; }
.email-access input { margin-top: 5px; }

.workspace { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar {
  align-self: start;
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 24px 16px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.brand { padding: 0 8px; line-height: 1.1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: .74rem; font-weight: 650; letter-spacing: normal; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav button, .sign-out, .account {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.sidebar nav button, .sign-out { display: flex; align-items: center; gap: 11px; text-align: left; min-height: 44px; padding: 9px 12px; }
.sidebar nav button:hover, .sign-out:hover, .account:hover { background: var(--canvas); color: var(--ink); }
.sidebar nav button[aria-current="page"] { background: var(--soft); color: var(--badge-ink); }
.nav-separator { margin-top: 15px; }
.sign-out { margin-top: auto; }
.page { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 7px var(--edge);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  font-weight: 800;
}
.account { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 10px; color: var(--ink); font-size: .86rem; }
#account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%; background: var(--soft); color: var(--badge-ink); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
main { max-width: 1320px; margin: auto; padding: clamp(26px, 4vw, 48px) var(--edge); }
.page-heading { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.page-heading p { margin-top: 8px; color: var(--muted); }

.dashboard { display: grid; gap: 26px; }
.dashboard-date { margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; }
.dashboard-date::first-letter { text-transform: uppercase; }
.hero {
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: clamp(244px, 27vw, 340px);
  overflow: hidden;
  border-radius: 18px;
  padding: clamp(23px, 4vw, 51px);
  background: linear-gradient(90deg, #142c23 0%, #142c23ee 34%, #142c2390 65%, #142c2311 100%),
    #1c3a2e url("./assets/quartiere.webp") right 56% / cover no-repeat;
  color: #fff;
}
.hero-content { max-width: 490px; }
.hero h2 { max-width: 18ch; font-size: clamp(1.75rem, 3.6vw, 3.1rem); line-height: 1.08; letter-spacing: -.055em; }
.hero p { max-width: 41ch; margin-top: 12px; color: #e4eee2; }
.hero .button { margin-top: 20px; gap: 12px; color: #213a2c; background: #f4e9d7; border-color: transparent; }
.hero .button:hover { background: #fff6e7; }
.hero .button:focus-visible { outline-color: #ffbe89; }
.hero .button .symbol { font-size: 18px; }
.dashboard-section { display: grid; gap: 12px; min-width: 0; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dashboard-card, .dashboard-link {
  display: grid;
  align-items: center;
  gap: 3px 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}
.dashboard-card:hover, .dashboard-link:hover { border-color: var(--border); background: var(--input); }
.dashboard-card { grid-template-columns: minmax(0, 1fr) auto; padding: 14px; min-height: 124px; }
.dashboard-card strong, .dashboard-card .card-detail { grid-column: 1 / -1; }
.dashboard-card strong { margin-top: 6px; }
.card-icon { display: grid; place-items: center; width: 37px; height: 37px; color: var(--badge-ink); background: var(--soft); border-radius: 10px; }
.card-icon-feed { color: var(--clay); background: var(--warm); }
.card-icon-chat_bubble { color: var(--blue-ink); background: var(--blue); }
.card-detail { display: block; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.dashboard-card > .symbol, .dashboard-link > .symbol { color: var(--muted); font-size: 18px; }
.dashboard-link { grid-template-columns: auto minmax(0, 1fr) auto; padding: 12px 14px; min-height: 64px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card, .empty, .chat-layout { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: var(--shadow); }
.card, .empty { padding: clamp(15px, 2.5vw, 24px); }
.card p, .empty p { color: var(--muted); margin-top: 7px; }
.card .button { margin-top: 10px; }
.card .toolbar .button, .card .section-header .button { margin-top: 0; }
.section-header, .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.section-header { justify-content: space-between; gap: 11px; margin-bottom: 14px; }
.stack, .rows { display: grid; gap: 12px; }
.stack > .button { justify-self: start; }
.item { border-top: 1px solid var(--line); padding-top: 12px; }
.item:last-child { padding-bottom: 3px; }
.item .description { white-space: pre-wrap; }
.item .toolbar { margin-top: 8px; }
.item-title { display: flex; align-items: start; flex-wrap: wrap; justify-content: space-between; gap: 7px; }
.meta { font-size: .84rem; color: var(--muted); }
.pill { padding: 4px 10px; border-radius: 20px; background: var(--soft); color: var(--badge-ink); font-size: .78rem; font-weight: 800; }
.pill.alert { background: var(--warm); color: var(--clay); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  max-width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
}
.button:hover { background: var(--canvas); }
.button.primary { color: var(--on-pine); background: var(--pine); border-color: var(--pine); }
.button.primary:not(:disabled):hover { filter: brightness(.90); }
.button.small { min-height: 38px; padding: 6px 11px; font-size: .86rem; }
select, input, textarea { min-width: 0; width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
.selector { min-width: min(100%, 230px); display: grid; gap: 4px; color: var(--muted); font-size: .86rem; font-weight: 750; }
.lower { margin-top: 18px; }
.location { margin-bottom: 16px; color: var(--muted); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.inline-form label { flex: 1 1 190px; }
.inline-form input { display: block; margin-top: 4px; }
label.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 600; }
.check input { width: auto; margin-top: 5px; accent-color: var(--pine); }
.zone-map, .form-map { position: relative; isolation: isolate; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--ink); overflow: hidden; }
.zone-map { height: clamp(320px, 67vh, 680px); }
.form-map { height: 205px; }
.map-tools { margin-bottom: 14px; }
.invite-qr { background: #fff; padding: 12px; width: max-content; max-width: 100%; border-radius: 10px; }
.invite-code { font-size: 1.45rem; font-weight: 800; letter-spacing: .06em; }
.quiz-score { font-size: 2.45rem; font-weight: 800; color: var(--pine); }

.chat-layout { display: grid; grid-template-columns: minmax(170px, .40fr) minmax(0, 1fr); min-height: 470px; overflow: hidden; }
.thread-list { display: flex; flex-direction: column; gap: 5px; padding: 12px; border-right: 1px solid var(--line); min-width: 0; }
.thread-button { min-width: 0; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; }
.thread-button:hover, .thread-button[aria-pressed="true"] { background: var(--soft); }
.thread-button span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-button .meta { margin-top: 3px; }
.chat-pane { min-width: 0; display: grid; grid-template-rows: auto minmax(240px, 1fr) auto auto; background: var(--chat); }
.chat-title { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.messages { min-height: 240px; max-height: 500px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; align-items: flex-start; }
.message { max-width: min(87%, 570px); padding: 9px 12px; border-radius: 4px 13px 13px 13px; background: var(--paper); overflow-wrap: anywhere; white-space: pre-wrap; }
.message.mine { align-self: flex-end; border-radius: 13px 4px 13px 13px; background: var(--own-bubble); }
.message .meta { font-size: .74rem; font-weight: 700; }
.message .button { min-height: 30px; padding: 3px 7px; font-size: .76rem; }
.message .toolbar { gap: 4px; margin-top: 6px; }
.message blockquote { margin: 4px 0 6px; padding: 4px 8px; border-left: 3px solid var(--border); color: var(--muted); }
.reply-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 12px; border-top: 1px solid var(--line); background: var(--soft); }
.chat-form { display: flex; align-items: end; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--paper); }
.chat-form textarea { min-height: 42px; max-height: 120px; }
.chat-form .button { min-width: 70px; }

dialog {
  width: min(520px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(16px, 4vw, 24px);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 24px 90px #0e291e50;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: #13291e91; }
dialog form, dialog label { display: grid; gap: 12px; }
dialog label { gap: 5px; font-size: .9rem; font-weight: 750; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.error { color: var(--clay); }
.toast { position: fixed; z-index: 5; inset: auto 16px 16px auto; padding: 12px 16px; max-width: calc(100% - 32px); border-radius: 10px; background: #183a2c; color: #fff; box-shadow: 0 8px 35px #061d1940; }

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 11px var(--edge) 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0; }
  .brand img { width: 36px; height: 36px; }
  .brand small { display: none; }
  .sidebar nav { grid-area: 2 / 1 / 3 / -1; display: flex; flex-wrap: wrap; gap: 3px; }
  .sidebar nav button, .sign-out { min-height: 39px; gap: 5px; padding: 6px 8px; font-size: .82rem; }
  .sidebar nav button .symbol, .sign-out .symbol { font-size: 18px; }
  .nav-separator { margin: 0; }
  .sign-out { grid-area: 1 / 2; margin: 0; }
  .topbar { min-height: 52px; padding-block: 4px; }
  .hero { background-position: center, right 54%; }
}
@media (max-width: 680px) {
  .sign-in { grid-template-columns: 1fr; align-content: start; background: var(--paper); }
  .welcome { gap: clamp(38px, 9vw, 75px); padding: 23px var(--edge) 29px; }
  .welcome h1 { font-size: clamp(2.35rem, 9vw, 3.7rem); }
  .welcome p { margin-top: 11px; }
  .access { padding: 28px var(--edge); }
  .chat-layout { grid-template-columns: 1fr; }
  .thread-list { border: 0; border-bottom: 1px solid var(--line); max-height: 160px; overflow-y: auto; }
  .messages { max-height: 400px; }
}
@media (max-width: 520px) {
  :root { --edge: 16px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sidebar nav button { min-height: 47px; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 1px; font-size: .69rem; text-align: center; line-height: 1.18; }
  .sidebar nav button .symbol { font-size: 20px; }
  .topbar { min-height: 46px; font-size: .87rem; }
  .avatar { width: 30px; height: 30px; }
  .grid { grid-template-columns: 1fr; }
  .dashboard { gap: 19px; }
  .dashboard-card { min-height: 111px; padding: 11px; }
  .dashboard-grid { gap: 9px; }
  .hero { min-height: 238px; background-image: linear-gradient(90deg, #132c23f2, #132c23a0 69%, #132c2350), url("./assets/quartiere.webp"); }
  .hero h2 { font-size: 1.95rem; }
  .hero p { line-height: 1.45; }
}

.print-summary { display: none; }
@media print {
  :root { color-scheme: light !important; }
  .sidebar, .topbar, .button, .selector, dialog, .toast { display: none !important; }
  .workspace { display: block; }
  main, .card { padding: 0; border: 0; box-shadow: none; }
  .item { break-inside: avoid; }
  .printing-report main > :not(.print-summary) { display: none; }
  .printing-report .print-summary { display: block; color: #000; }
  .print-summary table { margin-top: 1rem; border-collapse: collapse; min-width: 280px; }
  .print-summary th, .print-summary td { padding: 8px 14px; border-bottom: 1px solid #bbb; text-align: left; }
}
