:root {
  --forest-olive: #2F3A2E;
  --soft-sage: #7D8A77;
  --warm-cream: #FCF8F1;
  --brushed-brass: #B79B5B;
  --text-primary: #2F3A2E;
  --text-muted: #7D8A77;
  --card-bg: #FFFDFA;
  --line-soft: #F3EBDD;
  --line-mid: #E4D6BE;
  --danger: #B54A3A;
  --cell-size: 14px;
  --row-height: var(--cell-size);
  --cell-gap: 2px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: auto;
  background: linear-gradient(160deg, rgba(255, 253, 250, 0.99) 0%, rgba(252, 248, 241, 0.98) 58%, rgba(183, 155, 91, 0.1) 100%), var(--warm-cream);
  background-attachment: fixed;
  color: var(--text-primary);
}

#app {
  min-height: 100vh;
}

.step {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.step.active {
  display: flex;
}

.step-content {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.step-content.card {
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(183, 155, 91, 0.12);
  text-align: center;
  border: 3px solid var(--brushed-brass);
  max-width: 480px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.step-content h1 {
  font-size: 2.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--forest-olive), var(--brushed-brass));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.step-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--forest-olive);
}

.guest-intro {
  margin-bottom: 1.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(183, 155, 91, 0.45);
  border-radius: 14px;
  background: rgba(255, 253, 250, 0.95);
  text-align: left;
}

.guest-intro h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  color: var(--forest-olive);
  font-weight: 800;
}

.guest-intro p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.guest-intro .guest-note {
  margin-top: 0.45rem;
  color: var(--soft-sage);
  font-weight: 600;
}

.tagline {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: stretch;
}

.form input {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: #FFFCF8;
  border: 2px solid var(--soft-sage);
  border-radius: 16px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.form input:focus {
  outline: none;
  border-color: var(--brushed-brass);
  box-shadow: 0 0 0 6px rgba(183, 155, 91, 0.28);
}

.form input::placeholder {
  color: #AA9F8A;
}

.form button {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  background: linear-gradient(135deg, var(--forest-olive) 0%, var(--soft-sage) 100%);
  border: none;
  border-radius: 16px;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(183, 155, 91, 0.24);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hidden {
  display: none !important;
}

.auth-switch {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--brushed-brass);
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.guest-btn {
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--forest-olive);
  background: transparent;
  border: 1px solid rgba(125, 138, 119, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.guest-btn:hover {
  background: rgba(183, 155, 91, 0.14);
  border-color: var(--brushed-brass);
}

.auth-error {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--danger);
  min-height: 1.2em;
}

.verify-hint {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.code-timer {
  font-size: 0.9rem;
  color: var(--forest-olive);
  font-weight: 600;
  margin-bottom: 1rem;
}

.code-timer.expired {
  color: var(--danger);
}

#verify-code {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
}

.resend-btn {
  background: none;
  border: none;
  color: var(--brushed-brass);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0;
  transition: opacity 0.2s;
}

.resend-btn:disabled {
  color: #aaa;
  cursor: not-allowed;
}

.resend-btn:not(:disabled):hover {
  text-decoration: underline;
}

.form button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(183, 155, 91, 0.3);
}

/* Matrix */
#step-matrix {
  display: none;
  padding: 0;
  background: var(--warm-cream);
}

#step-matrix.active {
  display: block;
}

.matrix-header {
  position: sticky;
  top: 0;
  z-index: 950;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.82rem 1.15rem;
  background: var(--warm-cream);
  border-bottom: 1px solid rgba(125, 138, 119, 0.2);
  backdrop-filter: blur(4px);
}

.matrix-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.matrix-header-logo {
  display: inline-block;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: clamp(1.3rem, 2.1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--forest-olive);
  line-height: 1;
}

