:root {
  --bg: #090a0c;
  --card: #121417;
  --card-2: #171a1f;
  --text: #f2f4f8;
  --muted: #99a1ae;
  --accent: #ff2f43;
  --accent-soft: #381116;
  --border: #242a33;
  --ok: #4ce07a;
  --radius: 18px;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, #191e29 0%, transparent 50%),
    radial-gradient(circle at 100% 80%, #20080c 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
}

.is-hidden {
  display: none !important;
}

.card {
  background: linear-gradient(160deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-gate {
  width: min(100%, 520px);
  margin: 2.2rem auto 0;
  padding: 1.2rem;
}

.auth-gate h2 {
  margin: 0.24rem 0 0.5rem;
}

.auth-status {
  margin: 0;
  color: var(--muted);
}

.auth-actions {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.auth-btn {
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #cc1d31, var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
  padding: 0 1rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 47, 67, 0.35);
}

.auth-btn:hover,
.auth-btn:focus-visible {
  filter: brightness(1.08);
}

.auth-btn-secondary {
  border: 1px solid #343c49;
  background: #121923;
  box-shadow: none;
  color: #dbe2ef;
}

.auth-btn-secondary:hover,
.auth-btn-secondary:focus-visible {
  border-color: var(--accent);
  color: #fff;
  filter: none;
}

.user-label {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.app-header {
  padding: 1.15rem;
  position: relative;
}

.menu-wrap {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #303743;
  background: #0f141c;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 160ms ease;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 99px;
  background: #e6ebf3;
  transition: transform 160ms ease;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.18);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 162px;
  padding: 0.38rem;
  display: grid;
  gap: 0.35rem;
  border: 1px solid #302026;
  border-radius: 12px;
  background: #12161d;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 170ms ease, transform 170ms ease;
  z-index: 12;
}

.menu-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.7rem, 7vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.3rem 0 1rem;
  color: var(--muted);
}

.progress-wrap {
  display: grid;
  gap: 0.4rem;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #d31a2d 0%, var(--accent) 55%, #ff596a 100%);
  box-shadow: 0 0 16px rgba(255, 47, 67, 0.6);
  transition: width 280ms ease;
}

.list-section {
  padding: 1rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.section-head-stack {
  display: grid;
  gap: 0.65rem;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

.tab-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.tab-btn {
  border: 1px solid #2a3140;
  background: #0f141d;
  color: #c9d0dd;
  border-radius: 10px;
  min-height: 36px;
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 160ms ease;
}

.tab-btn:hover,
.tab-btn:focus-visible {
  border-color: var(--accent);
  color: #fff;
}

.tab-btn.is-active {
  border-color: #a31727;
  background: #2a1318;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.14);
}

.menu-item {
  width: 100%;
  text-align: left;
  border: 1px solid #3b2428;
  background: #171015;
  color: #ffd7db;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 0.65rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 150ms ease;
}

.menu-item:hover,
.menu-item:focus-visible {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.18);
}

.menu-item[aria-pressed="true"] {
  border-color: #a31727;
  background: #2a1318;
  color: #fff;
}

.exercise-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.exercise-item {
  padding: 0.65rem;
  display: grid;
  gap: 0.6rem;
  transition: transform 180ms ease, border-color 180ms ease;
}

.exercise-item:focus-within {
  border-color: #3c4554;
  transform: translateY(-1px);
}

.item-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: center;
}

.check-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.item-check {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.custom-check {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  border: 2px solid #4f5a6a;
  background: #0d1117;
  transition: all 180ms ease;
}

.item-check:checked + .custom-check {
  background: linear-gradient(140deg, #d31a2d, var(--accent));
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(255, 47, 67, 0.45);
}

.item-input {
  width: 100%;
  background: #0e1218;
  border: 1px solid #28303b;
  color: var(--text);
  border-radius: 12px;
  padding: 0.66rem 0.7rem;
  font: inherit;
}

.item-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.18);
}

.item-checked .item-input {
  color: #9fa6b2;
  text-decoration: line-through;
}

.item-actions {
  display: none;
  justify-content: flex-end;
  gap: 0.42rem;
}

.icon-btn {
  border: 1px solid #2e3642;
  background: #121822;
  color: #dbe1ea;
  border-radius: 10px;
  min-width: 36px;
  min-height: 34px;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--accent);
  color: #fff;
}

.remove-btn:hover,
.remove-btn:focus-visible {
  background: #2a1014;
}

.add-form {
  margin-top: 0.85rem;
  display: none;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

.app-shell.edit-mode .add-form {
  display: grid;
}

.app-shell.edit-mode .item-actions {
  display: flex;
}

.app-shell.edit-mode .complete-btn {
  display: none;
}

.item-input[readonly] {
  background: #121720;
  border-color: #242b36;
  color: #d9dee7;
  box-shadow: none;
}

.item-input[readonly]:focus {
  border-color: #242b36;
  box-shadow: none;
}

.add-form input {
  background: #0c1016;
  border: 1px solid #293140;
  border-radius: 12px;
  color: var(--text);
  padding: 0.72rem;
  font: inherit;
}

.add-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.add-form button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #cc1d31, var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0 1rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 47, 67, 0.35);
}

.add-form button:hover,
.add-form button:focus-visible {
  filter: brightness(1.08);
}

.complete-btn {
  margin-top: 0.75rem;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #cc1d31, var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(255, 47, 67, 0.35);
}

.complete-btn:hover,
.complete-btn:focus-visible {
  filter: brightness(1.08);
}

.complete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.stats-chart-wrap {
  width: 100%;
  height: 260px;
  border: 1px solid #242b36;
  border-radius: 12px;
  background: #0d1118;
  padding: 0.55rem 0.45rem 0.3rem;
}

.stats-empty {
  margin: 0.65rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}

.stats-summary {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.25rem;
}

.stats-summary p {
  margin: 0;
  color: #dde4f0;
  font-size: 0.87rem;
}

.history-item {
  border: 1px solid #27303d;
  background: #0d1219;
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}

.history-item:hover,
.history-item:focus-visible {
  border-color: #3b4659;
  transform: translateY(-1px);
}

.history-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.2);
}

