/* ============ Temas ============ */
/* Inspirados no calendário de parede coreano: papel branco, faixa lilás no mês atual,
   número do mês em índigo, domingos em vermelho e sábados em azul.
   "Automático" (sem data-theme) segue o modo claro/escuro do celular. */

:root, :root[data-theme="papel"] {
  --bg: #efeee9;
  --surface: #ffffff;
  --surface-2: #e9e8e3;
  --text: #26262b;
  --text-2: #6b6b73;
  --text-3: #9e9ea6;
  --line: rgba(20, 20, 40, 0.08);
  --line-2: rgba(20, 20, 40, 0.16);
  --accent: #3a3fb0;
  --accent-soft: #e6e8f5;
  --on-accent: #ffffff;
  --danger: #d7263d;
  --danger-soft: #fbe6e8;
  --warn: #b7791f;
  --warn-soft: #fcf1dc;
  --ok: #2f9e6a;
  --sun: #d7263d;
  --sat: #2c56c6;
  --band: #e6e8f5;
  --bind: #3b3b40;
  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: light;
}

:root[data-theme="hanji"] {
  --bg: #e9dfcd;
  --surface: #f8f2e6;
  --surface-2: #e8dcc6;
  --text: #3a2f25;
  --text-2: #7a6a58;
  --text-3: #a8977f;
  --line: rgba(70, 45, 20, 0.10);
  --line-2: rgba(70, 45, 20, 0.20);
  --accent: #8a4f22;
  --accent-soft: #efdfc4;
  --on-accent: #ffffff;
  --danger: #b8352a;
  --danger-soft: #f2d9cf;
  --warn: #a86a12;
  --warn-soft: #f1e0bd;
  --ok: #4f7a3a;
  --sun: #b8352a;
  --sat: #2e5c8a;
  --band: #ecdcc0;
  --bind: #5a4632;
  color-scheme: light;
}

:root[data-theme="noite"] {
  --bg: #131418;
  --surface: #1e1f25;
  --surface-2: #2a2b33;
  --text: #ecebe6;
  --text-2: #a9a8b2;
  --text-3: #74747e;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.18);
  --accent: #aeb1ff;
  --accent-soft: #2c2e4a;
  --on-accent: #15163a;
  --danger: #ff7a7a;
  --danger-soft: #3a1f22;
  --warn: #e9b44c;
  --warn-soft: #3a2e15;
  --ok: #5cc792;
  --sun: #ff7a7a;
  --sat: #8aabff;
  --band: #262838;
  --bind: #0b0c0f;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #131418;
    --surface: #1e1f25;
    --surface-2: #2a2b33;
    --text: #ecebe6;
    --text-2: #a9a8b2;
    --text-3: #74747e;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.18);
    --accent: #aeb1ff;
    --accent-soft: #2c2e4a;
    --on-accent: #15163a;
    --danger: #ff7a7a;
    --danger-soft: #3a1f22;
    --warn: #e9b44c;
    --warn-soft: #3a2e15;
    --ok: #5cc792;
    --sun: #ff7a7a;
    --sat: #8aabff;
    --band: #262838;
    --bind: #0b0c0f;
    color-scheme: dark;
  }
}

/* Faixa colorida tradicional (saekdong), como a do rodapé do calendário */
.saekdong {
  height: 6px;
  background: linear-gradient(90deg,
    #d7263d 0 16.66%, #f2b51d 16.66% 33.33%, #2e8b57 33.33% 50%,
    #2c56c6 50% 66.66%, #e889b0 66.66% 83.33%, #7a4fb0 83.33% 100%);
}

/* ============ Base ============ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  overscroll-behavior-y: contain; /* sem "puxar para atualizar" do navegador dentro do app */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ic {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-muted { color: var(--text-3); }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 16px calc(var(--tabs-h) + 96px + env(safe-area-inset-bottom));
  overflow-x: clip; /* a aba que sai de lado ao arrastar não cria rolagem para os lados */
}
/* pan-y: rolar para cima e para baixo continua com o navegador; para os lados, troca de aba */
#view { touch-action: pan-y; }

/* ============ Cabeçalho ============ */
.top {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: calc(20px + env(safe-area-inset-top)) 0 8px;
}
.eyebrow { margin: 0; font-size: 13px; color: var(--text-2); }
h1 { margin: 2px 0 0; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text-2);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }

