:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1a1a1d;
  --border: #26262a;
  --text: #ededef;
  --muted: #85858c;
  --accent: #ff5a4e;
  --accent-soft: rgba(255, 90, 78, 0.12);
  --radius: 14px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
select { appearance: none; cursor: pointer; padding-right: 36px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2385858c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
select option, select optgroup { background: var(--surface-2); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85em; }
a { color: var(--text); }

/* layout */
.app { position: relative; height: 100dvh; display: grid; grid-template-columns: 260px 1fr 260px; align-items: center; padding: 32px; }
.projects { align-self: center; max-height: calc(100dvh - 64px); overflow-y: auto; padding: 4px; }
.projects ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.project {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); text-align: left; transition: border-color .15s, background .15s;
}
.project:hover { background: var(--surface-2); }
.project.active { border-color: var(--accent); background: var(--accent-soft); }
.project .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project .meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.project.running .meta::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; animation: pulse 1.6s infinite; }
.project.add { justify-content: center; color: var(--muted); border-style: dashed; background: transparent; font-size: 18px; padding: 11px; }
.project.add:hover { color: var(--text); }
.new-project input { width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--surface); outline: none; }

.center { grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 28px; min-width: 0; }
.month { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 16px; }
.month span::first-letter, .srow.muted span::first-letter { text-transform: uppercase; }
.month span { display: inline-block; min-width: 160px; text-align: center; }
.timer-view, .notes-view { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.project-title { color: var(--muted); font-size: 18px; letter-spacing: .02em; }
.clock { font-size: clamp(56px, 9vw, 112px); font-weight: 200; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.is-running .clock { color: var(--text); text-shadow: 0 0 40px rgba(255, 90, 78, .18); }
.controls { display: flex; gap: 18px; }
.running-note {
  width: min(420px, 100%); padding: 8px 12px; text-align: center; font-size: 15px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; outline: none; color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.running-note::placeholder { color: #55555b; }
.running-note:hover { border-color: var(--border); }
.running-note:focus { border-color: var(--border); background: var(--surface); color: var(--text); }
.is-running .running-note { color: var(--text); }
.ctrl {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); transition: transform .1s, border-color .15s, opacity .15s;
}
.ctrl svg { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.ctrl:hover:not(:disabled) { border-color: var(--muted); }
.ctrl:active:not(:disabled) { transform: scale(.96); }
.ctrl:disabled { opacity: .3; cursor: default; }
.ctrl.play:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.is-running .ctrl.play { background: transparent; border-color: var(--accent); color: var(--accent); }
.amount { font-size: 26px; font-weight: 300; font-variant-numeric: tabular-nums; }
.is-running .amount { color: var(--accent); }
.month-total { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.notes-view textarea {
  width: min(640px, 100%); height: min(56dvh, 520px); resize: none; padding: 20px; line-height: 1.6;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); outline: none;
}
.notes-view textarea:focus { border-color: #3a3a40; }

.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); transition: color .15s, background .15s; }
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.icon-btn:disabled { opacity: .25; cursor: default; }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 16px; }
.icon-btn.corner { position: absolute; top: 24px; right: 24px; }
.side-tools { grid-column: 3; justify-self: end; margin-right: 8px; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); }
.icon-btn.side { width: 48px; height: 48px; }
.icon-btn.side.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.side svg { width: 24px; height: 24px; }

/* login */
.login { height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 16px; }
.brand { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 8px; }
.brand span { color: var(--accent); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .row input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background-color: var(--surface); outline: none; font-size: 15px;
}
.field input:focus, .field select:focus, .row input:focus { border-color: var(--accent); }
.btn { padding: 11px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; min-height: 1em; }

/* settings sheet */
.sheet {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 24px; border-radius: 18px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.sheet h2 { margin: 0; font-size: 18px; font-weight: 600; }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.tab { flex: 1; padding: 8px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; transition: color .15s, background .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.tab-panel { min-height: 220px; }
.tab-panel .row { margin-top: 14px; }
.sheet h3 { margin: 28px 0 10px; font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field input, .field select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.wide { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row input { flex: 1; min-width: 0; }
.summary { display: grid; gap: 2px; font-variant-numeric: tabular-nums; font-size: 14px; }
.srow { display: grid; grid-template-columns: 1fr 70px auto; gap: 8px; padding: 6px 0; }
.srow span:not(:first-child) { text-align: right; }
.srow.muted { color: var(--muted); font-size: 12px; }
.srow.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; font-weight: 500; }
.new-token { display: grid; gap: 6px; margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.new-token code { word-break: break-all; user-select: all; }
.tokens { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.tokens li { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.tokens small { color: var(--muted); }
.toggles { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.toggles label { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; cursor: pointer; }
.switch { appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.srow.out { color: var(--muted); }
.srow small { font-size: 11px; opacity: .8; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }

.menu { position: fixed; z-index: 10; min-width: 150px; padding: 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); box-shadow: 0 12px 32px rgba(0, 0, 0, .5); display: grid; }
.menu button { text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; }
.menu button:hover { background: var(--surface); }
.menu .danger { color: var(--accent); }

.entries-view { width: min(680px, 100%); display: flex; flex-direction: column; gap: 14px; }
.entries-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.entries-head .project-title::first-letter { text-transform: uppercase; }
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: min(58dvh, 560px); overflow-y: auto; }
.entry {
  display: grid; grid-template-columns: auto 1fr auto auto; column-gap: 14px; row-gap: 4px; align-items: center;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color .15s;
}
.entry:hover, .entry:focus-visible { border-color: var(--muted); outline: none; }
.entry.running { cursor: default; border-color: var(--accent); }
.entry .e-date { text-transform: capitalize; color: var(--muted); }
.entry .e-note { grid-row: 2; grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .e-note:empty { display: none; }
.entry .e-dur, .entry .e-amt { text-align: right; }
.entry .e-amt { min-width: 84px; }
.entries .empty { padding: 24px; text-align: center; }
.sheet.narrow { width: min(440px, calc(100vw - 32px)); overflow-x: hidden; }
.entry-actions { justify-content: space-between; margin-top: 4px; }
.danger-text { color: var(--accent); }
.field input[type="date"], .field input[type="time"] { color-scheme: dark; }

/* tela grande: timer à esquerda, notas do projeto à direita */
.app.split { grid-template-columns: 240px minmax(0, 1fr) auto; column-gap: 40px; }
.app.split .center { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: 1fr auto auto 1fr; column-gap: 56px; row-gap: 28px; align-items: center; height: min(100%, 680px); align-self: center; }
.app.split .month { grid-column: 1; grid-row: 2; justify-self: center; }
.app.split .timer-view { grid-column: 1; grid-row: 3; }
.app.split .notes-view { grid-column: 2; grid-row: 1 / -1; align-self: stretch; gap: 8px; align-items: stretch; }
.app.split #notes-title { display: none; }
.app.split .notes-view textarea { width: 100%; height: auto; flex: 1; }
.app.split .notes-view .hint { text-align: right; }
.app.split .side-tools { grid-column: 3; margin-right: 0; }

@keyframes pulse { 50% { opacity: .3; } }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-items: start; padding: 88px 16px 16px; gap: 24px; }
  .projects { max-height: none; overflow-x: auto; }
  .projects ul { display: flex; margin: 0; }
  .projects { display: flex; gap: 8px; }
  .project { white-space: nowrap; width: auto; padding: 10px 14px; }
  .new-project input { width: 160px; padding: 10px 14px; }
  .center { grid-column: 1; align-self: center; }
  .side-tools { position: absolute; top: 16px; left: 16px; flex-direction: row; gap: 8px; margin: 0; }
  .icon-btn.side { width: 44px; height: 44px; }
  .icon-btn.corner { top: 16px; right: 16px; }
}
