:root {
  --bg: #0f1419;
  --bg-elev: #1a222c;
  --bg-soft: #243040;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3f7;
  --muted: #8b9aab;
  --work: #3ecf8e;
  --work-dim: rgba(62, 207, 142, 0.15);
  --break: #f0a35e;
  --break-dim: rgba(240, 163, 94, 0.15);
  --danger: #ef6b6b;
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(62, 207, 142, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 163, 94, 0.1), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input {
  font: inherit;
  color: inherit;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem calc(2rem + var(--safe-b));
  display: grid;
  gap: 1.25rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.65rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--work), #1f9d66);
  color: #04140c;
  font-weight: 700;
  font-size: 1.05rem;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem;
}

.nav-btn,
.day-label {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

.nav-btn:hover,
.day-label:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.day-label {
  min-width: 7.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.total {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.total-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.total-value {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--work);
}

.total-value.muted {
  color: var(--break);
}

.timer-panel {
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
    var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: 1.75rem 1.25rem 1.5rem;
}

.status {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.timer-panel.working .status { color: var(--work); }
.timer-panel.breaking .status { color: var(--break); }

.clock {
  font-family: var(--mono);
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.55rem;
  font-variant-numeric: tabular-nums;
}

.status-hint {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.35rem;
  min-height: 1.3em;
}

.main-btn {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--work);
  color: #04140c;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.main-btn:active {
  transform: scale(0.98);
}

.main-btn.pause {
  background: var(--break);
  color: #1a0f04;
}

.entries-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.entries-head h2 {
  font-size: 1rem;
  font-weight: 600;
}

.entries-head span {
  color: var(--muted);
  font-size: 0.85rem;
}

.entries-list {
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.entry:hover {
  background: var(--bg-soft);
}

.entry-badge {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.entry.work .entry-badge {
  background: var(--work-dim);
  color: var(--work);
}

.entry.break .entry-badge {
  background: var(--break-dim);
  color: var(--break);
}

.entry-meta {
  min-width: 0;
}

.entry-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.entry-duration {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.entry.live {
  border-color: rgba(62, 207, 142, 0.35);
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.12);
}

.entry.live.break {
  border-color: rgba(240, 163, 94, 0.35);
  box-shadow: inset 0 0 0 1px rgba(240, 163, 94, 0.12);
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 1rem 0.25rem;
}

.empty.hidden,
.hidden {
  display: none;
}

.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 2rem);
  width: 420px;
}

.dialog::backdrop {
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(4px);
}

.dialog-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem;
  display: grid;
  gap: 0.9rem;
  color: var(--text);
}

.dialog-card h3 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.dialog-card > p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: -0.35rem;
}

.dialog-card label,
.reason-field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.reason-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.reason-chips:empty {
  display: none;
}

.reason-chip {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.reason-chip:hover {
  background: var(--bg-soft);
}

.reason-chip.active {
  background: var(--break-dim);
  border-color: rgba(240, 163, 94, 0.55);
  color: var(--break);
}

.reason-chip.custom-used {
  border-style: dashed;
}

.dialog-card input[type="text"],
.dialog-card input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  outline: none;
}

.dialog-card input:focus {
  border-color: rgba(62, 207, 142, 0.55);
}

.duration-inputs {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.duration-inputs span {
  color: var(--muted);
  font-size: 0.85rem;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.dialog-actions-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--work);
  color: #04140c;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.btn.danger {
  background: rgba(239, 107, 107, 0.15);
  color: var(--danger);
}

@media (max-width: 380px) {
  .dialog-actions {
    flex-wrap: wrap;
  }

  .dialog-actions-right {
    width: 100%;
    justify-content: flex-end;
  }
}