/* ============ Resumo da semana ============ */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.stat { border-radius: var(--radius); padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); }
.stat b { display: block; font-size: 22px; font-weight: 650; }
.stat span { font-size: 12px; color: var(--text-2); }
.stat.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.stat.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.stat.danger span, .stat.warn span { color: inherit; }
.hint { font-size: 12px; color: var(--text-3); margin: 6px 2px 0; }
.hint.center { text-align: center; margin-top: 16px; }

/* ============ Listas de atividades ============ */
.section-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin: 22px 2px 6px;
}
.section-title .ic { width: 16px; height: 16px; }
.section-title.danger { color: var(--danger); }
.section-row { display: flex; justify-content: space-between; align-items: center; }
.section-row .section-title { margin-bottom: 6px; }
.link-btn { font-size: 13px; color: var(--accent); font-weight: 550; margin-top: 16px; padding: 4px 2px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; }
.muted-line { font-size: 13px; color: var(--text-3); margin: 0 2px; }

.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }

.check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.8px solid var(--line-2);
  display: grid; place-items: center; flex-shrink: 0;
  color: transparent; transition: background 0.15s, border-color 0.15s;
}
.check .ic { width: 14px; height: 14px; stroke-width: 3; }
.item.t-prova .check { border-color: var(--warn); }
.item.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }

.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-title { margin: 0; font-size: 15px; line-height: 1.3; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.item-title .ic { width: 16px; height: 16px; }
.item.done .item-title { text-decoration: line-through; color: var(--text-3); }
.item-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--text-2); }
.item-meta.late { color: var(--danger); }
.ic-prova { color: var(--warn); }
.ic-bell { color: var(--accent); }

.tag {
  font-size: 11.5px; padding: 3px 8px; border-radius: 8px; white-space: nowrap;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: color-mix(in srgb, var(--c) 75%, var(--text));
}

.more {
  width: 100%; padding: 14px 0 4px; font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.more .ic { width: 16px; height: 16px; }

.teaser {
  width: 100%; margin-top: 22px; padding: 14px;
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.teaser > span { flex: 1; min-width: 0; }
.teaser b { font-weight: 600; font-size: 14px; }
.teaser small { font-size: 12.5px; color: var(--text-2); }
.teaser > .ic:first-child { color: var(--accent); }

/* ============ Estado vazio ============ */
.empty { text-align: center; padding: 48px 12px; color: var(--text-2); }
.empty > .ic { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.5; }
.empty h2 { color: var(--text); font-size: 19px; margin: 12px 0 6px; }
.empty p { margin: 0 0 20px; font-size: 14px; line-height: 1.5; }
.empty .btn { margin: 0 auto 8px; display: flex; }

/* ============ Botões ============ */
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line-2); font-weight: 550; font-size: 14.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn .ic { width: 18px; height: 18px; }
a.btn { text-decoration: none; color: inherit; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13.5px; }

.fab {
  position: fixed; z-index: 5;
  bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  right: max(16px, calc(50% - 240px + 16px));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(60, 50, 200, 0.3);
}
.fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.fab:active { transform: scale(0.96); }

/* ============ Barra de abas ============ */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 6;
  width: 100%; max-width: 480px;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; color: var(--text-3);
}
.tab .ic { width: 22px; height: 22px; }
.tab.active { color: var(--accent); font-weight: 600; }

