/* Tema escuro ao estilo do Relógio do Windows 11 */
:root {
  --bg: #202020;
  --card: #2b2b2b;
  --card-border: #1a1a1a;
  --inset: #333333;
  --stroke: #3d3d3d;
  --track: #505050;
  --text: #ffffff;
  --sub: #c5c5c5;
  --accent: #4cc2ff;
  --accent-hover: #62cdff;
  --break: #6ccb5f;
  --warn: #fcb95b;
  --row: #373737;
  --row-hover: #3d3d3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1em; height: 1em; flex: none; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 862px; margin: 0 auto; padding: 14px 16px 6px;
}
.topbar h1 { font-size: 20px; font-weight: 600; margin: 0; }

.layout {
  display: grid; gap: 16px;
  max-width: 862px; margin: 0 auto; padding: 8px 16px 32px;
  grid-template-columns: 1fr;
}
@media (min-width: 880px) {
  .layout {
    grid-template-columns: 415px 415px;
    grid-template-areas: "focus daily" "cats history";
    align-items: start;
  }
  .focus-card { grid-area: focus; }
  .categories-card { grid-area: cats; }
  .daily-card { grid-area: daily; }
  .history-card { grid-area: history; grid-row: 2 / span 1; }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px 18px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.card-head h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; font-weight: 600; }
.accent-ic { color: var(--accent); font-size: 18px; }

.sub { color: var(--sub); }
.center { text-align: center; }
.center-block { display: flex; justify-content: center; }
p { margin: 0; }

