:root {
  --ink: #08090d;
  --panel: #101316;
  --panel-2: #181d1c;
  --paper: #f4f7f0;
  --muted: #aab3a8;
  --line: rgba(244, 247, 240, 0.14);
  --line-strong: rgba(244, 247, 240, 0.25);
  --mint: #58f2b5;
  --cyan: #4dd7ff;
  --amber: #ffbe3d;
  --coral: #ff6b7f;
  --violet: #b68cff;
  --danger: #ff6b7f;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(88, 242, 181, 0.1), transparent 34%),
    linear-gradient(245deg, rgba(255, 107, 127, 0.08), transparent 38%),
    linear-gradient(180deg, #08090d 0%, #111514 52%, #08090d 100%),
    var(--ink);
  color: var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(244, 247, 240, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 247, 240, 0.05) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

a {
  color: inherit;
}

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

img {
  display: block;
  max-width: 100%;
}

.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
}

.portfolio-shell {
  width: 100%;
  overflow: hidden;
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 900;
  white-space: nowrap;
}

.brand-mark,
.mini-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 900;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-links a:hover {
  background: rgba(244, 247, 240, 0.08);
  color: var(--paper);
}

.hero-section {
  position: relative;
  min-height: 94vh;
  display: grid;
  align-items: center;
  gap: 40px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 118px 0 44px;
}

.hero-section::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(3.35rem, 17vw, 9.4rem);
  line-height: 0.86;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 8vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.08rem;
}

.hero-lede {
  max-width: 700px;
  color: var(--paper);
  font-size: clamp(1.12rem, 4vw, 1.65rem);
  line-height: 1.35;
}

.hero-note,
.section-head > p,
.prose-block,
.timeline-item p,
.project-card p,
.stack-item p,
.contact-band p,
.mini-card p {
  color: var(--muted);
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.hero-tags span {
  border: 1px solid rgba(88, 242, 181, 0.24);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(88, 242, 181, 0.06);
  color: #dfffee;
  font-size: 0.83rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(244, 247, 240, 0.05);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-2px);
  border-color: rgba(244, 247, 240, 0.42);
  background: rgba(244, 247, 240, 0.09);
}

.button.primary {
  border-color: transparent;
  background: var(--mint);
  color: var(--ink);
  font-weight: 900;
}

.button.danger {
  border-color: rgba(255, 107, 127, 0.38);
  color: var(--danger);
}

.hero-visual {
  position: relative;
  min-height: 590px;
}

.visual-panel {
  position: relative;
  display: grid;
  gap: 14px;
}

.portrait-frame {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid rgba(244, 247, 240, 0.24);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.48);
}

.portrait-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(88, 242, 181, 0.28);
  pointer-events: none;
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 2px;
  border: 1px solid rgba(244, 247, 240, 0.18);
  border-radius: 12px;
  padding: 12px;
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(14px);
}

.portrait-caption strong,
.portrait-caption span {
  display: block;
}

.portrait-caption span {
  color: var(--muted);
  font-size: 0.82rem;
}

.featured-project {
  position: absolute;
  right: 0;
  top: 10%;
  width: min(330px, 72%);
  overflow: hidden;
  border: 1px solid rgba(244, 247, 240, 0.2);
  border-top: 3px solid var(--accent, var(--mint));
  border-radius: 16px;
  background: rgba(16, 19, 22, 0.88);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
}

.featured-project-media {
  aspect-ratio: 16 / 9;
  background: var(--panel-2);
}

.featured-project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-project div:last-child {
  padding: 14px;
}

.featured-project span {
  color: var(--accent, var(--mint));
  font-weight: 900;
  font-size: 0.82rem;
}

.featured-project h2 {
  margin: 4px 0 8px;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1;
}

.featured-project p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.project-strip {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 10px;
  width: min(58%, 280px);
}

.project-strip figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(244, 247, 240, 0.18);
  border-radius: 12px;
  background: rgba(16, 19, 22, 0.88);
}

.project-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.project-strip figcaption {
  padding: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-stats,
.section-band,
.contact-band {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 18px 0 42px;
}

.stat,
.mini-card,
.project-card,
.stack-item,
.timeline-item,
.login-panel,
.admin-panel,
.editor-column,
.edit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 22, 0.78);
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.stat::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--mint), var(--cyan), var(--coral));
  opacity: 0.72;
}