.account-btn {
  margin: 0;
  height: 40px;
  padding: 0 0.8rem;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 650;
  color: var(--forest-olive);
  background: rgba(183, 155, 91, 0.14);
  border: 1px solid rgba(183, 155, 91, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(183, 155, 91, 0.12);
}

.account-btn:hover {
  background: rgba(183, 155, 91, 0.2);
}

.premium-header-btn {
  margin: 0;
  height: 40px;
  padding: 0 0.8rem;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 650;
  color: var(--forest-olive);
  background: rgba(183, 155, 91, 0.14);
  border: 1px solid rgba(183, 155, 91, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.premium-header-btn:hover {
  background: rgba(183, 155, 91, 0.2);
}

.header-menu {
  position: relative;
  margin: 0;
}

.menu-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(183, 155, 91, 0.45);
  border-radius: 10px;
  background: rgba(183, 155, 91, 0.12);
  color: var(--forest-olive);
  font-size: 1.18rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-btn:hover {
  background: rgba(183, 155, 91, 0.2);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: #FFFDFA;
  border: 1px solid rgba(183, 155, 91, 0.45);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(183, 155, 91, 0.18);
  padding: 0.4rem;
  z-index: 1100;
}

.menu-dropdown a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--forest-olive);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
}

.menu-dropdown a:hover {
  background: rgba(183, 155, 91, 0.16);
}

.matrix-container {
  width: 100%;
  max-width: none;
  margin: 0;
  background: inherit;
  padding: 2rem;
  border-radius: 0;
  box-shadow: none;
  text-align: center;
}

.logo {
  display: block;
  max-width: 600px;
  height: auto;
  margin: 0 auto 1rem;
}

.step-content .logo {
  max-width: 350px;
}

#matrix-title {
  font-size: clamp(1.6rem, 2.3vw, 2.2rem);
  margin-bottom: 0.55rem;
  text-align: center;
  color: var(--forest-olive);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.lived-stats {
  font-size: clamp(0.98rem, 1.3vw, 1.08rem);
  color: var(--text-primary);
  margin: 0.55rem auto 1.15rem;
  line-height: 1.5;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 550;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(125, 138, 119, 0.34);
  background: rgba(255, 253, 250, 0.94);
}

.lived-stats strong {
  color: var(--forest-olive);
  font-weight: 800;
}

.stats-separator {
  margin: 0 0.52rem;
  color: var(--brushed-brass);
  font-weight: 700;
}

.matrix-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--forest-olive);
  margin-bottom: 1rem;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(183, 155, 91, 0.4);
  background: rgba(183, 155, 91, 0.12);
  letter-spacing: 0.01em;
  font-weight: 650;
}

.matrix-wrapper {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line-mid);
  border-radius: 16px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: 0 8px 22px rgba(183, 155, 91, 0.14);
}

.matrix-wrapper::-webkit-scrollbar {
  display: none;
}

#matrix {
  display: grid;
  grid-template-columns: repeat(52, var(--cell-size));
  grid-auto-rows: var(--cell-size);
  gap: var(--cell-gap);
  background: var(--line-soft);
  border: 2px solid var(--line-mid);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
  min-width: calc(52 * var(--cell-size) + 51 * var(--cell-gap));
}

.matrix-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  min-width: var(--cell-size);
  min-height: var(--cell-size);
  background: #FAF4E9;
  border-radius: 2px;
}

.matrix-cell.clickable-cell {
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.matrix-cell.clickable-cell:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(183, 155, 91, 0.65);
}

.matrix-cell.clickable-cell:active {
  transform: translateY(0);
}

.matrix-cell.filled {
  background: linear-gradient(135deg, var(--forest-olive), #465345);
}

.matrix-cell.current-week {
  background: var(--brushed-brass);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.85);
}

.matrix-cell.current-age-row {
  filter: saturate(1.06);
}

.matrix-cell.birthday-cell {
  box-shadow: 0 0 0 2px var(--brushed-brass);
}

.matrix-inner {
  position: relative;
}

.matrix-target-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 280px;
  min-width: 190px;
  padding: 0.52rem 0.65rem 0.58rem;
  border-radius: 12px;
  border: 1px solid rgba(183, 155, 91, 0.5);
  background: rgba(255, 253, 250, 0.98);
  color: var(--forest-olive);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(183, 155, 91, 0.2);
  pointer-events: none;
  z-index: 20;
  text-align: left;
}

.matrix-target-tooltip.hidden {
  display: none;
}

.matrix-target-tooltip-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.matrix-target-tooltip-icon {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #C58A35, #9E6F2F);
  box-shadow: 0 0 0 1px rgba(255, 253, 250, 0.85);
}

.matrix-target-tooltip-chip {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9E6F2F;
  background: rgba(183, 155, 91, 0.13);
  border: 1px solid rgba(183, 155, 91, 0.35);
  border-radius: 999px;
  padding: 0.1rem 0.38rem;
}

.matrix-target-tooltip-title {
  margin: 0 0 0.24rem;
  color: var(--forest-olive);
  font-size: 0.8rem;
  font-weight: 700;
}

.matrix-target-tooltip-meta {
  margin: 0;
  color: var(--soft-sage);
  font-size: 0.74rem;
  font-weight: 600;
}

