:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2a2e;
  --muted: #7a8689;
  --line: #e7e3da;
  --accent: #2f7d6d;
  --accent-soft: #e3f1ed;
  --accent-ink: #ffffff;
  --danger: #c4452f;
  --warn-soft: #fbece7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 42, 46, .06), 0 4px 14px rgba(31, 42, 46, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715;
    --card: #1b2321;
    --ink: #e8eeec;
    --muted: #8d9a97;
    --line: #2a3431;
    --accent: #5fc2ab;
    --accent-soft: #1f3a34;
    --accent-ink: #0d1f1b;
    --danger: #ef7b66;
    --warn-soft: #3a2420;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

#app {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(110px + env(safe-area-inset-bottom));
}

/* navegação inferior */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
#nav button {
  flex: 1; max-width: 160px; border: 0; background: none; border-radius: 12px;
  padding: 6px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#nav button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
#nav button.on { color: var(--accent); background: var(--accent-soft); }
#nav button.on span { filter: none; opacity: 1; }

h1 { font-size: 26px; margin: 0 0 2px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* tira da semana */
.weekbar { display: flex; align-items: center; gap: 4px; margin: 12px -4px 14px; }
.weekbar .arrow { border: 0; background: none; font-size: 22px; color: var(--muted); padding: 6px 6px; border-radius: 10px; }
.days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day {
  border: 1px solid transparent; background: none; border-radius: 14px; padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
}
.day small { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.day b { font-size: 17px; }
.day i { font-style: normal; font-size: 10px; color: var(--muted); height: 12px; }
.day.today b { color: var(--accent); }
.day.sel { background: var(--accent); }
.day.sel small, .day.sel b, .day.sel i { color: var(--accent-ink); }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.add { color: var(--accent); border-style: dashed; background: none; }

/* progresso */
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.progress div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }

/* cartões e tarefas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.pad { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 4px; }
.card-head strong { font-size: 17px; }
.card-head .count { color: var(--muted); font-size: 13px; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 22px 2px 8px; font-weight: 700; font-size: 15px; }
.sec-title.warn { color: var(--danger); }
.room .card-head { padding: 4px 0; }
.room-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left;
  border: 0; background: none; padding: 10px 0; font-size: 17px;
}
.room-toggle .count { margin-left: 4px; }
.chev { display: inline-block; width: 14px; font-size: 24px; line-height: 1; color: var(--muted); transition: transform .15s; }
.room.open .chev { transform: rotate(90deg); }
.room.open .card-head { border-bottom: 1px solid var(--line); }
#totop {
  position: fixed; left: 18px; bottom: calc(86px + env(safe-area-inset-bottom));
  width: 46px; height: 46px; border-radius: 16px; font-size: 22px; line-height: 1;
  background: var(--card); color: var(--accent); border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.15); z-index: 15;
}
.pick {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 0; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: none;
}
.pick.on .check { background: var(--accent); border-color: var(--accent); }
.pick.on .check svg { opacity: 1; }
.copybtn { flex: none; font-size: 18px; padding: 4px 2px; opacity: .75; }
.room-label { font-size: 13px; font-weight: 700; color: var(--muted); padding: 10px 0 0; }

.task { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted);
  background: none; display: grid; place-items: center; padding: 0; transition: all .12s;
}
.check svg { width: 16px; height: 16px; stroke: var(--accent-ink); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check svg { opacity: 1; }
.task .body { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; }
.task .title { display: block; word-break: break-word; }
.task.done .title { text-decoration: line-through; opacity: .45; }
.task.done .pills { opacity: .45; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.pill.muted { background: var(--line); color: var(--muted); }
.pill.warn { background: var(--warn-soft); color: var(--danger); }

.quickadd { display: flex; gap: 8px; padding: 10px 0 12px; }
.quickadd input { flex: 1; min-width: 0; }
input[type=text], input[type=password], input[type=date], input[type=time], select {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--warn-soft); color: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.iconbtn { border: 0; background: none; font-size: 20px; color: var(--muted); padding: 4px 8px; border-radius: 10px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty b { display: block; font-size: 38px; margin-bottom: 6px; }

.fab {
  position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 20px; border: 0; font-size: 30px; line-height: 1;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0,0,0,.22); z-index: 15;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.field { margin: 12px 0; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.seg { display: grid; grid-auto-flow: column; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 4px; font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 8px; }
.wd button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 0; font-size: 13px; font-weight: 700; }
.wd button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* modal */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card);
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .btn { flex: 1; }
@media (min-width: 700px) { #modal { align-items: center; } .sheet { border-radius: 22px; } }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; max-width: 90vw;
}

/* login */
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box .logo { font-size: 54px; }
.login-box input { margin: 18px 0 12px; text-align: center; }
.login-box .btn { width: 100%; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }
