@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@500;600&display=swap");

:root {
  --bg: #121418;
  --bg-elevated: #1a1d24;
  --bg-soft: #22262f;
  --border: #2e3440;
  --text: #eef1f6;
  --text-muted: #9aa3b2;
  --accent: #3ecf8e;
  --accent-dim: rgba(62, 207, 142, 0.16);
  --danger: #ff6b6b;
  --warn: #f0c14a;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(62, 207, 142, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(80, 120, 255, 0.06), transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(24px + var(--safe-bottom));
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Sticky stopwatch bar */
.timer-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(18, 20, 24, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.timer-bar.visible {
  display: flex;
}

.timer-bar .stopwatch {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.timer-bar .rest-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timer-bar .rest-countdown {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--warn);
}

.main {
  flex: 1;
  padding: 20px 16px 32px;
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 8px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.lead {
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.45;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

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

.btn-primary {
  background: var(--accent);
  color: #0b1210;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost {
  color: var(--text-muted);
  min-height: 40px;
  padding: 8px 12px;
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.btn-yes,
.btn-no {
  flex: 1;
  min-height: 88px;
  font-size: 1.35rem;
  border-radius: 18px;
}

.btn-yes {
  background: var(--accent);
  color: #0b1210;
}

.btn-no {
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field textarea {
  min-height: 160px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.4;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.list-item:hover,
.list-item:focus-visible {
  border-color: var(--accent);
  background: var(--bg-soft);
}

.list-item .title {
  font-weight: 600;
}

.list-item .meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item .actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
}

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

.banner {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  border: 1px solid rgba(62, 207, 142, 0.35);
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.banner.muted {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}

.banner.warn {
  background: rgba(240, 193, 74, 0.12);
  border-color: rgba(240, 193, 74, 0.4);
  color: var(--warn);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-tabs .tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
}

.nav-tabs .tab.active {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--border);
}

.exercise-row {
  display: grid;
  grid-template-columns: 1fr 88px 40px;
  gap: 8px;
  align-items: end;
}

.session-progress {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.big-number {
  font-family: var(--mono);
  font-size: 3.5rem;
  font-weight: 600;
  text-align: center;
  margin: 16px 0;
  color: var(--accent);
}

.rep-input {
  font-family: var(--mono);
  font-size: 2rem !important;
  text-align: center;
  font-weight: 600;
  padding: 18px !important;
}

.rest-display {
  text-align: center;
  padding: 32px 16px;
}

.rest-display .time {
  font-family: var(--mono);
  font-size: 4rem;
  font-weight: 600;
  color: var(--warn);
  line-height: 1;
}

.rest-display .hint {
  margin-top: 12px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  z-index: 100;
  transition: transform 0.25s ease;
  max-width: calc(100% - 32px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.update-banner {
  display: none;
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  gap: 12px;
  align-items: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  width: min(420px, calc(100% - 24px));
}

.update-banner.visible {
  display: flex;
}

.history-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
  display: none;
  width: 100%;
}

.history-item.open .history-details {
  display: block;
}

.history-item {
  flex-direction: column;
  align-items: stretch;
}

.history-item .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 6px;
}

.hidden {
  display: none !important;
}

.section-gap {
  margin-top: 28px;
}

.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-weight: 500;
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.minute-picks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.minute-picks .btn {
  min-height: 56px;
}