/* ---------- Botões ---------- */
.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 40px; height: 36px; border: 0; border-radius: 4px;
  background: transparent; font-size: 18px;
}
.icon-btn:hover { background: #3a3a3a; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 6px 14px;
  background: #373737; border: 1px solid #444; border-radius: 4px;
}
.btn:hover { background: #424242; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #000; }
.btn.accent:hover { background: var(--accent-hover); }
.btn.start { margin-top: 26px; padding: 9px 16px; font-size: 15px; }
.btn.start svg { font-size: 15px; margin-right: 4px; }

/* ---------- Preparação ---------- */
.focus-card { padding: 22px 24px 28px; }
.focus-title { font-size: 22px; font-weight: 600; margin: 8px 8% 0; line-height: 1.35; }
.focus-card .sub.center { margin-top: 10px; }

.picker {
  display: flex; width: 198px; margin: 26px auto 0;
  background: var(--inset);
  border: 1px solid var(--stroke); border-bottom: 1px solid #8a8a8a;
  border-radius: 4px 4px 0 0;
}
.picker-value {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-right: 1px solid var(--stroke); padding: 10px 0;
}
#minutes { font-size: 44px; line-height: 1.1; font-weight: 400; }
.picker-value small { font-size: 13px; color: var(--sub); }
.picker-arrows { width: 60px; display: flex; flex-direction: column; }
.picker-arrows button {
  flex: 1; height: 54px; border: 0; background: transparent; font-size: 20px;
  display: grid; place-items: center;
}
.picker-arrows button + button { border-top: 1px solid var(--stroke); }
.picker-arrows button:hover { background: #3d3d3d; }

.breaks { margin-top: 26px; }

.check { margin-top: 18px; gap: 10px; align-items: center; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 20px; height: 20px; border-radius: 4px;
  border: 1px solid #8a8a8a; background: #262626;
  display: grid; place-items: center;
}
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box::after {
  content: ""; width: 10px; height: 5px; margin-top: -2px;
  border-left: 2px solid #000; border-bottom: 2px solid #000; transform: rotate(-45deg);
}
.check input:focus-visible + .box { outline: 2px solid #fff; outline-offset: 2px; }
.check.small { font-size: 13px; color: var(--sub); margin-top: 20px; }

.result { margin-top: 16px; color: var(--accent); }

/* ---------- Anéis ---------- */
.ring { position: relative; margin: 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 16; }
.ring .track { stroke: var(--track); }
.ring .arc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring.big { width: 240px; height: 240px; margin-top: 20px; margin-bottom: 14px; }
.ring-num { font-size: 56px; font-weight: 600; line-height: 1.05; }

.run-cat { font-size: 20px; font-weight: 600; margin: 6px 0 0; overflow-wrap: anywhere; }
#runTask { margin-top: 4px; }
.period { font-size: 15px; }
#nextText { margin-top: 4px; font-size: 14px; min-height: 1.4em; }
.round-btns { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.round {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: #373737; border: 1px solid #444;
}
.round:hover { background: #424242; }
.round.accent { background: var(--accent); border-color: var(--accent); color: #000; }

/* ---------- Categorias ---------- */
.categories-card .sub { margin: 10px 0; font-size: 15px; }
.field {
  width: 100%; min-height: 38px; padding: 7px 10px;
  background: #1f1f1f; border: 1px solid var(--stroke); border-radius: 4px; outline: none;
  font-size: 16px; /* evita zoom automático no iPhone */
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: #808080; }
#newCategoryForm { margin-bottom: 8px; }
.task-list { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; }
.task-list li {
  display: flex; align-items: center; gap: 10px;
  min-height: 50px; padding: 0 6px 0 12px; margin-bottom: 6px;
  background: var(--row); border: 1px solid #303030; border-radius: 4px;
  cursor: pointer; user-select: none;
}
.task-list li:hover { background: var(--row-hover); }
.task-list .mark { font-size: 21px; color: var(--sub); }
.task-list li.selected .mark { color: var(--accent); }
.task-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-list .remove { width: 32px; height: 32px; font-size: 13px; color: var(--sub); }
#taskInput { margin-top: 6px; }
.categories-card.locked { opacity: .55; pointer-events: none; }
.empty { padding: 18px 0; }

/* ---------- Progresso diário ---------- */
.daily-card { padding-bottom: 22px; }
.daily { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 18px; }
.stat { display: flex; flex-direction: column; align-items: center; margin-top: -26px; }
.stat strong, .ring-label strong { font-size: 40px; font-weight: 600; line-height: 1.15; }
.ring.goal { width: 180px; height: 180px; }
@media (max-width: 400px) {
  .ring.goal { width: 150px; height: 150px; }
  .stat strong, .ring-label strong { font-size: 32px; }
  .daily-card .ring-label span { font-size: 13px; }
}
#todayText { margin-top: 12px; }
.goal-edit { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.goal-edit .btn { min-height: 32px; padding: 4px 12px; font-size: 12px; }

/* ---------- Histórico ---------- */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 8px; }
.pill {
  padding: 4px 12px; border-radius: 14px; font-size: 13px;
  background: transparent; border: 1px solid #444; color: var(--sub);
}
.pill:hover { background: #353535; }
.pill.on { background: var(--accent); border-color: var(--accent); color: #000; }

.summary, .sessions { list-style: none; margin: 0; padding: 0; }
.summary { max-height: 190px; overflow-y: auto; }
.summary li { padding: 7px 10px; border-radius: 4px; margin: 1px 0; cursor: pointer; }
.summary li:hover { background: #323232; }
.summary li.on { background: #3a3a3a; }
.summary .top { display: flex; justify-content: space-between; gap: 12px; }
.summary .top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.summary .top span { color: var(--sub); font-size: 13px; white-space: nowrap; }
.summary .bar { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--accent); min-width: 4px; }

.list-head {
  margin: 8px 0 4px; padding-top: 10px; border-top: 1px solid var(--stroke);
  font-size: 13px; font-weight: 400; color: var(--sub);
}
.sessions { max-height: 420px; overflow-y: auto; }
.sessions li {
  display: grid; grid-template-columns: 84px 1fr auto 22px 30px; align-items: center; gap: 6px;
  padding: 7px 4px 7px 10px; border-radius: 4px;
}
.sessions li:hover { background: #323232; }
.sessions .when small, .sessions .what small { display: block; color: var(--sub); font-size: 12px; }
.sessions .what { min-width: 0; }
.sessions .what strong, .sessions .what small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions .what strong { display: block; font-weight: 600; }
.sessions .dur { white-space: nowrap; }
.sessions .status { font-size: 16px; display: grid; place-items: center; }
.sessions .status.done { color: var(--break); }
.sessions .status.cut { color: var(--warn); }
.sessions .del { width: 30px; height: 30px; font-size: 14px; color: var(--sub); }

/* ---------- Conta ---------- */
.icon-btn .sync-dot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--break);
}
.icon-btn .sync-dot.err { background: var(--warn); }
dialog {
  width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
  border: 1px solid #444; border-radius: 8px; padding: 16px 18px 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog .field { margin-top: 10px; }
dialog .row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
dialog p { margin-top: 8px; }
dialog hr { border: 0; border-top: 1px solid var(--stroke); margin: 18px 0 6px; }
.msg { min-height: 1.4em; font-size: 13px; }
.file-btn { margin-top: 10px; }
code { font-size: 12px; background: #1f1f1f; padding: 1px 4px; border-radius: 3px; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #3a3a3a; border: 1px solid #4a4a4a; border-radius: 6px;
  padding: 10px 16px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