.matrix-target-tooltip-meta-secondary {
  margin: 0.2rem 0 0;
  color: #9E6F2F;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.35;
}

#year-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.year-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(125, 138, 119, 0.34);
}

.year-guide.decade {
  height: 2px;
  background: rgba(183, 155, 91, 0.48);
}

.year-guide.current-age-guide {
  height: 2px;
  background: rgba(183, 155, 91, 0.72);
}

#year-scale {
  position: relative;
  width: 90px;
  min-width: 90px;
  flex-shrink: 0;
  padding-left: 16px;
  height: calc(100 * (var(--row-height) + var(--cell-gap)) - var(--cell-gap));
  border-left: 2px solid rgba(183, 155, 91, 0.5);
}

.year-label {
  position: absolute;
  left: 16px;
  width: 68px;
  height: calc(var(--row-height) + var(--cell-gap));
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--forest-olive);
  letter-spacing: 0.02em;
}

.year-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #EFE5D3;
  border: 1px solid var(--soft-sage);
  position: absolute;
  left: -18px;
}

.year-label.milestone {
  color: var(--warm-cream);
  background: linear-gradient(135deg, var(--forest-olive), #465345);
  border-radius: 999px;
  border: 1px solid rgba(244, 239, 230, 0.25);
  font-weight: 700;
  min-height: 16px;
}

.year-label.current-age {
  color: var(--forest-olive);
  font-weight: 700;
  background: var(--brushed-brass);
  border: 1px solid rgba(183, 155, 91, 0.35);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(183, 155, 91, 0.35);
}

.year-label.current-age::before {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--brushed-brass);
  border: 1px solid var(--forest-olive);
}

.matrix-legend {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 1.1rem auto 0;
  padding: 0.45rem;
  border: 1px solid var(--line-mid);
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.92);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.62rem;
  border-radius: 999px;
  background: #FFFCF8;
  border: 1px solid rgba(125, 138, 119, 0.35);
}

.legend-item.age-now {
  color: var(--brushed-brass);
}

.legend-item.week-now {
  color: var(--forest-olive);
}

.legend-item.target-now {
  color: #9E6F2F;
}

.legend-box {
  width: 12px;
  height: 12px;
  background: #FAF4E9;
  border-radius: 3px;
}

.legend-box.filled {
  background: linear-gradient(135deg, var(--forest-olive), #465345);
}

.legend-box.current-week {
  background: var(--brushed-brass);
}

.legend-box.current-age {
  background: var(--forest-olive);
}

.legend-box.target-mark {
  background: linear-gradient(135deg, #C58A35, #9E6F2F);
}

.matrix-cell.target-cell {
  position: relative;
}

.matrix-cell.target-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.matrix-cell.target-cell:focus-visible {
  outline: 1px solid var(--brushed-brass);
  outline-offset: 1px;
}

.matrix-cell.target-upcoming::after {
  background: #C58A35;
  box-shadow: 0 0 0 1px rgba(255, 253, 250, 0.95);
}

.matrix-cell.target-achieved::after {
  background: #2F3A2E;
  box-shadow: 0 0 0 1px rgba(255, 253, 250, 0.95);
}

.profile-btn-fixed {
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  background: linear-gradient(135deg, var(--forest-olive) 0%, var(--soft-sage) 100%);
  border: 1px solid rgba(244, 239, 230, 0.32);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 8px 25px rgba(183, 155, 91, 0.22);
  z-index: 1000;
  display: grid;
  place-items: center;
}

.profile-btn-fixed::before {
  content: "";
  width: 20px;
  height: 20px;
  display: inline-block;
  background-color: currentColor;
  opacity: 0.95;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M4 20c1.8-3.3 4.5-5 8-5s6.2 1.7 8 5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M4 20c1.8-3.3 4.5-5 8-5s6.2 1.7 8 5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.profile-btn-fixed:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 10px 26px rgba(183, 155, 91, 0.28);
}

.profile-btn-fixed:focus-visible {
  outline: 2px solid var(--brushed-brass);
  outline-offset: 3px;
}

.matrix-actions,
.profile-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.action-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  background: linear-gradient(135deg, var(--forest-olive) 0%, var(--soft-sage) 100%);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(183, 155, 91, 0.24);
}

.logout-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  background: transparent;
  border: 2px solid var(--forest-olive);
  border-radius: 12px;
  color: var(--forest-olive);
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--forest-olive);
  color: white;
}

/* Profile */
#step-profile {
  display: none;
  padding: 2rem;
  align-items: flex-start;
  justify-content: center;
}

