@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #0e1016;
  --panel: #171a23;
  --panel-2: #1f2330;
  --line: #292e3d;
  --text: #f3f4f8;
  --muted: #9097ab;
  --accent: #a78bfa;
  --ok: #4ade80;
  --warn: #fb7185;
  --ink: #0e1016;
  --c: var(--accent);
  --r-tile: 22px;
  --nav-h: 64px;
  --nav-w: 248px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(60rem 40rem at 85% -10%, rgb(167 139 250 / 0.10), transparent 60%),
    radial-gradient(50rem 36rem at -10% 110%, rgb(34 211 238 / 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 1rem/1.4 "Bricolage", ui-rounded, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, p, ul, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 8px; }

/* ---------- estrutura ---------- */

#view {
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px);
  outline: none;
}

.top { margin-bottom: 18px; }
.top p { color: var(--muted); font-size: 0.95rem; }
.top p::first-letter { text-transform: uppercase; }
.top h1 { font-size: clamp(2rem, 1.5rem + 2vw, 2.9rem); font-weight: 750; line-height: 1.05; letter-spacing: -0.03em; }

h2 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
section + section { margin-top: 26px; }

.meta { color: var(--muted); font-size: 0.875rem; }
.meta.gap { margin: 14px 0 4px; }
.warn { color: var(--warn); }
.empty { color: var(--muted); font-size: 0.95rem; padding: 6px 0; }

.tile {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.025), transparent 40%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-tile);
  padding: 18px;
}

/* ---------- navegação ---------- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgb(14 16 22 / 0.86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.brand, .nav-status { display: none; }
.nav nav { display: flex; justify-content: space-around; }
.nav button {
  flex: 1; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0;
  color: var(--muted); font-size: 0.75rem; font-weight: 550;
}
.nav svg, .icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button[aria-current] { color: var(--text); }
.nav button[aria-current] svg { stroke: var(--accent); }

/* ---------- resumo do dia ---------- */

.today { display: grid; gap: 26px; }
.today-main { min-width: 0; }

.hero { display: flex; align-items: center; gap: 18px; padding: 20px; margin-bottom: 26px; }
.hero.is-closed { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--panel)); }
.hero-dial { position: relative; flex: none; width: clamp(104px, 28vw, 150px); aspect-ratio: 1; }
.dial { width: 100%; height: 100%; display: block; }
.dial path { fill: none; stroke-width: 13; stroke-linecap: round; }
.dial .track { opacity: 0.2; }
.hero-pct { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: calc(50% - 0.62em); line-height: 1; font-size: clamp(1.5rem, 6vw, 2.1rem); font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-pct small { font-size: 0.5em; font-weight: 600; color: var(--muted); margin-left: 1px; }
.hero-text { min-width: 0; }
.hero-title { font-size: clamp(1.3rem, 1rem + 1.6vw, 1.9rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; margin-bottom: 6px; text-wrap: balance; }
.is-closed .hero-title { color: var(--ok); }

.now-running {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-top: 14px; padding: 10px 12px;
  border-radius: 16px; background: color-mix(in srgb, var(--c) 14%, transparent);
}
.now-name { font-weight: 600; }
.now-time { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: auto; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--c); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; transform: scale(0.7); } }

/* ---------- hábitos ---------- */

.habits { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px; }

.habit {
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; text-align: left;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}
button.habit:active { transform: scale(0.985); }
.habit.is-done {
  background: color-mix(in srgb, var(--c) 13%, var(--panel));
  border-color: color-mix(in srgb, var(--c) 45%, var(--line));
}
.habit.is-running { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }

.habit-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; background: none; border: 0; text-align: left; }
.chip {
  flex: none; width: 46px; height: 46px; border-radius: 15px;
  display: grid; place-items: center; font-size: 1.4rem;
  background: color-mix(in srgb, var(--c) 20%, transparent);
}
.habit-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.name { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }

