@font-face {
  font-family: "Inter";
  src: url("Inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f6f5f2;
  --col: #efeee9;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #8b8a85;
  --line: #e2e0da;
  --chip: #e8e6e0;
  --accent: #1c1c1c;
  --on-accent: #ffffff;
  --now: #ff5a36;
  --danger: #d93a2b;
  --shadow: 0 1px 2px rgba(20, 20, 10, .06), 0 1px 1px rgba(20, 20, 10, .04);
  --radius: 14px;
  --surface: #fbfaf7;
  --side: #efede7;
  --hover: rgba(30, 25, 10, .045);
  --q1: #e5484d;
  --q2: #d99a00;
  --q3: #2f74d0;
  --q4: #12a594;
  --axis: #9db4f5;
  --q0: #8fa3c4;
  --hour: 48px;
  --quad-shadow: 0 10px 30px rgba(30, 40, 80, .07), 0 1px 2px rgba(30, 40, 80, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --col: #1c1c1c;
    --card: #262626;
    --text: #ededea;
    --muted: #8a8984;
    --line: #2f2f2f;
    --chip: #1f1f1f;
    --tab-on: #333333;
    --accent: #ededea;
    --on-accent: #141414;
    --shadow: none;
    --surface: #212121;
    --side: #1a1a1a;
    --hover: rgba(255, 255, 255, .04);
    --q1: #ff6369;
    --q2: #ffc53d;
    --q3: #5aa2f0;
    --q4: #0bd8b6;
    --axis: #3a4a7a;
    --q0: #7d8aa3;
    --quad-shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

[hidden] { display: none !important; }

/* Navegação: lateral no PC, inferior no celular */
.app { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.side {
  flex: 0 0 76px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(14px + env(safe-area-inset-top)) 8px 14px;
  border-right: 1px solid var(--line);
  background: var(--side);
}
.side-logo { align-self: center; margin: 2px 0 14px; border-radius: 7px; }
.side button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.side button:hover { color: var(--text); }
.side button.on { background: var(--chip); color: var(--text); }
.side svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.side button.on svg { fill: currentColor; fill-opacity: .12; }

/* Topo */
.top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -.01em; }
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--chip);
  border-radius: 11px;
}
.tabs button {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}
.tabs button.on { background: var(--tab-on, var(--card)); color: var(--text); box-shadow: var(--shadow); }
.week-title { display: flex; align-items: baseline; gap: 10px; }
.week-title.pick { cursor: pointer; border-radius: 9px; padding: 4px 8px; margin: -4px -8px; }
.week-title.pick:hover { background: var(--chip); }
.week-title.pick strong::after { content: " ▾"; color: var(--muted); font-size: 12px; }
.sr { position: absolute; left: 50%; top: 100%; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.week-title strong { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.week-title span { color: var(--muted); font-size: 13px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.ghost {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  font-weight: 500;
  font-size: 14px;
}
.ghost:hover { background: var(--chip); }
#prev, #next { font-size: 20px; line-height: 1; }
.status { width: 8px; height: 8px; border-radius: 50%; }
.side .status { align-self: center; margin-top: auto; }
.status.off { background: var(--now); }

/* Horizontes: uma coluna por horizonte, recolhível, wallpaper à direita */
.strip {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.strip.drag { scroll-snap-type: none !important; }
.hz {
  --w: 320px;
  position: relative;
  flex: 0 0 auto;
  width: var(--w);
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: width .38s cubic-bezier(.2, .8, .2, 1);
}
.hz-day { --w: 560px; }
.hz.collapsed { width: 52px; }
.hz-inner {
  width: var(--w); /* largura fixa: ao abrir, o conteúdo é revelado para a direita */
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(26px + env(safe-area-inset-top)) 12px 12px;
  transition: opacity .25s ease .08s;
}
.hz.collapsed .hz-inner { opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.hz-rail {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  opacity: 0;
  pointer-events: none;
  color: var(--muted);
  transition: opacity .15s ease;
}
.hz-rail span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.hz.collapsed .hz-rail { opacity: 1; pointer-events: auto; transition: opacity .2s ease .18s; }
.hz-rail:hover { color: var(--text); background: var(--hover); }

.hz-head { position: relative; display: flex; align-items: baseline; gap: 12px; padding: 0 10px 18px; min-height: 58px; }
.hz-title {
  padding: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  white-space: nowrap;
  text-align: left;
}
.hz-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 16px; font-weight: 500; white-space: nowrap; }
.hz-tools {
  position: absolute;
  top: 2px;
  right: 0;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s ease;
}
.hz:hover .hz-tools, .hz-tools:focus-within { opacity: 1; }
.hz-tool { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.hz-tool:hover { background: var(--hover); color: var(--text); }
.hz-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* itens no estilo da referência: linhas sem cartão, tingidas pela prioridade */
.hz .item { gap: 12px; padding: 9px 10px; margin: 0 0 3px; background: none; box-shadow: none; border-radius: 10px; }
.hz .item:hover { background: var(--hover); }
.hz .item[data-q] { background: color-mix(in srgb, var(--q) 20%, var(--surface)); }
.hz .item[data-q]:hover { background: color-mix(in srgb, var(--q) 26%, var(--surface)); }
.hz .item[data-q] > .body > .title { color: color-mix(in srgb, var(--q) 62%, var(--text)); }
.hz .item[data-q] > .check { border-color: color-mix(in srgb, var(--q) 62%, var(--text)); }
.hz .item[data-q].done > .check { background: var(--q); border-color: var(--q); }
.hz .item > .check { flex-basis: 20px; width: 20px; height: 20px; margin-top: 1px; }
.hz .item .title { font-size: 16px; font-weight: 500; letter-spacing: -.005em; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.subs-toggle { display: inline-flex; align-items: center; gap: 4px; padding: 0; color: inherit; font-size: inherit; }
.subs-toggle::after { content: ""; width: 5px; height: 5px; margin: -3px 0 0 2px; border: solid currentColor; border-width: 0 1.4px 1.4px 0; transform: rotate(45deg); transition: transform .2s; }
.subs-toggle.open::after { margin-top: 3px; transform: rotate(-135deg); }
.subs-toggle:hover { color: var(--text); }
.inline-subs { list-style: none; margin: 8px 0 2px; padding: 0; }
.sub-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14.5px; }
.sub-row > .check { flex-basis: 16px; width: 16px; height: 16px; border-radius: 4px; }
.sub-row.done > .check { background: var(--accent); border-color: var(--accent); }
.sub-row.done > .check::after { content: ""; width: 4px; height: 7px; border: solid var(--on-accent); border-width: 0 1.5px 1.5px 0; transform: translateY(-1px) rotate(45deg); }
.sub-row.done .title { color: var(--muted); text-decoration: line-through; }
.hz .add-li { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.ghost-check { flex: 0 0 20px; height: 20px; border-radius: 5px; background: var(--hover); }
.hz .add { padding: 9px 0; font-size: 16px; }
.hz .add:focus { background: none; box-shadow: none; }

/* wallpaper: textura granulada em CSS, ou imagem enviada pelo usuário */
.wall {
  position: relative;
  flex: 1 0 0;
  min-width: 0;
}
.wall, .login {
  background-color: #e8e5de;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"),
    radial-gradient(120% 70% at 80% 10%, rgba(255, 255, 255, .7), transparent 60%),
    radial-gradient(90% 60% at 10% 90%, rgba(150, 140, 120, .25), transparent 70%);
  background-size: 260px, cover, cover;
  background-position: center;
}
@media (prefers-color-scheme: dark) {
  .wall, .login {
    background-color: #070707;
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 4.2 0 0 0 -2.75'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E"),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .13 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1400' height='1400'%3E%3Cfilter id='d' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0014 .0085' numOctaves='5' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .55 0 0 0 -.24'/%3E%3C/filter%3E%3Cg transform='rotate(-28 700 700)'%3E%3Crect x='-500' y='-500' width='2400' height='2400' filter='url(%23d)'/%3E%3C/g%3E%3C/svg%3E"),
      radial-gradient(120% 70% at 80% 0%, rgba(255, 255, 255, .06), transparent 65%),
      linear-gradient(170deg, #151515, #050505);
    background-size: 320px, 240px, max(1400px, 100vw) auto, cover, cover;
    background-position: 0 0, 0 0, 30% 40%, center, center;
  }
}
.wall.custom { background-size: cover; background-repeat: no-repeat; }
.wall-tools { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; }
.wall:hover .wall-tools, .wall-tools:focus-within { opacity: 1; }
.wall-tools button {
  padding: 7px 12px;
  border-radius: 9px;
  background: rgba(20, 20, 20, .55);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.wall-tools button:hover { background: rgba(20, 20, 20, .75); }
.wall:not(.custom) .wall-tools button + button { display: none; }

/* Login: cartão de vidro sobre a textura */
.login { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, 100%);
  padding: 32px 28px 28px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--card) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.login-card img { border-radius: 11px; margin-bottom: 6px; }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.025em; }
.login-sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  font-size: 15px;
  outline: none;
}
.login-card input:focus { border-color: var(--muted); }
.login-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }
.login-card button { padding: 12px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 15px; }
.login-card button:disabled { opacity: .6; }
.login-card .login-link { align-self: center; padding: 4px; background: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.login-card .login-link:hover { color: var(--text); }

/* Avatar (abre Conta) */
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 650;
  flex: 0 0 auto;
}
.side .side-avatar { display: grid; place-items: center; align-self: center; width: 34px; height: 34px; padding: 0; margin-top: 12px; border-radius: 50%; color: var(--on-accent); font-size: 14px; font-weight: 650; }
.side .side-avatar:hover { color: var(--on-accent); opacity: .85; }
.avatar.big { width: 44px; height: 44px; font-size: 18px; }
.avatar.small { width: 24px; height: 24px; font-size: 11px; }
.top-avatar { display: none; }

/* Conta: cartão sobre fundo escurecido; no celular, folha de baixo */
.sheet { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .32); }
.sheet-card {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 24px 20px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-card .muted { color: var(--muted); font-size: 13px; }
.sheet-card section { display: flex; flex-direction: column; gap: 10px; }
.sheet-card h3 { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sheet-card .note { margin: 0; font-size: 14px; line-height: 1.45; }
.sheet-card .msg { margin: 0; min-height: 0; color: var(--muted); font-size: 13px; }
.sheet-card .msg:empty { display: none; }
.sheet-card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-card .stack { display: flex; flex-direction: column; gap: 8px; }
.sheet-card input:not([type=checkbox]) {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
  outline: none;
}
.sheet-card input:focus { border-color: var(--muted); }
.btn { padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.quiet { background: var(--chip); color: var(--text); }
.stack .btn { align-self: flex-start; }
.switch { cursor: pointer; font-size: 15px; }
.switch input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.switch span { flex: 1; }
.switch input[type=time] { padding: 6px 8px; }
.switch input:disabled { opacity: .45; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.people .person { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.people .tag { padding: 1px 7px; border-radius: 6px; background: var(--chip); color: var(--muted); font-size: 11px; font-weight: 600; }
.link { padding: 4px 2px; color: var(--muted); font-size: 13px; }
.link:hover { color: var(--text); }
.danger-link:hover { color: var(--danger); }
.sheet-card > .danger { align-self: flex-start; padding: 0; }

/* lembrete no painel da tarefa e sino na lista */
.when select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  font-size: 14px;
}
.hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.meta .bell, .rep { display: inline-grid; place-items: center; }
.item > .rep { color: var(--muted); }
.ev-title .rep { display: inline-grid; margin-right: 4px; vertical-align: -1px; }
.ev-title .rep svg, .chip .rep svg { width: 11px; height: 11px; }
.chip .rep { flex: 0 0 auto; color: var(--muted); }

/* repetição: dias da semana no painel e diálogo "só esta ou todas" */
.days { display: flex; gap: 6px; margin-top: 8px; }
.days button { width: 32px; height: 32px; border-radius: 16px; color: var(--muted); font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--line); }
.days button.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.scope-card { width: min(340px, 100%); gap: 14px; }
.scope-card h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.scope-card .stack .btn { align-self: stretch; }
.scope-card .link { align-self: center; }
.meta .bell svg, .rep svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* sem cabeçalho no topo na aba Horizontes do PC: colunas começam no topo */
body[data-view="horizons"] .nav .ghost { display: none; }
@media (min-width: 641px) {
  body[data-view="horizons"] .top { display: none; }
  .top .brand { display: none; }
}

.col-head { padding: 0 6px 10px; }
.col-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.col-sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

/* Item */
.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.item .body { flex: 1; min-width: 0; }
.item .title { overflow-wrap: anywhere; }
.item .count { color: var(--muted); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.item.done .title { color: var(--muted); text-decoration: line-through; }
.item.ghost-drop { opacity: .35; }
.item.dragging { box-shadow: 0 8px 24px rgba(0, 0, 0, .14); transform: rotate(1deg); }

.check {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 5px;
  border: 1.5px solid var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
}
.check:hover { border-color: var(--text); }
.done > .check, .check.on { background: var(--accent); border-color: var(--accent); }
.done > .check::after, .check.on::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid var(--on-accent);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

.add {
  width: 100%;
  margin-top: 2px;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  outline: none;
}
.add::placeholder { color: var(--muted); }
.add:focus { background: var(--card); box-shadow: var(--shadow); }

/* Quadrantes */
.q1, [data-q="1"] { --q: var(--q1); }
.q2, [data-q="2"] { --q: var(--q2); }
.q3, [data-q="3"] { --q: var(--q3); }
.q4, [data-q="4"] { --q: var(--q4); }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: var(--q);
  color: #fff;
  font: 600 12px/1 Georgia, "Times New Roman", serif;
}
.item .qdot { flex: 0 0 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--q); }
.item .tag { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; }

/* Matriz de Eisenhower */
.matrix {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 24px;
  padding: 6px 20px 20px;
}
.tray {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 10px 10px;
  background: var(--col);
  border-radius: 18px;
}
.quads {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 36px;
  min-height: 0;
  padding: 4px;
}
/* eixos */
.quads::before, .quads::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  pointer-events: none;
}
.quads::before { left: calc(50% - 1px); top: 0; bottom: 0; width: 2px; background: linear-gradient(to top, transparent, var(--axis)); }
.quads::after { top: calc(50% - 1px); left: 0; right: 0; height: 2px; background: linear-gradient(to right, transparent, var(--axis)); }
.quad {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px 8px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--quad-shadow);
  border: 1px solid var(--line);
}
.quad-head { display: flex; align-items: center; gap: 8px; padding: 0 6px 8px; }
.quad-name { color: var(--q); font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.quad .item { background: none; box-shadow: none; padding: 7px 6px; margin: 0; border-radius: 10px; }
.quad .item:hover { background: var(--bg); }
.quad .item.dragging { background: var(--card); }
.matrix .item .check { border-radius: 6px; border-color: var(--q, var(--muted)); }
.matrix .item.done > .check { background: var(--q, var(--accent)); border-color: var(--q, var(--accent)); }
.matrix .item.done > .check::after { border-color: #fff; }
.quad .add { padding-left: 6px; }
.quad .add:focus { background: var(--bg); box-shadow: none; }

/* Calendário */
.cal {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 16px;
  padding: 6px 20px 20px;
  user-select: none;
  -webkit-user-select: none;
}
.cal.month-mode, .cal.no-tray { grid-template-columns: 1fr; }
.cal-body {
  display: flex;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.cal-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.cal-row { display: grid; grid-template-columns: 52px repeat(var(--n), minmax(0, 1fr)); }
.cal-sticky { position: sticky; top: 0; z-index: 4; background: var(--card); border-bottom: 1px solid var(--line); }
.cal-day-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 0 8px; }
.cal-day-head .wd { color: var(--muted); font-size: 12px; font-weight: 500; }
.cal-day-head .dn { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 15px; font-size: 18px; font-weight: 650; }
.cal-day-head.now .wd { color: var(--now); }
.cal-day-head.now .dn { background: var(--now); color: #fff; }
.cal-allday .gutter { color: var(--muted); font-size: 10px; text-align: right; padding: 8px 6px 0 0; }
.allday-cell { list-style: none; margin: 0; padding: 3px; min-height: 30px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.allday-cell.over { background: color-mix(in srgb, var(--q3) 12%, transparent); }
.cal-grid { height: calc(24 * var(--hour)); }
.hours { position: relative; }
.hours span { position: absolute; right: 8px; transform: translateY(-50%); color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cal-col {
  position: relative;
  border-left: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) - 1px), var(--line) calc(var(--hour) - 1px) var(--hour));
  cursor: cell;
}
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }

.ev {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--q, var(--q0)) 24%, var(--card));
  font-size: 13px;
  line-height: 1.3;
  cursor: grab;
  -webkit-touch-callout: none;
}
.ev:hover { background: color-mix(in srgb, var(--q, var(--q0)) 32%, var(--card)); }
.ev-title { font-weight: 550; overflow-wrap: anywhere; }
.ev-time { color: color-mix(in srgb, var(--text) 55%, transparent); font-size: 12px; font-variant-numeric: tabular-nums; }
.ev.short { display: flex; gap: 6px; align-items: baseline; padding-top: 2px; padding-bottom: 0; }
.ev.short .ev-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.done { opacity: .55; }
.ev.done .ev-title { text-decoration: line-through; }
.ev .h-top, .ev .h-bot { position: absolute; left: 0; right: 0; height: 8px; cursor: ns-resize; touch-action: none; }
.ev .h-top { top: 0; }
.ev .h-bot { bottom: 0; }
.ev.dragging { z-index: 6; pointer-events: none; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); opacity: .95; }
.cal.is-dragging, .cal.is-dragging * { cursor: grabbing !important; }
.lifted { opacity: .4; }

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--q, var(--q0)) 16%, var(--card));
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  -webkit-touch-callout: none;
}
.chip .dot { flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--q, var(--q0)); }
.chip .chip-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .chip-title { overflow: hidden; text-overflow: ellipsis; }
.chip.done .chip-title { color: var(--muted); text-decoration: line-through; }

