@layer base, rmx;

@layer base {
  :root {
    color: #171714;
    background: #f3f2eb;
    font-family:
      Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    font-synthesis: none;
  }

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

  html {
    min-width: 320px;
    background: #f3f2eb;
  }

  body {
    min-height: 100vh;
    margin: 0;
    background: #f3f2eb;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  button,
  input {
    font: inherit;
  }

  button,
  a {
    -webkit-tap-highlight-color: transparent;
  }

  button {
    cursor: pointer;
  }

  button:disabled {
    cursor: wait;
  }

  svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
  }

  .app-shell {
    min-height: 100vh;
  }

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

  .site-header,
  .workout-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid #dedcd2;
    background: rgb(243 242 235 / 95%);
    backdrop-filter: blur(12px);
  }

  .site-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: max-content;
    color: #171714;
    text-decoration: none;
  }

  .brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    color: #dfff44;
    background: #171714;
  }

  .brand-name {
    display: none;
    font-size: 1.125rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    text-transform: uppercase;
  }

  .clock {
    justify-self: center;
    color: #171714;
    font-family:
      "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.875rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
  }

  .local-badge {
    justify-self: end;
    border: 1px solid #d9d7cd;
    border-radius: 999px;
    padding: 0.35rem 0.6rem;
    color: #77766e;
    font-family:
      "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.625rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .logout-form {
    justify-self: end;
  }

  .logout-button {
    border: 1px solid #d9d7cd;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    color: #5f5e57;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 900;
  }

  .logout-button:active {
    color: #171714;
    background: #e8e6dd;
  }

  .login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1.25rem;
    background:
      radial-gradient(circle at top right, rgb(223 255 68 / 12%), transparent 32rem),
      #171714;
  }

  .login-card {
    display: grid;
    width: min(100%, 28rem);
    gap: 2rem;
    border: 1px solid #34342f;
    border-radius: 1.5rem;
    padding: 1.5rem;
    color: white;
    background: #20201d;
    box-shadow: 0 2rem 5rem rgb(0 0 0 / 25%);
  }

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

  .login-brand p {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    text-transform: uppercase;
  }

  .login-card h1 {
    margin: 0.5rem 0 0;
    color: white;
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    font-weight: 900;
    letter-spacing: -0.06em;
    line-height: 0.95;
  }

  .login-copy {
    margin: 1rem 0 0;
    color: #aaa9a1;
    font-size: 0.875rem;
    line-height: 1.5;
  }

  .login-form {
    display: grid;
    gap: 1rem;
  }

  .login-form label {
    display: grid;
    gap: 0.45rem;
  }

  .login-form label span {
    color: #c7c6bd;
    font-size: 0.75rem;
    font-weight: 900;
  }

  .login-form label input {
    width: 100%;
    border: 1px solid #474740;
    border-radius: 0.75rem;
    outline: none;
    padding: 0.8rem 0.9rem;
    color: white;
    background: #171714;
  }

  .login-form label input:focus {
    border-color: #dfff44;
  }

  .login-button {
    width: 100%;
    border: 0;
    border-radius: 0.75rem;
    padding: 0.9rem 1rem;
    color: #171714;
    background: #dfff44;
    font-weight: 900;
  }

  .login-error {
    margin: 0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    color: #ffcac5;
    background: rgb(180 35 24 / 18%);
    font-size: 0.8rem;
    font-weight: 700;
  }

  .dashboard {
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 1.25rem 5rem;
  }

  .hero {
    position: relative;
    overflow: hidden;
    border-radius: 0 0 2rem 2rem;
    padding: 2rem 1.5rem;
    color: white;
    background: #171714;
  }

  .hero-glow {
    position: absolute;
    top: -5rem;
    right: -3rem;
    width: 16rem;
    height: 16rem;
    border-radius: 999px;
    background: #dfff44;
    filter: blur(48px);
    opacity: 0.08;
  }

  .hero-content {
    position: relative;
    max-width: 42rem;
  }

  .eyebrow {
    margin: 0;
    color: #8a897f;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .eyebrow.accent {
    margin-bottom: 1.25rem;
    color: #dfff44;
    letter-spacing: 0.16em;
  }

  .hero h1,
  .workout-title h1,
  .section-heading h2 {
    margin: 0;
    color: #171714;
    font-weight: 900;
    letter-spacing: -0.055em;
  }

  .hero h1 {
    color: white;
    font-size: clamp(2.5rem, 8vw, 3.75rem);
    line-height: 0.98;
  }

  .hero-copy {
    max-width: 34rem;
    margin: 1.25rem 0 0;
    color: #aaa9a1;
    font-size: 0.875rem;
    line-height: 1.5rem;
  }

  .continue-button {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.75rem;
    border-radius: 1rem;
    padding: 0.875rem 1.25rem;
    color: #171714;
    background: #dfff44;
    font-size: 0.875rem;
    font-weight: 900;
    text-decoration: none;
    transition: transform 150ms ease;
  }

  .continue-button:active,
  .routine-start:active,
  .finish-button:active {
    transform: scale(0.98);
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 1.5rem 0;
  }

  .stat {
    border: 1px solid #d9d7cd;
    border-radius: 1rem;
    padding: 1rem;
    background: #f6f5ef;
  }

  .stat-wide {
    grid-column: span 2;
  }

  .stat p,
  .history-main p,
  .empty-state p {
    margin: 0;
    color: #171714;
    font-weight: 900;
  }

  .stat p {
    font-size: 1.5rem;
    letter-spacing: -0.04em;
  }

  .stat small,
  .history-main small,
  .empty-state small {
    display: block;
    margin-top: 0.25rem;
    color: #88877e;
    font-size: 0.75rem;
    font-weight: 700;
  }

  .section {
    padding: 1.25rem 0;
  }

  .history-section {
    padding-top: 2.5rem;
  }

  .section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .section-heading h2 {
    margin-top: 0.5rem;
    font-size: 1.875rem;
  }

  .schedule {
    display: none;
    color: #77766e;
    font-size: 0.875rem;
  }

  .heading-icon {
    color: #77766e;
  }

  .routine-grid {
    display: grid;
    gap: 1rem;
  }

  .routine-card {
    display: flex;
    min-height: 18rem;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid #d9d7cd;
    border-radius: 1.75rem;
    padding: 1.5rem;
    background: white;
    box-shadow: 0 8px 30px rgb(34 34 30 / 4%);
  }

  .routine-meta {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
  }

  .routine-meta > span {
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    color: #66665f;
    background: #eff0e8;
    font-size: 0.6875rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .routine-meta small {
    color: #99988f;
    font-size: 0.875rem;
    font-weight: 700;
  }

  .routine-card h3 {
    margin: 0;
    color: #171714;
    font-size: 1.875rem;
    font-weight: 900;
    letter-spacing: -0.05em;
  }

  .routine-card > div > p {
    margin: 0.5rem 0 0;
    color: #77766e;
    font-size: 0.875rem;
    line-height: 1.5rem;
  }

  .routine-start,
  .finish-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    color: white;
    background: #171714;
    font-size: 0.875rem;
    font-weight: 900;
    transition:
      transform 150ms ease,
      opacity 150ms ease;
  }

  .routine-start {
    margin-top: 2rem;
  }

  .routine-start:disabled,
  .finish-button:disabled {
    opacity: 0.72;
  }

  .accent-icon {
    color: #dfff44;
  }

  .inline-error {
    margin: 0.75rem 0 0;
    color: #a51d1d;
    font-size: 0.75rem;
    font-weight: 800;
  }

  .history-list {
    overflow: hidden;
    border: 1px solid #d9d7cd;
    border-radius: 1.5rem;
    background: white;
  }

  .history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
  }

  .history-row + .history-row {
    border-top: 1px solid #ebe9e0;
  }

  .history-main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 1rem;
  }

  .history-check {
    display: flex;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    color: #617000;
    background: #eef0e5;
  }

  .history-main > div {
    min-width: 0;
  }

  .history-main p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-link {
    color: #77766e;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
  }

  .history-link:hover {
    color: #171714;
  }

  .empty-state {
    border: 1px dashed #cbc9bf;
    border-radius: 1.5rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
  }

  .workout-header {
    z-index: 30;
  }

  .workout-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
  }

  .back-link {
    justify-self: start;
    color: #6f6e66;
    font-size: 0.875rem;
    font-weight: 900;
    text-decoration: none;
  }

  .back-link:hover {
    color: #171714;
  }

  .header-count {
    justify-self: end;
    color: #6f6e66;
    font-size: 0.75rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
  }

  .progress-track {
    height: 0.25rem;
    background: #e1dfd5;
  }

  .progress-value {
    display: block;
    height: 100%;
    background: #9fb800;
    transition: width 180ms ease;
  }

  .workout-main {
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
  }

  .workout-title {
    margin-bottom: 2rem;
  }

  .workout-title h1 {
    margin-top: 0.75rem;
    font-size: clamp(2.5rem, 10vw, 3rem);
  }

  .workout-title > p:last-child {
    margin: 0.75rem 0 0;
    color: #77766e;
    font-size: 0.875rem;
  }

  .exercise-list {
    display: grid;
    gap: 1rem;
  }

  .exercise-card {
    overflow: hidden;
    border: 1px solid #dad8ce;
    border-radius: 1.5rem;
    background: white;
  }

  .exercise-heading {
    display: flex;
    align-items: start;
    gap: 0.75rem;
    border-bottom: 1px solid #e9e7de;
    padding: 1.25rem;
  }

  .exercise-number {
    display: flex;
    width: 1.75rem;
    height: 1.75rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    color: #7e7d74;
    background: #eeece3;
    font-size: 0.75rem;
    font-weight: 900;
  }

  .exercise-number svg {
    width: 1rem;
    height: 1rem;
  }

  .exercise-number-done {
    color: #dfff44;
    background: #171714;
  }

  .exercise-heading h2 {
    margin: 0;
    color: #171714;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.25rem;
  }

  .exercise-heading p {
    margin: 0.25rem 0 0;
    color: #8b8a81;
    font-size: 0.75rem;
  }

  .sets {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .set-labels,
  .set-row {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) minmax(0, 1fr) 3rem;
    align-items: center;
    gap: 0.5rem;
  }

  .set-labels {
    padding: 0 0.5rem;
    color: #9a998f;
    font-size: 0.625rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
  }

  .set-row {
    position: relative;
    border-radius: 0.75rem;
    padding: 0.5rem;
    background: #f8f7f2;
    transition: background-color 150ms ease;
  }

  .set-row-complete {
    background: #f0f3df;
  }

  .set-index {
    color: #85847b;
    font-size: 0.875rem;
    font-weight: 900;
    text-align: center;
  }

  .set-row label {
    min-width: 0;
  }

  .set-row label input {
    width: 100%;
    min-width: 0;
    border: 1px solid #dfddd3;
    border-radius: 0.5rem;
    outline: none;
    padding: 0.625rem 0.75rem;
    color: #171714;
    background: white;
    font-size: 1rem;
    font-weight: 900;
    text-align: center;
    transition: border-color 150ms ease;
  }

  .set-row label input::placeholder {
    color: #bbb9b0;
  }

  .set-row label input:focus {
    border-color: #171714;
  }

  .set-check {
    display: flex;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7d5cb;
    border-radius: 0.75rem;
    color: transparent;
    background: white;
    transition:
      transform 120ms ease,
      color 120ms ease,
      background-color 120ms ease;
  }

  .set-check-complete {
    border-color: #171714;
    color: #dfff44;
    background: #171714;
  }

  .set-check:active {
    transform: scale(0.92);
  }

  .set-check svg {
    width: 1rem;
    height: 1rem;
  }

  .save-state {
    position: absolute;
    right: 0.3rem;
    bottom: 0.1rem;
    width: 0.75rem;
    height: 0.75rem;
    color: #89887f;
    font-size: 0.625rem;
    font-weight: 900;
    line-height: 0.75rem;
    text-align: center;
  }

  .save-state-failed {
    color: #b42318;
  }

  .save-state-saved {
    color: #617000;
  }

  .finish-form {
    margin-top: 1.5rem;
  }

  .finish-button {
    justify-content: center;
  }

  @media (min-width: 640px) {
    .site-header-row {
      padding-inline: 2rem;
    }

    .brand-name {
      display: inline;
    }

    .login-card {
      padding: 2rem;
    }

    .dashboard {
      padding-inline: 2rem;
    }

    .hero {
      padding: 3rem 2.5rem;
    }

    .hero-copy {
      font-size: 1rem;
    }

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

    .stat {
      padding: 1.25rem;
    }

    .stat-wide {
      grid-column: auto;
    }

    .schedule {
      display: inline;
    }

    .routine-card {
      padding: 1.75rem;
    }

    .workout-title h1 {
      font-size: 3rem;
    }
  }

  @media (min-width: 768px) {
    .routine-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      scroll-behavior: auto !important;
      transition-duration: 0.01ms !important;
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
    }
  }
}
