@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* ---------- temas visuais ---------- */
:root,
[data-theme="noite"]   { --bg:#070707; --panel:#0d0d0d; --fg:#ece9e2; --dim:#6d6a64; --line:#1f1e1c; --accent:#ff453a; --grain:.06; }
[data-theme="fosforo"] { --bg:#0a0805; --panel:#100d08; --fg:#ffdcaa; --dim:#7d6a4d; --line:#2a2217; --accent:#ffb000; --grain:.06; }
[data-theme="gelo"]    { --bg:#05080a; --panel:#0a0f12; --fg:#e2edf2; --dim:#5d6e77; --line:#17232a; --accent:#6fd3ff; --grain:.06; }
[data-theme="musgo"]   { --bg:#070906; --panel:#0c0f0a; --fg:#e4eadf; --dim:#68725e; --line:#1c2318; --accent:#9be15d; --grain:.06; }
[data-theme="violeta"] { --bg:#08060c; --panel:#0e0b14; --fg:#ece6f5; --dim:#6f6781; --line:#221c2d; --accent:#b28cff; --grain:.06; }
[data-theme="papel"]   { --bg:#f5f3ee; --panel:#efece5; --fg:#1c1b19; --dim:#8b877f; --line:#dedad1; --accent:#d9480f; --grain:.035; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .5s ease, color .5s ease;
}

::selection { background: var(--accent); color: var(--bg); }

/* brilho suave no fundo */
.glow {
  position: fixed; left: 50%; top: 50%; width: 70vmax; height: 70vmax;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 7%, transparent), transparent);
  transition: background .5s;
}

/* textura de filme */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 50; opacity: var(--grain);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

/* ---------- topo ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 30px; z-index: 30;
}
.logo { font-size: 13px; font-weight: 500; letter-spacing: .22em; color: var(--dim); }
.blink { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.head-right { display: flex; align-items: center; gap: 22px; }

.theme-wrap { position: relative; }
.swatch-btn { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); transition: border-color .2s; }
.swatch-btn:hover { border-color: var(--dim); }
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); transition: background .5s; }

.theme-menu {
  position: absolute; right: 0; top: 38px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; min-width: 170px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.theme-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.theme-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border-radius: 9px; font-size: 13px; text-align: left; color: var(--fg);
}
.theme-opt:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.theme-opt i { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35); }
.theme-opt .check { margin-left: auto; color: var(--accent); opacity: 0; }
.theme-opt.on .check { opacity: 1; }

/* ---------- telas ---------- */
main { height: 100%; position: relative; z-index: 1; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 30px; padding: 0 8vw; text-align: center;
  opacity: 0; pointer-events: none; transform: translateY(10px); filter: blur(4px);
  transition: opacity .5s ease, transform .5s ease, filter .5s ease;
}
.screen.active { opacity: 1; pointer-events: auto; transform: none; filter: none; }

.hero {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: clamp(40px, 6.4vw, 84px); line-height: 1.02; letter-spacing: -.02em;
}
.hero em { color: var(--dim); }

.cat {
  font-size: 11px; font-weight: 500; letter-spacing: .28em; text-transform: uppercase;
  color: var(--accent); min-height: 1em;
}

.topic {
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: clamp(36px, 6vw, 80px);
  line-height: 1.05; letter-spacing: -.015em;
  max-width: 17ch; min-height: 2.2em;
  display: flex; align-items: center; justify-content: center;
  transition: filter .2s, opacity .2s;
}
.topic.small {
  font-size: clamp(18px, 2.2vw, 26px); font-style: italic;
  min-height: 0; max-width: 40ch; color: var(--dim);
}
.topic.spin { filter: blur(1.2px); opacity: .7; }
.topic.locked { animation: lock .7s cubic-bezier(.2, .9, .3, 1.25); }
@keyframes lock {
  0% { transform: scale(.94); filter: blur(3px); }
  100% { transform: scale(1); filter: none; }
}

.clock {
  font-size: clamp(96px, 21vw, 260px);
  font-weight: 200; letter-spacing: -.05em;
  font-variant-numeric: tabular-nums; line-height: .95;
}
.clock.final { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- controles ---------- */
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.big {
  font-size: 13px; font-weight: 500; letter-spacing: .26em; text-transform: uppercase;
  padding: 18px 46px;
  border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 3%, transparent);
  transition: border-color .25s, background .25s, transform .15s, box-shadow .25s;
}
.big:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 18%, transparent);
}
.big:active { transform: scale(.97); }

.link {
  font-size: 12px; letter-spacing: .14em; color: var(--dim);
  border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
.link:hover { color: var(--fg); border-color: var(--dim); }
.link:disabled { opacity: .3; pointer-events: none; }

.actions {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  transition: opacity .4s, transform .4s;
}
.actions.hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }

/* seletor 10/15 min — discreto */
.mode {
  display: inline-flex; padding: 3px; border-radius: 999px;
  border: 1px solid var(--line); position: relative;
}
.mode-opt {
  font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  padding: 7px 16px; border-radius: 999px; color: var(--dim);
  transition: color .25s, background .25s;
}
.mode-opt.on { color: var(--fg); background: color-mix(in srgb, var(--fg) 8%, transparent); }

.stats {
  display: flex; gap: 34px; margin-top: 10px;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim);
}
.stats b {
  display: block; margin-bottom: 6px;
  font-family: "Instrument Serif", Georgia, serif; font-weight: 400;
  font-size: 30px; letter-spacing: 0; text-transform: none; color: var(--fg);
}