.stat-index {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.stat strong {
  display: block;
  font-size: 1.45rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-band {
  padding: 86px 0;
}

.section-head {
  display: grid;
  gap: 18px;
  margin-bottom: 34px;
}

.section-head > p {
  max-width: 650px;
  font-size: 1.03rem;
}

.about-layout {
  display: grid;
  gap: 18px;
}

.prose-block {
  padding: 22px;
  border-left: 3px solid var(--mint);
  background: linear-gradient(90deg, rgba(88, 242, 181, 0.08), transparent);
  font-size: 1.03rem;
}

.capability-grid,
.project-grid,
.stack-grid {
  display: grid;
  gap: 14px;
}

.mini-card,
.stack-item {
  padding: 18px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.mini-card:hover,
.stack-item:hover,
.project-card:hover {
  transform: translateY(-4px);
  border-color: rgba(244, 247, 240, 0.32);
  background: rgba(20, 25, 27, 0.88);
}

.mini-card .mini-icon {
  margin-bottom: 18px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 10px;
  width: 1px;
  background: linear-gradient(var(--mint), var(--amber), var(--coral));
  opacity: 0.6;
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 18px 18px 18px 34px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 5px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 0 0 5px rgba(88, 242, 181, 0.16);
}

.timeline-item > span {
  color: var(--amber);
  font-weight: 900;
}

.project-card {
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.project-media {
  aspect-ratio: 16 / 10;
  background: var(--panel-2);
  overflow: hidden;
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s ease;
}

.project-card:hover .project-media img {
  transform: scale(1.04);
}

.project-content {
  padding: 18px;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
}

.tags,
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tags span,
.project-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.accent-mint { --accent: var(--mint); }
.accent-cyan { --accent: var(--cyan); }
.accent-amber { --accent: var(--amber); }
.accent-coral { --accent: var(--coral); }
.accent-violet { --accent: var(--violet); }

.project-card,
.stack-item {
  border-top: 3px solid var(--accent, var(--mint));
}

.project-card-featured {
  display: grid;
}

.stack-item {
  position: relative;
  min-height: 180px;
}

.stack-number {
  display: block;
  margin-bottom: 28px;
  color: var(--accent, var(--mint));
  font-weight: 900;
}

.contact-band {
  display: grid;
  gap: 22px;
  align-items: center;
  margin-bottom: 34px;
  padding: 42px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(88, 242, 181, 0.14), rgba(77, 215, 255, 0.08));
}

.contact-card {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.contact-card img {
  width: 86px;
  aspect-ratio: 1;
  border: 1px solid rgba(244, 247, 240, 0.22);
  border-radius: 12px;
  object-fit: cover;
}

.contact-card span {
  color: var(--muted);
}

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 24px;
}

.login-panel form,
.editor-column,
.edit-item,
.collection-editor,
.admin-shell {
  display: grid;
  gap: 14px;
}

.admin-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 110px;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-topbar h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 9vw, 5.4rem);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.admin-tabs button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.admin-tabs button.active {
  background: var(--paper);
  color: var(--ink);
}

.admin-panel {
  padding: 14px;
}

.editor-grid {
  display: grid;
  gap: 14px;
}

.editor-column {
  padding: 16px;
}

.editor-column.wide {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(8, 9, 13, 0.72);
  color: var(--paper);
  resize: vertical;
}

.photo-editor {
  display: grid;
  gap: 10px;
}

.photo-editor img {
  width: 160px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.file-button {
  position: relative;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.cv-editor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(8, 9, 13, 0.42);
}

.cv-editor div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.cv-editor span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.cv-editor a,
.cv-editor small {
  color: var(--paper);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.edit-list {
  display: grid;
  gap: 12px;
}

.edit-item {
  padding: 14px;
}

.edit-item.compact {
  grid-template-columns: 1fr;
}

.admin-muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.guestbook-admin-list {
  display: grid;
  gap: 10px;
}

.guestbook-admin-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(8, 9, 13, 0.52);
}

.guestbook-admin-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: var(--mint);
  font-weight: 950;
}

.guestbook-admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.guestbook-admin-head strong {
  color: var(--paper);
}

.guestbook-admin-head time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.guestbook-admin-item p {
  margin: 6px 0 0;
  color: #dce5dc;
}

.guestbook-admin-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
}

.admin-savebar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  background: rgba(8, 9, 13, 0.9);
  backdrop-filter: blur(18px);
}