#step-profile.active {
  display: flex;
}

.profile-container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(183, 155, 91, 0.12);
  text-align: center;
}

.profile-container h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--forest-olive);
  font-weight: 700;
}

.profile-card {
  background: #FFFBF5;
  border: 1px solid var(--line-mid);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: left;
}

.profile-main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #E4D9C4;
}

.profile-item:last-child {
  border-bottom: none;
}

.profile-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.profile-value {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1rem;
}

.profile-editor-locked {
  margin-top: 0.85rem;
  padding: 0.6rem 0.7rem;
  border: 1px dashed rgba(183, 155, 91, 0.5);
  border-radius: 10px;
  background: rgba(183, 155, 91, 0.09);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.profile-editor {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid #E4D9C4;
}

.profile-editor-actions {
  display: flex;
  justify-content: flex-end;
}

.profile-editor .action-btn {
  padding: 0.42rem 0.95rem;
  font-size: 0.8rem;
}

.profile-edit-form {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.profile-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-muted);
}

.profile-edit-form input {
  height: 36px;
  padding: 0 0.55rem;
  border: 1px solid #DCCFB8;
  border-radius: 10px;
  background: #FFFDF8;
  color: var(--text-primary);
  font-family: inherit;
}

.profile-edit-buttons {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.profile-edit-buttons .logout-btn,
.profile-edit-buttons .action-btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
}

.profile-edit-status {
  margin-top: 0.45rem;
  min-height: 1em;
  font-size: 0.78rem;
  color: var(--soft-sage);
  font-weight: 600;
}

.profile-targets {
  margin-top: 0;
  text-align: left;
  background: #FFFBF5;
  border: 1px solid var(--line-mid);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.profile-target-form {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  flex-shrink: 0;
}

.profile-target-form input {
  height: 38px;
  padding: 0 0.65rem;
  border: 1px solid #DCCFB8;
  border-radius: 10px;
  background: #FFFDF8;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  min-width: 0;
}

.profile-target-form .action-btn {
  grid-column: 1 / -1;
  justify-self: end;
  height: 38px;
  padding: 0 0.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
  white-space: nowrap;
  margin-top: 0.1rem;
}

.target-help {
  margin: 0.65rem 0 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.target-premium-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 0.8rem;
  border: 1px solid rgba(183, 155, 91, 0.55);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(183, 155, 91, 0.16), rgba(183, 155, 91, 0.28));
  color: #8A5F24;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.55rem;
}

.target-premium-btn:hover {
  background: linear-gradient(135deg, rgba(183, 155, 91, 0.24), rgba(183, 155, 91, 0.36));
}

.profile-premium-upgrade {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #E4D9C4;
  text-align: center;
}

.premium-upgrade-text {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.premium-buy-btn {
  background: linear-gradient(135deg, rgba(183, 155, 91, 0.35), rgba(183, 155, 91, 0.5));
  color: #5C4813;
  font-weight: 700;
}

.premium-buy-btn:hover {
  background: linear-gradient(135deg, rgba(183, 155, 91, 0.45), rgba(183, 155, 91, 0.6));
}

.profile-premium-badge {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--forest-olive);
}

.premium-modal-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--forest-olive);
  margin: 0.5rem 0 1rem;
}

.profile-target-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
  max-height: 240px;
  overflow-y: auto;
}

.target-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid #E8DFC9;
  border-radius: 10px;
  background: #FFFDF8;
}

.target-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--forest-olive);
  background: rgba(183, 155, 91, 0.16);
  border: 1px solid rgba(183, 155, 91, 0.36);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}

.target-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.target-remove {
  background: transparent;
  border: 1px solid rgba(181, 74, 58, 0.35);
  color: #9D4C3D;
  border-radius: 8px;
  height: 28px;
  padding: 0 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.target-remove:hover {
  background: rgba(181, 74, 58, 0.08);
}

.target-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.target-edit {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(183, 155, 91, 0.45);
  background: rgba(183, 155, 91, 0.1);
  color: #9E6F2F;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.target-edit:hover {
  background: rgba(183, 155, 91, 0.18);
}

/* Add target modal (Week) */
.add-target-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 52, 54, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.add-target-modal-overlay.hidden {
  display: none;
}

.add-target-modal {
  background: var(--card-bg);
  border: 1px solid var(--line-mid);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(45, 52, 54, 0.25);
}

.add-target-modal-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--forest-olive);
}

.add-target-modal input {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  border: 1px solid #DCCFB8;
  border-radius: 10px;
  background: #FFFDF8;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.add-target-modal input:focus {
  outline: none;
  border-color: var(--brushed-brass);
}