.tab-icon { position: relative; display: grid; }
.badge {
  position: absolute; top: -5px; right: -9px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* ============ Avisos ============ */
.notice-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.notice-actions .link-btn { margin-top: 0; }
.syncing [data-action="sync"] .ic { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-error {
  display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; padding: 10px 12px;
  border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 13px; line-height: 1.4;
}
.sync-error .ic { width: 16px; height: 16px; margin-top: 1px; }
.text-danger { color: var(--danger); }

.notice { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex-shrink: 0; }
.notice.read .unread-dot { background: transparent; }
.notice-body { flex: 1; min-width: 0; cursor: pointer; }
.notice-line {
  margin: 0; font-size: 15px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notice-line.full { display: block; }
.notice:not(.read) .notice-line { font-weight: 550; }
.notice.read .notice-line { color: var(--text-2); }
.notice-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.notice-meta .tag { max-width: 200px; }
.notice-more { margin-top: 10px; display: grid; gap: 6px; justify-items: start; }
.notice-text { margin: 0; font-size: 14px; line-height: 1.45; color: var(--text); }
.notice-more .btn { margin-top: 4px; }
.suggest {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 550; color: var(--accent);
  padding: 6px 10px; border-radius: 9px; background: var(--accent-soft);
}
.suggest .ic { width: 15px; height: 15px; }
.suggest.done { background: none; padding: 0; color: var(--ok); font-weight: 500; }
.notice-teaser { margin-top: 14px; }
.one-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.canvas-box { padding: 14px 12px 2px; }
.cloud-box { padding: 12px 12px 0; }
.cloud-status { margin: 0 0 6px; font-size: 14px; font-weight: 550; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cloud-status .ic { width: 16px; height: 16px; }
.cloud-status .ok { color: var(--ok); display: inline-flex; align-items: center; gap: 6px; }
.version-row { width: 100%; text-align: left; }
.version-row .item-title, .version-row .item-meta { display: block; }
.key-row { display: flex; align-items: center; gap: 8px; }
.key {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg);
  font: 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; user-select: all;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.paste-key { margin-top: 12px; }
.paste-key summary { font-size: 13px; color: var(--accent); font-weight: 550; cursor: pointer; padding: 4px 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ Listas (Sem prazo) ============ */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 4px 6px; font-size: 14px; font-weight: 600;
}
.list-head small { font-weight: 500; color: var(--text-3); margin-left: 4px; }
.list-head .icon-btn { color: var(--text-3); }

/* ============ Matérias ============ */
.subject-list { display: grid; gap: 10px; margin-top: 14px; }
.subject-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.subject-main { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left; }
.subject-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex-shrink: 0; }
.subject-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.subject-text b { font-size: 15.5px; font-weight: 600; }
.subject-text small { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-2); }
.subject-text small .ic { width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }
.join-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--line); font-size: 13.5px; font-weight: 550;
  color: var(--accent); text-decoration: none;
}
.join-btn .ic { width: 18px; height: 18px; }

.slot-time { display: grid; text-align: right; min-width: 44px; font-variant-numeric: tabular-nums; }
.slot-time b { font-size: 14px; font-weight: 600; }
.slot-time small { font-size: 12px; color: var(--text-3); }
.item.slot.past { opacity: 0.55; }
.muted-line.pad { padding: 14px 0; margin: 0; }

.subject-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.subject-sheet-head h2 { margin: 0; }
.subject-sheet-head .subject-dot { width: 14px; height: 14px; }

.canvas-hint {
  margin-top: 10px; padding: 12px; border-radius: 12px;
  background: var(--accent-soft); font-size: 14px;
}
.canvas-hint .label { color: var(--accent); margin-bottom: 6px; }
.suggest-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.suggest-row .suggest { margin-top: 0; background: var(--surface); }

