:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2740;
  --text: #e7edf5;
  --muted: #93a1b5;
  --accent: #14b8a6;
  --accent-strong: #0f766e;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #263349;
  --radius: 12px;
  --gap: 0.75rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  padding: 1rem 1rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-strong), transparent);
}

.app-title {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
}

.app-tagline {
  margin: 0.15rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.app-footer {
  padding: 0.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Banner (errors / success) */
.banner {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.banner--error { background: rgba(239, 68, 68, 0.12); border-color: var(--danger); color: #fecaca; }
.banner--success { background: rgba(34, 197, 94, 0.12); border-color: var(--success); color: #bbf7d0; }

/* Views */
.view { display: flex; flex-direction: column; gap: var(--gap); }
.view h2 { margin: 0.25rem 0; }
.view h3 { margin: 1rem 0 0.25rem; font-size: 1rem; color: var(--muted); }

.muted { color: var(--muted); }
.error { color: #fecaca; }

/* Forms */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

input {
  flex: 1 1 6rem;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.unit { color: var(--muted); font-size: 0.85rem; flex: 0 0 auto; }

.btn {
  flex: 0 0 auto;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #04211d;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:hover { background: #0fcdb8; }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.btn--ghost { background: transparent; color: var(--accent); align-self: flex-start; padding-left: 0; }
.btn--ghost:hover { background: transparent; text-decoration: underline; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #dc2626; }
.btn--small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Exercise list */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.list__item:hover { background: var(--surface-2); border-color: var(--accent); }
.list__item:focus-visible { outline: 2px solid var(--accent); }
.list__text {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
}
.list__name { font-weight: 600; }
.list__meta { color: var(--muted); font-size: 0.8rem; }
.list__delete { flex: 0 0 auto; }

/* Personal best */
.pb {
  margin: 0;
  padding: 0.6rem 0.85rem;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius);
  font-weight: 600;
}

/* Target suggestion */
.target {
  padding: 0.85rem;
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
}
.target h3 { margin-top: 0; color: var(--accent); }
.target__readout { margin: 0.5rem 0 0; font-weight: 600; }

/* History table */
.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.history th, .history td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.history th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.history tr:last-child td { border-bottom: none; }
.history__actions { text-align: right; width: 1%; white-space: nowrap; }

/* Motivational pictures */
.motivation {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.motivation h2 { margin: 0; font-size: 1.1rem; }
.motivation__msg { margin: 0; font-size: 0.9rem; }
.motivation__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.motivation__img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: #000;
}
.motivation__caption {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-word;
}
.motivation__caption a { color: var(--accent); }
.motivation__count { color: var(--muted); font-size: 0.8rem; }

/* Raw dump for unreadable store */
.raw {
  max-height: 12rem;
  overflow: auto;
  padding: 0.6rem;
  background: #000;
  border-radius: var(--radius);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 420px) {
  .list__meta { font-size: 0.72rem; }
}