.history-details {
  min-width: 0;
}

.history-time {
  margin: 0;
  font-weight: 600;
  color: #e8edf7;
}

.history-meta {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.history-empty {
  color: var(--muted);
  text-align: center;
  cursor: default;
  transform: none;
}

.history-delete-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid #3b2428;
  background: #171015;
  color: #ffd7db;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 150ms ease;
}

.history-delete-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.history-delete-btn:hover,
.history-delete-btn:focus-visible {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.18);
}

.completion-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
  z-index: 30;
}

.completion-overlay.show {
  opacity: 1;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 10, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 40;
}

.history-details-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 10, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 41;
}

.history-details-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.history-details-card {
  width: min(94vw, 520px);
  max-height: 84vh;
  overflow: auto;
  padding: 1rem;
}

.history-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.history-details-title {
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
}

.history-details-close-btn {
  border: 1px solid #2d3542;
  background: #141b25;
  color: #e6ebf3;
  border-radius: 10px;
  min-height: 34px;
  padding: 0 0.8rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.history-details-close-btn:hover,
.history-details-close-btn:focus-visible {
  border-color: var(--accent);
  color: #fff;
}

.history-details-summary {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-detail-section {
  margin-top: 0.9rem;
}

.history-detail-label {
  margin: 0;
  font-size: 0.84rem;
  color: #cfd6e2;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.history-detail-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.history-detail-item {
  border: 1px solid #27303d;
  background: #0d1219;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  color: #e9eef8;
  font-size: 0.88rem;
}

.history-detail-empty {
  color: var(--muted);
}

.confirm-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.confirm-card {
  width: min(92vw, 420px);
  padding: 1rem;
}

.confirm-title {
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}

.confirm-message {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.confirm-actions {
  margin-top: 0.9rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.confirm-btn {
  border: 1px solid #2d3542;
  background: #141b25;
  color: #e6ebf3;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
}

.confirm-btn:hover,
.confirm-btn:focus-visible {
  border-color: var(--accent);
  color: #fff;
}

.confirm-btn.danger {
  border-color: #4a1f25;
  background: #2a1116;
  color: #ffd7db;
}

.confirm-btn.danger:hover,
.confirm-btn.danger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 47, 67, 0.18);
}

.completion-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 47, 67, 0.26) 0%, rgba(0, 0, 0, 0.84) 60%);
  animation: pulseGlow 1300ms ease-in-out infinite;
}

.completion-card {
  position: relative;
  background: rgba(12, 15, 20, 0.9);
  border: 1px solid #3a1b20;
  border-radius: 20px;
  padding: 1.2rem 1.4rem;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 47, 67, 0.26);
  transform: scale(0.88);
  animation: popIn 400ms ease forwards;
  max-width: 88vw;
}

.completion-label {
  margin: 0;
  color: #ff8f9c;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.completion-card h2 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.3rem, 6vw, 2rem);
}

.particle-field {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff8c99 0%, var(--accent) 65%, #99131f 100%);
  opacity: 0;
  animation: burst 950ms ease-out forwards;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes burst {
  0% {
    transform: translate(0, 0) scale(0.4);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.2);
    opacity: 0;
  }
}

@keyframes popIn {
  to {
    transform: scale(1);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.9;
  }
  50% {
    opacity: 1;
  }
}

@media (min-width: 680px) {
  .app-shell {
    padding: 1.5rem;
    gap: 1.2rem;
  }

  .app-header,
  .list-section {
    padding: 1.2rem 1.3rem;
  }

  .exercise-item {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .item-actions {
    padding-left: 0.5rem;
  }
}