details.canvas-text, details.add-box { margin-top: 10px; }
details summary {
  cursor: pointer; font-size: 13.5px; font-weight: 550; color: var(--accent);
  padding: 6px 2px; display: flex; align-items: center; gap: 6px; list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary .ic { width: 16px; height: 16px; }
details.canvas-text p { margin: 4px 2px; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.add-form { display: grid; gap: 8px; padding: 8px 0 4px; }

/* Seletor de telas (Matérias / Monitorias / Médias) */
.segmented {
  display: flex; gap: 4px; padding: 4px; border-radius: 12px;
  background: var(--surface-2);
}
.segmented button {
  flex: 1; height: 36px; border-radius: 9px; font-size: 14px; font-weight: 550; color: var(--text-2);
  white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.segmented.top { margin: 10px 0 4px; }
.segmented.small { padding: 3px; }
.segmented.small button { height: 30px; font-size: 13px; padding: 0 12px; }

/* Blocos das monitorias */
.block { margin-top: 18px; }
.block-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 4px 8px; font-size: 15px; font-weight: 650;
}
.today-pill {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
}
.subject-dot.inline { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* Cálculo de médias */
.step-label {
  display: flex; align-items: center; gap: 8px;
  margin: 22px 2px 10px; font-size: 14px; font-weight: 600;
}
.step-label span {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.formula {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  font-size: 14px;
}
.formula b { color: var(--accent); font-weight: 650; }
.formula i { font-style: normal; color: var(--text-3); margin: 0 6px; }
.formula-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; color: var(--danger); }
.formula-foot .ok { color: var(--ok); }
.formula-foot .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.formula-foot .link-btn .ic { width: 16px; height: 16px; }
.source-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 8px 2px 0;
  font-size: 13px; line-height: 1.45; color: var(--warn);
}
.source-note.ok { color: var(--ok); }
.source-note .ic { width: 16px; height: 16px; margin-top: 1px; }
.grade-input-row { cursor: text; }
.grade-input-row .item-title, .grade-input-row .item-meta { display: block; }
.input.grade-box { width: 84px; height: 46px; text-align: center; font-size: 18px; font-weight: 600; flex-shrink: 0; }

/* Colar horários */
.paste-example {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg);
  font: 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
textarea.input.paste-box { height: 150px; }
.paste-row .item-body { display: grid; gap: 4px; }
.paste-row select.input { height: 38px; }
.paste-row select.input.creating { color: var(--accent); border-color: var(--accent); }

/* Escolher matérias */
.choose-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.choose-row { cursor: pointer; }
.choose-row .item-title, .choose-row .item-meta { display: block; }
.choose-box { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }

.grade-line { display: flex; justify-content: space-between; gap: 12px; }
.grade-line b { color: var(--text); }
.grade-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.grade-row .input { height: 40px; padding: 0 10px; }
.grade-head { font-size: 12px; color: var(--text-3); padding: 0 4px; margin-bottom: 2px; }
.toggle .target-input { width: 80px; height: 40px; text-align: center; flex-shrink: 0; }
.grade-result { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--bg); font-size: 14.5px; }
.result-big { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.result-big.ok { color: var(--ok); }
.result-big.bad { color: var(--danger); }

/* ============ Calendário (folha de parede) ============ */
/* O bloco: a espiral fica parada em cima; as folhas ficam presas nela. */
.pad { margin-top: 8px; overflow-x: clip; }
.wall-bind {
  position: relative; z-index: 6; height: 16px; border-radius: 6px 6px 0 0;
  background: var(--bind); display: flex; justify-content: space-around; align-items: center;
}
.wall-bind i { width: 7px; height: 7px; border-radius: 50%; background: var(--bg); }
.sheet-stack { position: relative; }
body { --paper-back: color-mix(in srgb, var(--surface) 88%, var(--text)); }
.page {
  position: relative; z-index: 1; background: var(--surface); border-radius: 0 0 6px 6px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* Virar a folha: o mês de destino fica por baixo, a aba dobrada (verso do papel) por cima */
.page-under { position: absolute; top: 0; left: 0; right: 0; z-index: 0; pointer-events: none; }
.page-under .corner { display: none; }
.curl-shade { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.page.curling { box-shadow: none; }
.curl-flap-wrap {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; transform-origin: 0 0;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.28));
}
.curl-flap { position: absolute; inset: 0; border-radius: 0 0 6px 6px; }

/* Cantinhos dobrados: pegue e arraste na diagonal */
.corner {
  position: absolute; bottom: 0; z-index: 4; width: 52px; height: 52px;
  touch-action: none; cursor: grab;
}
.corner-next { right: 0; }
.corner-prev { left: 0; }
.corner::before {
  content: ''; position: absolute; bottom: 0; width: 22px; height: 22px;
  transition: width 0.2s ease, height 0.2s ease;
}
.corner-next::before {
  right: 0; border-top-left-radius: 5px;
  background: linear-gradient(315deg, var(--bg) 0 47%, rgba(0, 0, 0, 0.22) 50%, var(--paper-back) 56%,
    color-mix(in srgb, var(--paper-back) 80%, #fff) 100%);
}
.corner-prev::before {
  left: 0; border-top-right-radius: 5px;
  background: linear-gradient(45deg, var(--bg) 0 47%, rgba(0, 0, 0, 0.22) 50%, var(--paper-back) 56%,
    color-mix(in srgb, var(--paper-back) 80%, #fff) 100%);
}
.corner:hover::before, .corner:focus-visible::before { width: 30px; height: 30px; }
.page:not(.curling) .corner-next::before { animation: peek 1.2s ease-in-out 0.8s 1; }
@keyframes peek { 40% { width: 34px; height: 34px; } }

/* Pilha de folhas arrancadas (meses passados) */
.pad.from-pile .wall-bind { visibility: hidden; height: 6px; }
.page.torn { padding-top: 6px; border-radius: 2px 2px 6px 6px; }
.pile-tag {
  position: absolute; z-index: 2; top: 16px; left: 12px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: rgba(0, 0, 0, 0.45); color: #fff;
}
.pile-count {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 10px 0 0; font-size: 12px; color: var(--text-3);
}
.pile-count .ic { width: 15px; height: 15px; }
.pile-count.bump { animation: bump 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes bump { 40% { transform: scale(1.18); color: var(--accent); } }

/* Folha pendurada do mês que acabou: puxe para baixo para arrancar */
.tear-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px 0 0; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 550;
}
.tear-hint span { display: flex; align-items: center; gap: 6px; }
.tear-hint .ic { width: 16px; height: 16px; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }
/* touch-action: none — senão o celular acha que puxar para baixo é "puxar para atualizar" e cancela */
.page.hanging { touch-action: none; cursor: grab; transition: transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1); }
.page.hanging.dragging { transition: none; cursor: grabbing; }
.page-falling { position: fixed; z-index: 60; margin: 0; pointer-events: none; }
.paper-bit {
  position: fixed; z-index: 61; width: 5px; height: 4px; border-radius: 1px; pointer-events: none;
  background: var(--surface); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.15);
}

/* Por baixo da folha pendurada: o mês novo, ainda à sombra e sem o número */
.page-under.tear-under { filter: brightness(0.9); }
.page-under.tear-under .mnum { opacity: 0; }

/* O mês novo chegando: a luz "acende" na foto, o número carimba, os dias dão um pulinho */
.page.ritual .wall-photo img { animation: photo-in 1.1s ease-out both; }
@keyframes photo-in { from { transform: scale(1.06); filter: brightness(0.85); } 45% { filter: brightness(1.15); } }
.page.ritual .mnum { display: inline-block; animation: stamp 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) 0.6s both; }
@keyframes stamp { from { opacity: 0; transform: scale(2.4) rotate(-10deg); } }
.page.ritual .day .n { animation: day-in 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both; animation-delay: calc(0.85s + var(--row, 0) * 70ms); }
@keyframes day-in { 50% { transform: translateY(-3px) scale(1.08); } }

/* Resumo do mês que acabou */
.dialog.month-summary { text-align: center; padding: 0 20px 20px; overflow: hidden; animation: pop 0.3s ease-out; }
.month-summary .saekdong { margin: 0 -20px 16px; }
.ms-eyebrow { margin: 0 !important; font-size: 13px !important; color: var(--text-2); }
.month-summary h3 { margin: 2px 0 16px; font-size: 22px; font-weight: 800; color: var(--accent); }
.ms-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.ms-stats div { padding: 10px 4px; border-radius: 12px; background: var(--band); }
.ms-stats b { display: block; font-size: 24px; font-weight: 800; color: var(--accent); }
.ms-stats span { font-size: 11.5px; color: var(--text-2); line-height: 1.2; }
.ms-note { margin: 0 0 16px !important; font-size: 14.5px !important; color: var(--text-2); }

/* ============ Adesivos ============ */
.sticker-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.sticker {
  position: absolute; transform: translate(-50%, -50%) rotate(var(--r));
  font-size: 30px; line-height: 1; user-select: none; -webkit-user-select: none;
  /* contorno branco de adesivo recortado + sombrinha */
  filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff)
          drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
}
.decorating .sticker { pointer-events: auto; cursor: grab; touch-action: none; }
.decorating .cal { pointer-events: none; }
.sticker.sel { outline: 1.5px dashed var(--accent); outline-offset: 5px; border-radius: 8px; }
.sticker.lifted { transform: translate(-50%, -50%) rotate(var(--r)) scale(1.25); cursor: grabbing; z-index: 2; }
.sticker.leaving { opacity: 0.45; }
.sticker.stick { animation: stick 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes stick { from { transform: translate(-50%, -50%) rotate(var(--r)) scale(1.35); } }
.sticker-x {
  position: absolute; top: -16px; right: -16px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--danger); color: #fff; filter: none;
}
.sticker-x .ic { width: 12px; height: 12px; stroke-width: 3; }

.sticker-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px 0 0; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 550;
  transition: background 0.15s, color 0.15s;
}
.sticker-bar > span { display: flex; align-items: center; gap: 6px; }
.sticker-bar .ic { width: 16px; height: 16px; flex-shrink: 0; }
.sticker-bar.removing { background: var(--danger-soft); color: var(--danger); }
.sticker-bar.removing .sticker-tip { font-size: 0; }
.sticker-bar.removing .sticker-tip::after { content: 'Solte para tirar o adesivo'; font-size: 13px; }

.sticker-tray {
  margin-top: 12px; padding: 10px; border-radius: 14px;
  background: var(--surface); border: 1px dashed var(--line-2);
}
.tray-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; }
.tray-tabs::-webkit-scrollbar { display: none; }
.tray-tabs button {
  flex-shrink: 0; height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 550; color: var(--text-2);
}
.tray-tabs button.on { background: var(--accent-soft); color: var(--accent); }
.tray-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.tray-sticker {
  aspect-ratio: 1; border-radius: 12px; font-size: 28px; line-height: 1;
  filter: drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff)
          drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.25));
  transition: transform 0.12s;
}
.tray-sticker:active { transform: scale(0.88) rotate(-6deg); }
.tray-sticker { touch-action: none; }
/* O adesivo sendo arrastado da cartela até a folha */
.sticker-drag {
  position: fixed; z-index: 70; pointer-events: none; font-size: 32px; line-height: 1;
  transform: translate(-50%, -50%) rotate(var(--r)) scale(1.1); transition: transform 0.12s;
  filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff)
          drop-shadow(0 6px 6px rgba(0, 0, 0, 0.3));
  opacity: 0.85;
}
.sticker-drag.over { transform: translate(-50%, -50%) rotate(var(--r)) scale(1.3); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .page.ritual *, .corner::before, .tear-hint .ic, .sticker.stick, .pile-count.bump { animation: none !important; }
}