.admin-savebar span,
.form-error {
  color: var(--coral);
}

@media (min-width: 720px) {
  .nav-links {
    display: flex;
  }

  .hero-section {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.75fr);
  }

  .quick-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .contact-band {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .section-head,
  .about-layout,
  .timeline-item {
    grid-template-columns: 0.9fr 1.1fr;
  }

  .capability-grid,
  .project-grid,
  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .edit-item.compact {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}

@media (max-width: 640px) {
  .cv-editor {
    align-items: stretch;
    flex-direction: column;
  }

  .cv-editor .file-button {
    width: 100%;
  }

  .guestbook-admin-item {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .guestbook-admin-item .button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (min-width: 1040px) {
  .site-nav {
    padding-inline: calc((100vw - 1180px) / 2);
  }

  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-card-featured {
    grid-column: span 2;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr);
  }

  .project-card-featured .project-media {
    aspect-ratio: auto;
    min-height: 100%;
  }
}

@media (max-width: 520px) {
  .brand span:last-child {
    display: none;
  }

  .hero-section {
    min-height: auto;
    padding-top: 96px;
  }

  .portfolio-shell .hero-actions .button {
    width: auto;
    flex: 1 1 calc(50% - 10px);
  }

  .admin-actions .button {
    width: 100%;
  }

  h1 {
    font-size: 3rem;
  }

  .hero-note {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .hero-tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .hero-tags span {
    flex: 0 0 auto;
  }

  .visual-panel {
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: stretch;
  }

  .portrait-frame {
    width: 96px;
    height: 100%;
    min-height: 188px;
    aspect-ratio: auto;
  }

  .portrait-caption {
    display: none;
  }

  .project-strip {
    display: none;
  }

  .featured-project {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 0;
  }

  .featured-project-media {
    display: none;
  }

  .featured-project div:last-child {
    padding: 12px;
  }

  .featured-project h2 {
    font-size: 1.25rem;
  }

  .featured-project p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .hero-visual {
    min-height: auto;
  }
}

.workout-shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 80px;
  display: grid;
  gap: 14px;
}

.workout-login {
  min-height: 100vh;
  place-items: center;
}

.workout-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.workout-topbar h1 {
  margin-bottom: 6px;
  font-size: clamp(2.4rem, 10vw, 5.2rem);
}

.workout-topbar span {
  color: var(--muted);
}

.workout-panel,
.exercise-card,
.workout-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 19, 22, 0.78);
}

.workout-panel {
  padding: 16px;
}

.workout-controls {
  display: grid;
  gap: 14px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.day-grid button,
.suggestions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 247, 240, 0.05);
  color: var(--paper);
  cursor: pointer;
}

.day-grid button.active {
  background: var(--paper);
  color: var(--ink);
}

.strength-form,
.cardio-form,
.exercise-card,
.workout-list {
  display: grid;
  gap: 12px;
}

.exercise-card,
.workout-card {
  padding: 14px;
}

.suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.suggestions button {
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--muted);
}

.set-row,
.row-actions,
.workout-metrics {
  display: grid;
  gap: 10px;
}

.set-type-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.set-type-toggle button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(244, 247, 240, 0.04);
  font-weight: 850;
  cursor: pointer;
}

.set-type-toggle button.active {
  border-color: rgba(88, 242, 181, 0.5);
  color: var(--ink);
  background: var(--mint);
}

.workout-card {
  display: grid;
  gap: 12px;
}

.workout-card strong,
.workout-card span {
  display: block;
}

.workout-card span,
.empty-state {
  color: var(--muted);
}

.selected-exercises {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.selected-exercise {
  display: grid;
  gap: 8px;
}

.selected-exercise strong,
.selected-exercise span {
  display: block;
}

.set-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.set-chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--paper);
  font-size: 0.86rem;
}

.set-chips span.machine {
  border-color: rgba(77, 215, 255, 0.34);
}

.set-chips span.free {
  border-color: rgba(88, 242, 181, 0.42);
}

.set-chips strong {
  display: inline;
  margin-right: 6px;
  color: var(--mint);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

.history-table th {
  color: var(--muted);
  font-size: 0.85rem;
}

.history-compare-list {
  display: grid;
  gap: 6px;
}

.history-compare {
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--paper);
  background: rgba(244, 247, 240, 0.04);
  font-size: 0.88rem;
  line-height: 1.25;
}