.add-target-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.guest-upgrade-text {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.add-target-modal-actions .action-btn,
.add-target-modal-actions .logout-btn {
  padding: 0 1rem;
  height: 38px;
}

@media (max-width: 768px) {
  :root {
    --cell-size: 9px;
  }

  .matrix-header {
    padding: 0.62rem 0.82rem;
  }

  .matrix-header-logo {
    font-size: clamp(1.15rem, 4.7vw, 1.4rem);
  }

  .matrix-header-actions {
    gap: 0.38rem;
  }

  .account-btn {
    font-size: 0.74rem;
    height: 36px;
    padding: 0 0.62rem;
  }

  .header-menu {
    margin: 0;
  }

  .menu-btn {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
  }

  .menu-dropdown {
    min-width: 186px;
  }

  .matrix-wrapper {
    gap: 0.85rem;
    padding: 0.8rem 0.85rem;
    border-radius: 12px;
  }

  .lived-stats {
    border-radius: 16px;
    padding: 0.55rem 0.7rem;
    line-height: 1.45;
  }

  .stats-separator {
    display: inline-block;
    margin: 0 0.35rem;
  }

  .matrix-meta {
    font-size: 0.8rem;
    padding: 0.32rem 0.55rem;
  }

  #year-scale {
    width: 68px;
    min-width: 68px;
    padding-left: 12px;
  }

  .year-label {
    left: 12px;
    font-size: 9px;
    width: 54px;
    padding-left: 0.25rem;
  }

  .year-label::before {
    width: 6px;
    height: 6px;
    left: -14px;
  }

  .profile-target-form {
    grid-template-columns: 1fr 90px;
  }

  .profile-main-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .profile-edit-form {
    grid-template-columns: 1fr;
  }

  .profile-target-form input#target-text {
    grid-column: 1 / -1;
  }

  .profile-target-form .action-btn {
    grid-column: 1 / -1;
  }
}

/* Footer */
.site-footer {
  background: var(--card-bg);
  color: var(--forest-olive);
  border-top: 1px solid rgba(183, 155, 91, 0.32);
  padding: 2rem 1rem;
  text-align: center;
  margin-top: auto;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
}

.footer-content p {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--soft-sage);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--brushed-brass);
}

/* Legal Pages */
.legal-page {
  min-height: 100vh;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.legal-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(183, 155, 91, 0.1);
  flex: 1;
}

.back-link {
  display: inline-block;
  color: var(--forest-olive);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 2rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--brushed-brass);
}

.legal-container h1 {
  font-size: 2.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.last-updated {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.legal-container section {
  margin-bottom: 2rem;
}

.legal-container h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #E4D9C4;
}

.legal-container section:first-of-type h2 {
  border-top: none;
  padding-top: 0;
}

.legal-container h3 {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.legal-container p {
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.legal-container ul {
  margin: 1rem 0 1rem 1.5rem;
  color: var(--text-primary);
}

.legal-container li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.legal-container a {
  color: var(--forest-olive);
}

.legal-container a:hover {
  text-decoration: underline;
}

/* About Page */
.about-logo {
  width: 320px;
  max-width: 100%;
  margin-bottom: 2rem;
}

.about-page h1 {
  margin-bottom: 2rem;
}

/* Contact Page */
.contact-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.contact-item {
  background: #FFFAF3;
  padding: 1.5rem;
  border-radius: 16px;
  text-align: center;
}

.contact-item h3 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.contact-item p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.contact-link {
  display: inline-block;
  color: var(--forest-olive);
  font-weight: 600;
  font-size: 1rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.social-link {
  padding: 0.5rem 1.5rem;
  background: var(--forest-olive);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}

.social-link:hover {
  background: var(--soft-sage);
}

/* Contact Form */
.contact-form-section {
  margin-top: 2rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  padding: 0.75rem 1rem;
  border: 2px solid #DCCFB8;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brushed-brass);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.submit-btn {
  background: linear-gradient(135deg, var(--forest-olive) 0%, var(--soft-sage) 100%);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(183, 155, 91, 0.24);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.contact-status {
  text-align: center;
  font-weight: 600;
  margin-top: 0.5rem;
}

.contact-status.success {
  color: #27ae60;
}

.contact-status.error {
  color: #e74c3c;
}

@media (max-width: 600px) {
  .legal-container {
    padding: 1.5rem;
  }

  .legal-container h1 {
    font-size: 1.8rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
  }
}