.wall-photo { position: relative; margin: 0; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.wall-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wall-photo.loading { animation: pulse 1.2s ease-in-out infinite alternate; }
.wall-photo.offline img { display: none; }
@keyframes pulse { to { opacity: 0.55; } }
.wall-photo figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 10px 5px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
  font-size: 10px; text-align: right;
}
.wall-photo figcaption a { color: rgba(255, 255, 255, 0.85); text-decoration: none; }
.photo-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.photo-actions .photo-btn { position: static; }
.photo-btn {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(0, 0, 0, 0.35); color: #fff; backdrop-filter: blur(4px);
}
.photo-btn .ic { width: 17px; height: 17px; }
.wall-photo.empty { display: grid; place-items: center; }
.photo-btn.big {
  position: static; width: auto; height: auto; border-radius: 12px; padding: 10px 16px;
  display: flex; gap: 8px; background: var(--surface); color: var(--accent); font-size: 14px; font-weight: 600;
}

.wall-month { background: var(--band); padding: 12px 8px 8px; }
.wall-head { display: flex; align-items: flex-end; gap: 10px; margin: 0 6px 10px; }
.mnum { font-size: 52px; font-weight: 800; line-height: 0.85; color: var(--accent); letter-spacing: -2px; }
.mname { color: var(--accent); font-size: 16px; font-weight: 700; line-height: 1.15; }
.mname small { display: block; font-size: 12px; color: var(--text-2); font-weight: 500; }
.wall-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.month-pick { display: flex; align-items: flex-end; gap: 10px; text-align: left; border-radius: 10px; padding: 2px 4px 2px 0; }
.month-pick:active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.month-pick .mname .ic { width: 14px; height: 14px; margin-left: 3px; vertical-align: -1px; opacity: 0.6; }