.history-compare strong {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.history-compare small {
  color: var(--muted);
  font-size: 0.78rem;
}

.history-compare.up {
  border-color: rgba(88, 242, 181, 0.45);
  color: var(--mint);
}

.history-compare.down {
  border-color: rgba(255, 112, 112, 0.42);
  color: #ff9a9a;
}

.history-compare.same,
.history-compare.first {
  border-color: rgba(77, 215, 255, 0.34);
  color: #bdefff;
}

.history-compare.muted {
  display: inline;
  width: auto;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

@media (max-width: 640px) {
  .workout-shell {
    width: min(100% - 18px, 980px);
    gap: 12px;
    padding: 14px 0 82px;
    font-size: 16px;
  }

  .workout-topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .workout-topbar h1 {
    font-size: clamp(2.15rem, 13vw, 3.35rem);
    line-height: 0.98;
  }

  .workout-topbar .admin-actions,
  .workout-topbar .button {
    width: 100%;
  }

  .workout-panel {
    padding: 14px;
  }

  .workout-panel h2,
  .editor-head h2,
  .cardio-form h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.15;
  }

  .editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .field {
    gap: 8px;
  }

  .field span {
    font-size: 0.94rem;
  }

  .field input,
  .field textarea,
  .field select {
    min-height: 50px;
    padding: 13px 14px;
    font-size: 1.04rem;
  }

  .button,
  .day-grid button,
  .suggestions button,
  .set-type-toggle button {
    min-height: 50px;
    font-size: 1rem;
  }

  .day-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .day-grid button {
    padding: 0 8px;
    font-weight: 850;
  }

  .suggestions {
    gap: 9px;
    padding-bottom: 6px;
  }

  .suggestions button {
    padding: 0 14px;
    color: var(--paper);
  }

  .exercise-card,
  .workout-card {
    padding: 14px;
  }

  .set-row {
    gap: 12px;
    border: 1px solid rgba(244, 247, 240, 0.1);
    border-radius: 8px;
    padding: 12px;
    background: rgba(8, 9, 13, 0.38);
  }

  .set-type-toggle {
    gap: 8px;
  }

  .set-type-toggle button {
    padding: 0 8px;
    line-height: 1.15;
  }

  .row-actions {
    grid-template-columns: 1fr;
  }

  .workout-metrics {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .workout-metrics span,
  .selected-exercise span,
  .empty-state {
    font-size: 1rem;
  }

  .workout-card > div:first-child strong,
  .selected-exercise strong {
    font-size: 1.08rem;
  }

  .set-chips {
    display: grid;
    grid-template-columns: 1fr;
  }

  .set-chips span {
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 0.98rem;
    line-height: 1.25;
  }

  .set-chips strong {
    font-size: 0.82rem;
  }

  .history-table-wrap {
    overflow: visible;
  }

  .history-table,
  .history-table thead,
  .history-table tbody,
  .history-table tr,
  .history-table td {
    display: block;
    width: 100%;
  }

  .history-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .history-table thead {
    display: none;
  }

  .history-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: rgba(8, 9, 13, 0.48);
  }

  .history-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(244, 247, 240, 0.08);
    padding: 10px 2px;
    text-align: right;
    font-size: 1rem;
  }

  .history-table td[data-label="Kiyas"] {
    align-items: flex-start;
  }

  .history-table td:last-child {
    border-bottom: 0;
  }

  .history-table td::before {
    content: attr(data-label);
    color: var(--muted);
    flex: 0 0 92px;
    font-weight: 850;
    text-align: left;
  }

  .history-compare-list {
    justify-items: end;
  }

  .history-compare {
    width: min(100%, 220px);
    max-width: 220px;
    text-align: right;
  }

  .toast {
    width: calc(100% - 24px);
    text-align: center;
    font-size: 1rem;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(8, 9, 13, 0.92);
}

@media (min-width: 720px) {
  .workout-controls {
    grid-template-columns: 220px 1fr;
    align-items: end;
  }

  .day-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .set-row {
    grid-template-columns: minmax(240px, 1.15fr) minmax(110px, 0.45fr) minmax(110px, 0.45fr) auto;
    align-items: end;
  }

  .row-actions,
  .workout-metrics {
    display: flex;
    flex-wrap: wrap;
  }

  .workout-card {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
}