.note { display: flex; flex-direction: column; gap: 10px; width: min(540px, 100%); }
.note span { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.note input {
  font-family: "Instrument Serif", Georgia, serif; font-size: 24px; font-style: italic; color: var(--fg);
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 2px; outline: none; text-align: center; transition: border-color .2s;
}
.note input::placeholder { color: var(--line); }
.note input:focus { border-color: var(--accent); }

.hint {
  position: fixed; bottom: 26px; left: 0; right: 0; text-align: center; z-index: 2;
  font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--dim); opacity: .5;
}

.bar { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); z-index: 3; }
#barFill { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; box-shadow: 0 0 12px var(--accent); }

/* ---------- histórico ---------- */
.hist {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%);
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .4s cubic-bezier(.2, .8, .2, 1);
  z-index: 40; display: flex; flex-direction: column;
}
.hist.open { transform: none; box-shadow: -30px 0 80px rgba(0, 0, 0, .3); }
.hist-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 26px 28px; font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.hist ol { list-style: none; overflow-y: auto; padding: 6px 28px 40px; }
.hist li { padding: 18px 0; border-bottom: 1px solid var(--line); }
.hist .h-date { font-size: 10px; color: var(--dim); letter-spacing: .18em; text-transform: uppercase; }
.hist .h-topic { font-family: "Instrument Serif", Georgia, serif; font-size: 22px; line-height: 1.15; margin-top: 6px; }
.hist .h-note { font-size: 13px; color: var(--dim); margin-top: 8px; line-height: 1.5; }
.hist .empty { color: var(--dim); font-size: 14px; padding: 28px 0; }

/* ---------- modo livre ---------- */
.mode-sep { width: 1px; margin: 6px 4px; background: var(--line); }
.free-opt[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
body.free .stats { opacity: .35; }
body.free .logo::after {
  content: "livre"; margin-left: 12px; padding: 3px 8px; border-radius: 999px;
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
body.free #s-done .note { display: none; }

/* ---------- zerar histórico ---------- */
.hist { }
.hist ol { flex: 1; }
.hist-foot {
  padding: 20px 28px 28px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.hist-foot small { font-size: 11px; color: var(--dim); line-height: 1.5; }
.link.danger { align-self: flex-start; }
.link.danger:hover, .link.danger.armed { color: var(--accent); border-color: var(--accent); }
