: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 { font: inherit; color: var(--text); }
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: 10px; color: var(--muted); font-size: 13px; }
.month span::first-letter, .srow.muted span::first-letter { text-transform: uppercase; }
.month span { display: inline-block; min-width: 120px; 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: 14px; 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; }
.ctrl {
  width: 64px; height: 64px; 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: 22px; height: 22px; 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; }
.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; }
.icon-btn.side { grid-column: 3; justify-self: end; margin-right: 8px; width: 52px; height: 52px; border: 1px solid var(--border); background: var(--surface); }
.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, .row input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); outline: none; font-size: 15px;
}
.field input: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; }
.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: 2fr 1fr; gap: 12px; }
.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 110px; 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); }
.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); }

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

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-items: start; padding: 72px 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; }
  .icon-btn.side { position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; margin: 0; }
  .icon-btn.corner { top: 16px; right: 16px; }
}