/* Seletor de mês */
.mp-head { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 12px; }
.mp-head b { font-size: 20px; font-weight: 800; color: var(--accent); }
.mp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mp-month {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 12px 4px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
}
.mp-month b { font-size: 22px; font-weight: 800; line-height: 1; color: var(--text); }
.mp-month span { font-size: 12px; color: var(--text-2); }
.mp-month.past b { color: var(--text-3); }
.mp-month.now { border-color: var(--accent); }
.mp-month.now::after {
  content: 'hoje'; position: absolute; top: 5px; right: 6px; font-size: 9.5px; font-weight: 700; color: var(--accent);
}
.mp-month.on { background: var(--accent); border-color: var(--accent); }
.mp-month.on b, .mp-month.on span, .mp-month.on::after { color: var(--on-accent); }
.mp-exam { position: absolute; top: 7px; left: 7px; width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 2px var(--warn); }
.wall-nav .chip { height: 30px; font-size: 12.5px; margin-right: 4px; background: var(--surface); }
.wall-nav .icon-btn { color: var(--accent); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.wd { font-size: 9.5px; color: var(--text-2); padding: 0 0 6px; line-height: 1.25; letter-spacing: 0.3px; }
.wd b { display: block; font-size: 11px; font-weight: 600; }
.wd.sun { color: var(--sun); }
.wd.sat { color: var(--sat); }
.day {
  position: relative; height: 54px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  padding-top: 5px; border-left: 1px solid var(--line);
}
.day:nth-child(7n + 1) { border-left: 0; }
.day.blank { pointer-events: none; }
.day .n {
  width: 30px; height: 30px; line-height: 30px; border-radius: 50%;
  font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.5px;
}
.day.sun .n, .day.hol .n { color: var(--sun); }
.day.sat .n { color: var(--sat); }
.day.past .n, .day.past .hol-name, .day.past .dots { opacity: 0.32; }
.day.sel { background: var(--surface); border-radius: 10px; }
.day.today .n { background: var(--accent); color: var(--on-accent); opacity: 1; }
.day.exam .n { box-shadow: 0 0 0 2px var(--warn); }
.hol-name {
  max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 8px; line-height: 1; color: var(--sun);
}
.dots { display: flex; gap: 3px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.holiday-line { display: flex; align-items: center; gap: 6px; margin: -2px 2px 8px; font-size: 13px; color: var(--sun); }
.holiday-line .ic { width: 15px; height: 15px; }

/* Tema nas Configurações */
.theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.theme-card {
  display: grid; gap: 6px; justify-items: center; padding: 8px 4px 10px; border-radius: 12px;
  border: 1.5px solid var(--line-2); font-size: 12.5px; font-weight: 550;
}
.theme-card.on { border-color: var(--accent); color: var(--accent); }
.theme-swatch {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden;
  background: var(--p); border: 1px solid rgba(128, 128, 128, 0.25);
}
.theme-swatch .half { position: absolute; inset: 0 0 0 50%; background: var(--p); }
.theme-swatch i { position: absolute; display: block; }
.sw-band { left: 0; right: 0; top: 40%; height: 34%; background: var(--b); opacity: 0.9; }
.sw-num { left: 12%; top: 46%; width: 18%; height: 22%; border-radius: 3px; background: var(--a); }
.sw-sun { left: 40%; top: 52%; width: 9%; height: 12%; border-radius: 2px; background: #d7263d; }
.sw-sat { left: 74%; top: 52%; width: 9%; height: 12%; border-radius: 2px; background: #2c56c6; }
.label .ic { width: 15px; height: 15px; vertical-align: -3px; }
.hint .ic { width: 13px; height: 13px; vertical-align: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-2); margin: 10px 2px 0; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.legend i.ring { width: 10px; height: 10px; background: none; box-shadow: 0 0 0 2px var(--warn); }

/* ============ Sem prazo e objetivos ============ */
.quick { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.quick input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 15px; }
.quick input::placeholder { color: var(--text-3); }

.goal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.goal-head { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.goal-head > div { flex: 1; min-width: 0; }
.goal-title { margin: 0; font-size: 15.5px; font-weight: 600; }
.goal.achieved .goal-title { color: var(--text-2); }
.goal-count { font-size: 12.5px; color: var(--text-2); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.goal.achieved .progress i { background: var(--ok); }
.steps { margin-top: 8px; }
.goal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.goal-empty {
  width: 100%; padding: 18px; border: 1.5px dashed var(--line-2); border-radius: var(--radius);
  color: var(--text-2); font-size: 14px; line-height: 1.5; text-align: center;
}

/* ============ Painel inferior (formulários) ============ */
#sheet-root { position: fixed; inset: 0; z-index: 20; display: none; }
#sheet-root.open { display: block; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.42); animation: fade 0.2s; }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.22s ease-out;
}
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 14px; }
.sheet { overscroll-behavior: contain; }
.ic-inline { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.label .ic-inline { width: 14px; height: 14px; }
.until-label { font-size: 14px; color: var(--text-2); flex-shrink: 0; }
.dialog .choice {
  height: auto; padding: 12px 14px; margin-bottom: 8px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
}
.dialog .choice small { font-size: 12.5px; color: var(--text-2); font-weight: 400; line-height: 1.4; }
.sheet h2 { font-size: 19px; margin: 0 0 16px; }

.field { margin-bottom: 16px; }
.label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.input {
  width: 100%; height: 46px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg);
  padding: 0 12px; outline: none; font-size: 15px;
}
.input:focus { border-color: var(--accent); }
textarea.input { height: 84px; padding: 10px 12px; resize: vertical; }
.error { color: var(--danger); font-size: 13px; margin: 6px 2px 0; }
.row { display: flex; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-2); font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .ic { width: 16px; height: 16px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 550; }
.chip .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

.toggle { display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer;
  width: 46px; height: 28px; border-radius: 14px; background: var(--line-2);
  position: relative; transition: background 0.2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }

.sheet-actions { display: flex; gap: 8px; margin-top: 20px; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
}
.choice > .ic { width: 24px; height: 24px; color: var(--accent); }
.choice b { display: block; font-weight: 600; font-size: 15px; }
.choice small { font-size: 13px; color: var(--text-2); }

.swatch { width: 22px; height: 22px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.inline-input { flex: 1; min-width: 0; height: 36px; border: 0; background: transparent; outline: none; font-size: 15px; }

/* ============ Confirmação ============ */
#dialog-root { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; padding: 24px; }
#dialog-root.open { display: grid; }
.dialog {
  position: relative; width: 100%; max-width: 340px;
  background: var(--surface); border-radius: 18px; padding: 20px;
  animation: pop 0.16s ease-out;
}
.dialog p { margin: 0 0 18px; font-size: 15.5px; line-height: 1.45; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; }
.dialog .row.stacked { flex-direction: column-reverse; }

/* ============ Aviso rápido ============ */
.toast {
  position: fixed; left: 50%; z-index: 30;
  bottom: calc(var(--tabs-h) + 88px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  width: max-content; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg);
  padding: 11px 16px; border-radius: 12px; font-size: 14px;
  display: flex; gap: 16px; align-items: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