.tick {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--c) 70%, var(--line));
  display: grid; place-items: center;
  transition: background-color 0.15s, border-color 0.15s, transform 0.2s cubic-bezier(.3,1.6,.5,1);
}
.is-done > * > .tick, .is-done > .tick { background: var(--c); border-color: var(--c); transform: scale(1.06); }
.is-done > * > .tick::after, .is-done > .tick::after {
  content: ""; width: 13px; height: 7px; margin-top: -3px;
  border-left: 2.6px solid var(--ink); border-bottom: 2.6px solid var(--ink);
  transform: rotate(-45deg);
}

.ring { position: relative; flex: none; width: 48px; height: 48px; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.ring-track { stroke: color-mix(in srgb, var(--c) 20%, transparent); }
.ring-fill { stroke: var(--c); transition: stroke-dasharray 0.4s; }
.ring b { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring.full::after {
  content: ""; width: 14px; height: 7px; margin-top: -3px;
  border-left: 2.6px solid var(--c); border-bottom: 2.6px solid var(--c);
  transform: rotate(-45deg);
}

.habit-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.week { display: flex; gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 22px; font-size: 0.68rem; color: var(--muted); }
.wd i { width: 100%; height: 8px; border-radius: 4px; background: var(--panel-2); }
.wd.on i { background: color-mix(in srgb, var(--c) calc(var(--lv) * 100%), var(--panel-2)); }
.wd.future i { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.wd.now { color: var(--text); font-weight: 700; }
.badge { padding: 3px 9px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .btn { padding: 0 11px; }
.quick .btn.ghost { min-width: 50px; }
.quick .tint { margin-right: auto; }

/* ---------- botões ---------- */

.btn {
  min-height: 44px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 14px;
  font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: transform 0.1s, filter 0.15s, background-color 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn.solid { background: var(--text); color: var(--ink); }
.btn.ghost { background: var(--panel-2); border-color: var(--line); }
.btn.tint { background: var(--c); color: var(--ink); }
.tile > .btn { margin-top: 14px; }

.link { min-height: 40px; padding: 0 6px; background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 0.92rem; white-space: nowrap; }
.link.quiet { color: var(--muted); font-weight: 450; }
.link.danger { color: var(--warn); margin-right: auto; }
.icon-btn { width: 36px; height: 40px; display: grid; place-items: center; padding: 0; background: none; border: 0; border-radius: 10px; color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- tarefas ---------- */

.tasks { --c: var(--accent); align-self: start; }
.task-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.task-form-actions { display: flex; gap: 8px; }
.task-form-actions .btn { flex: 1; }

input[type="text"], input[type="password"], input[type="number"], input[type="time"], input:not([type]), select {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  font-size: 1rem;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-radius: 14px; }
select { padding: 0 8px 0 12px; text-overflow: ellipsis; }
input::placeholder { color: var(--muted); opacity: 0.85; }

.task { display: flex; align-items: center; gap: 2px; border-top: 1px solid var(--line); }
.task-list .task:first-child { border-top: 0; }
.task-main { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 6px 0; background: none; border: 0; text-align: left; }
.task .tick { width: 26px; height: 26px; border-radius: 9px; }
.task .tick::after { width: 10px !important; height: 5px !important; }
.task-title { font-weight: 550; overflow-wrap: anywhere; }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; }

.later { margin-top: 10px; border-top: 1px solid var(--line); }
.later summary { min-height: 48px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); font-weight: 600; list-style: none; }
.later summary::-webkit-details-marker { display: none; }
.later summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(45deg); transition: transform 0.2s; }
.later[open] summary::after { transform: rotate(-135deg); }
.count { padding: 1px 9px; border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

.notice { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; font-size: 0.95rem; }
.inline { display: flex; gap: 8px; }

/* ---------- histórico ---------- */

.hist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.hist { display: flex; flex-direction: column; gap: 16px; margin: 0 !important; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 12px; border-radius: 14px; background: var(--panel-2); min-width: 0; }
.stat b { display: block; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { display: block; color: var(--muted); font-size: 0.75rem; line-height: 1.25; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); grid-auto-columns: 1fr; gap: 3px; }
.cell { aspect-ratio: 1; border-radius: 4px; background: var(--panel-2); }
.cell.on { background: color-mix(in srgb, var(--c) calc(var(--lv) * 100%), var(--panel-2)); }
.cell.future { background: none; }
.cell.now { box-shadow: 0 0 0 1.5px var(--text); }

/* ---------- ajustes ---------- */

.settings { display: grid; gap: 14px; }
.settings-side { display: grid; gap: 14px; align-content: start; }
.settings section { margin: 0; }
.plain-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.plain-list input[type="time"] { flex: 1; width: auto; }
.plain-list .chip { width: 40px; height: 40px; border-radius: 13px; font-size: 1.2rem; }
.state-on { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.state-on::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }

/* ---------- diálogo e avisos ---------- */

dialog {
  width: min(100% - 24px, 30rem); max-height: 90dvh;
  padding: 22px; border: 1px solid var(--line); border-radius: 24px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.5);
}
dialog::backdrop { background: rgb(6 7 10 / 0.7); backdrop-filter: blur(4px); }
dialog h2 { display: flex; align-items: center; gap: 12px; font-size: 1.35rem; font-weight: 700; margin: 0; }
dialog form { display: flex; flex-direction: column; gap: 16px; }
dialog label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.875rem; }
dialog label.narrow { flex: 0 0 4.5rem; }
.field-row { display: flex; gap: 10px; align-items: flex-end; }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; }

.swatches { border: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.swatches legend { color: var(--muted); font-size: 0.875rem; margin-bottom: 8px; padding: 0; }
.swatches label { flex: none; position: relative; width: 36px; height: 36px; }
.swatches input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatches i { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); transition: transform 0.15s; }
.swatches input:checked + i { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c); transform: scale(0.86); }
.swatches input:focus-visible + i { outline: 2px solid var(--text); outline-offset: 5px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 20;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 14px;
  background: var(--text); color: var(--ink); font-weight: 600; font-size: 0.95rem;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- entrar e criar conta ---------- */

body.auth-page { display: grid; grid-template-columns: minmax(0, 1fr); }
.auth-art {
  display: flex; align-items: center; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 28px) 24px 8px;
}
.auth-dial { position: relative; flex: none; width: 104px; aspect-ratio: 1; }
.auth-dial svg { width: 100%; height: 100%; display: block; }
.auth-dial path { fill: none; stroke-width: 12; stroke-linecap: round; }
.auth-dial .track { opacity: 0.18; }
.auth-dial .fill { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.9s cubic-bezier(.3,.8,.3,1) forwards; animation-delay: calc(var(--i) * 90ms + 150ms); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.auth-clock { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.auth-clock b { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.auth-clock span { display: none; color: var(--muted); }
.auth-art h1 { font-size: 1.5rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
.auth-art p { display: none; }

.auth-main { display: grid; align-content: start; justify-items: center; padding: 20px 24px calc(env(safe-area-inset-bottom) + 40px); }
.auth-form { width: 100%; max-width: 27rem; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: none; }
.auth-form h2 { font-size: 2rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; margin: 0; }
.auth-form .lead { color: var(--muted); font-size: 1.05rem; margin-top: -10px; }
.auth-field { display: flex; flex-direction: column; gap: 8px; font-size: 1rem; font-weight: 550; }
.auth-field .hint { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.auth-field .err { color: var(--warn); font-size: 0.9rem; font-weight: 500; }
.auth-form input { min-height: 58px; padding: 0 18px; font-size: 1.1rem; border-radius: 16px; background: var(--panel); }
.auth-form input[aria-invalid="true"] { border-color: var(--warn); }
.pw { position: relative; }
.pw input { padding-right: 92px; }
.pw button { position: absolute; right: 6px; top: 7px; height: 44px; padding: 0 14px; background: none; border: 0; border-radius: 12px; color: var(--muted); font-size: 0.95rem; font-weight: 600; }
.auth-form .btn { min-height: 58px; font-size: 1.1rem; border-radius: 16px; background: var(--accent); color: var(--ink); margin-top: 4px; }
.auth-form .btn:disabled { opacity: 0.6; cursor: default; }
.auth-error { color: var(--warn); font-weight: 500; }
.auth-error:empty, .auth-field .err:empty { display: none; }
.auth-field:has(.err:not(:empty)) .hint { display: none; }
.auth-switch { color: var(--muted); font-size: 1rem; text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 650; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

@media (min-width: 900px) {
  body.auth-page { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100dvh; }
  .auth-art {
    flex-direction: column; justify-content: center; gap: 44px; padding: 56px;
    border-right: 1px solid var(--line);
    background: radial-gradient(42rem 42rem at 50% 42%, rgb(167 139 250 / 0.13), transparent 65%);
    text-align: center;
  }
  .auth-dial { width: min(46vh, 30vw, 440px); }
  .auth-dial path { stroke-width: 11; }
  .auth-clock b { font-size: clamp(3.4rem, 7vw, 6rem); }
  .auth-clock span { display: block; margin-top: 12px; font-size: 1.15rem; }
  .auth-clock span::first-letter { text-transform: uppercase; }
  .auth-art h1 { font-size: clamp(2rem, 2.8vw, 2.8rem); max-width: 16ch; }
  .auth-art p { display: block; margin-top: 14px; color: var(--muted); font-size: 1.15rem; max-width: 34ch; }
  .auth-main { align-content: center; padding: 56px; }
  .auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.3rem; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 14px; }
  .auth-brand img { border-radius: 11px; }
  .auth-form h2 { font-size: 2.6rem; }
}

/* ---------- PC ---------- */

@media (min-width: 960px) {
  .nav {
    top: 0; right: auto; width: var(--nav-w);
    display: flex; flex-direction: column; gap: 28px;
    padding: 28px 16px 22px;
    border-top: 0; border-right: 1px solid var(--line);
    background: rgb(14 16 22 / 0.6);
  }
  .brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; font-size: 1.3rem; font-weight: 750; letter-spacing: -0.02em; }
  .brand img { border-radius: 11px; }
  .nav nav { flex-direction: column; gap: 4px; }
  .nav button {
    flex: none; height: 46px; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 0 12px; border-radius: 13px; font-size: 1rem;
    transition: background-color 0.15s;
  }
  .nav button:hover { background: var(--panel); color: var(--text); }
  .nav button[aria-current] { background: var(--panel-2); }
  .nav-status { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 0 12px; color: var(--muted); font-size: 0.8rem; }
  .nav-status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
  .nav-status.off::before { background: var(--warn); }

  body:not(.auth-page) { padding-left: var(--nav-w); }
  #view { max-width: 1320px; padding: 36px 40px 56px; }
  .top { margin-bottom: 26px; }

  .today { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); gap: 22px; align-items: start; }
  .tasks { position: sticky; top: 28px; max-height: calc(100dvh - 56px); overflow-y: auto; margin: 0; }
  .hero { padding: 26px 28px; gap: 28px; }
  .hero-dial { width: 164px; }
  .habits { gap: 14px; }
  .habit:hover, .hist:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
  .btn:hover { filter: brightness(1.12); }
  .link:hover { text-decoration: underline; }
  .icon-btn:hover { background: var(--panel-2); color: var(--text); }

  .tile > .btn + .btn { margin-left: 8px; }
  .settings { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  #toast { bottom: 28px; left: calc(50% + var(--nav-w) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