.month { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.m-names { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.m-names span { padding: 10px 10px 8px; color: var(--muted); font-size: 12px; font-weight: 500; }
.m-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-cell { display: flex; flex-direction: column; gap: 2px; min-height: 0; min-width: 0; padding: 4px 4px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell.other > * { opacity: .4; }
.m-num { align-self: flex-start; min-width: 26px; height: 26px; border-radius: 13px; font-size: 13px; font-weight: 600; }
.m-num:hover { background: var(--chip); }
.m-cell.now .m-num { background: var(--now); color: #fff; }
.m-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 20px; display: flex; flex-direction: column; gap: 2px; }
.m-list .more { color: var(--muted); font-size: 12px; padding: 0 6px; cursor: pointer; }

/* Quando, no painel */
.when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.when input {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.when input:disabled { opacity: .45; }
.when .muted { color: var(--muted); font-size: 13px; }
#p-allday { color: var(--muted); font-size: 13px; padding: 6px 8px; border-radius: 8px; }
#p-allday.on { background: var(--chip); color: var(--text); }

/* Prioridade no painel */
.prio { display: flex; align-items: center; gap: 8px; }
.prio .badge { --q: var(--muted); opacity: .9; height: 28px; min-width: 34px; border-radius: 14px; background: none; color: var(--q); box-shadow: inset 0 0 0 1.5px var(--q); }
.prio .badge[data-q="1"] { --q: var(--q1); }
.prio .badge[data-q="2"] { --q: var(--q2); }
.prio .badge[data-q="3"] { --q: var(--q3); }
.prio .badge[data-q="4"] { --q: var(--q4); }
.prio .badge.on { background: var(--q); color: #fff; opacity: 1; }
.prio .none { color: var(--muted); font-size: 13px; padding: 4px 8px; border-radius: 8px; }
.prio .none.on { background: var(--chip); color: var(--text); }
#p-prio-name { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 4px; }

/* Painel de detalhes */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 10;
}
.backdrop.open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed;
  z-index: 11;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(18px + env(safe-area-inset-top)) 22px calc(18px + env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .12);
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-period { color: var(--muted); font-size: 13px; font-weight: 500; }
.panel-title { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 10px; }
.panel-title .check { margin-top: 6px; flex-basis: 20px; width: 20px; height: 20px; }
#p-title {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.25;
  field-sizing: content;
}
.label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 10px; }
.subs { list-style: none; margin: 0; padding: 0; }
.subs li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.subs .check { margin-top: 0; }
.subs input { flex: 1; border: 0; outline: none; background: none; padding: 2px 0; }
.subs li.done input { color: var(--muted); text-decoration: line-through; }
.subs .x { color: var(--muted); opacity: 0; padding: 0 4px; }
.subs li:hover .x, .subs li:focus-within .x { opacity: 1; }
.panel .add { padding-left: 0; }
.panel .add:focus { background: none; box-shadow: none; }
.notes {
  flex: 1;
  min-height: 160px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  outline: none;
  resize: none;
  line-height: 1.5;
}
.danger { align-self: flex-start; color: var(--danger); font-size: 14px; padding: 8px 0; }

/* Celular: uma coluna por tela, painel vira bottom sheet */
@media (max-width: 640px) {
  body { flex-direction: column; }
  .side {
    order: 2;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .side button { flex: 1; max-width: 120px; padding: 6px 0; }
  .side button.on { background: none; }
  .matrix { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: 6px 16px 16px; }
  .tray, .quad { flex: 0 0 auto; }
  .tray .list { min-height: 44px; }
  .quads { display: flex; flex-direction: column; gap: 12px; padding: 0; }
  .quads::before, .quads::after { display: none; }
  .quad .list { min-height: 36px; }
  .week-title { order: 3; width: 100%; }
  .week-title.pick { width: auto; margin: -4px 0; }
  .cal { display: flex; flex-direction: column; gap: 10px; padding: 6px 12px 12px; }
  .cal-tray { flex: 0 0 auto; padding: 8px; }
  .cal-tray .col-head { padding-bottom: 6px; }
  .cal-tray .col-sub { display: none; }
  .cal-tray .list { display: flex; gap: 6px; overflow-x: auto; }
  .cal-tray .item { flex: 0 0 auto; max-width: 70vw; margin: 0; }
  .cal-body, .month { flex: 1; }
  .cal-row { grid-template-columns: 40px repeat(var(--n), minmax(0, 1fr)); }
  .cal-allday .gutter { font-size: 9px; padding-right: 3px; }
  .ev { padding: 4px 5px; font-size: 12px; }
  .ev .h-top, .ev .h-bot { height: 12px; }
  .m-names span { padding: 8px 4px; text-align: center; }
  .m-cell { align-items: center; padding: 3px 2px; }
  .m-num { align-self: center; }
  .m-list { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .m-list .chip { padding: 0; background: none; }
  .m-list .chip .dot { flex-basis: 7px; height: 7px; }
  .m-list .chip-time, .m-list .chip-title, .m-list .more { display: none; }
  .top { flex-wrap: wrap; gap: 10px; padding-left: 16px; padding-right: 16px; }
  .tabs { order: 3; width: 100%; }
  .tabs button { flex: 1; padding: 7px 0; }
  .strip { scroll-snap-type: x mandatory; }
  .hz, .hz.collapsed { width: 100%; flex: 0 0 100%; scroll-snap-align: start; border-right: 0; }
  .hz-inner, .hz.collapsed .hz-inner { width: 100%; opacity: 1; pointer-events: auto; padding-top: 14px; }
  .hz-rail, .wall { display: none; }
  .hz-tools { opacity: 1; }
  .hz-tool.fold { display: none; }
  .hz-head { padding-right: 64px; min-height: 0; }
  .hz-title { font-size: 28px; }
  .tabs button { font-size: 13px; }
  .side-logo, .side .side-avatar { display: none; }
  .top-avatar { display: grid; order: 2; width: 32px; height: 32px; margin-left: auto; }
  .sheet { place-items: end stretch; padding: 0; }
  .sheet-card { width: 100%; max-height: 90dvh; border-radius: 22px 22px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .side { position: relative; }
  .side .status { position: absolute; top: 8px; right: 12px; margin: 0; }
  .panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: 88dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
  }
  .subs .x { opacity: 1; }
}
