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

:root {
  --bg: #e9e1d6;
  --surface: rgba(255, 252, 247, 0.64);
  --surface-strong: rgba(255, 251, 245, 0.88);
  --line: rgba(55, 40, 26, 0.2);
  --text: #1b1611;
  --muted: #49382b;
  --accent: #c25a21;
  --cyan: #2fc9c2;
  --shadow: 0 24px 60px rgba(35, 25, 16, 0.16);
  --radius-lg: 24px;
  --radius-md: 14px;
  --font: Georgia, "Times New Roman", "Songti SC", serif;
  --font-mono: "SF Mono", "Fira Code", "Courier New", monospace;
}

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

body {
  color: var(--text);
  background:
    linear-gradient(rgba(245, 238, 229, 0.74), rgba(232, 223, 212, 0.78)),
    linear-gradient(180deg, #f4ede4 0%, #e6ddcf 100%);
  font-family: var(--font);
  line-height: 1.6;
  font-weight: 500;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
  z-index: 2;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.page-border {
  position: fixed;
  inset: 8px;
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 4;
}

.page-border::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(55, 40, 26, 0.12);
}

.user-page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr) minmax(300px, 1fr);
  grid-template-rows: 58px minmax(220px, .9fr) minmax(160px, .7fr) minmax(420px, 1.25fr);
  gap: 12px;
}

.glass {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
  opacity: .48;
  z-index: 1;
}

.top-strip {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 10px;
}

.kicker,
.pill,
.account-row span,
.metric span,
.status-row span,
.retention-strip span,
.mailroom,
.progress-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.kicker {
  color: var(--accent);
}

.top-strip h1,
.panel-title h2 {
  margin: 0;
  line-height: 1;
}

.top-strip h1 {
  font-size: clamp(28px, 2.8vw, 42px);
}

.nav-pills {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.pill {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(55, 40, 26, 0.17);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.72);
  box-shadow: 0 10px 24px rgba(35, 25, 16, 0.08);
  padding: 0 12px;
  white-space: nowrap;
}

.pill.primary {
  border-color: rgba(194, 90, 33, .46);
  background: rgba(194, 90, 33, .14);
  color: #7b3111;
}

.account-panel,
.subscription-panel,
.library-panel,
.retention-panel,
.preference-panel,
.security-panel {
  padding: 18px;
}

.account-panel {
  grid-column: 1;
  grid-row: 2;
}

.subscription-panel {
  grid-column: 2;
  grid-row: 2;
}

.library-panel {
  grid-column: 3;
  grid-row: 2;
}

.retention-panel {
  grid-column: 1 / 3;
  grid-row: 3 / 5;
}

.preference-panel {
  grid-column: 3;
  grid-row: 3;
}

.security-panel {
  grid-column: 3;
  grid-row: 4;
  overflow: auto;
}

.panel-title,
.account-grid,
.metric-grid,
.status-list,
.progress-list,
.flow-grid,
.register-form,
.logout-button,
.retention-strip,
.mailroom {
  position: relative;
  z-index: 2;
}

.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 24px;
}

.account-grid,
.status-list,
.progress-list {
  display: grid;
  gap: 10px;
}

.account-row,
.status-row,
.progress-row,
.empty-row,
.mailroom {
  border: 1px solid rgba(55, 40, 26, 0.13);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.68);
  padding: 13px;
}

.account-row,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-row strong,
.status-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #315c58;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  border: 1px solid rgba(55, 40, 26, 0.13);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.68);
  padding: 13px;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.05;
}

.metric span,
.account-row span,
.status-row span,
.progress-meta,
.retention-strip span {
  color: var(--muted);
}

.retention-strip {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(47, 201, 194, .35);
  border-radius: var(--radius-md);
  background: rgba(47, 201, 194, .12);
  padding: 13px;
  margin-bottom: 10px;
}

.retention-strip strong {
  font-size: 28px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.progress-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  font-weight: 800;
}

.progress-bar {
  grid-column: 1 / 3;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(55, 40, 26, 0.12);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.flow-grid button,
.register-form button,
.logout-button {
  height: 34px;
  border: 1px solid rgba(55, 40, 26, 0.13);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.68);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.flow-grid button:not(:disabled) {
  background: rgba(47, 201, 194, .14);
  color: #315c58;
  cursor: pointer;
}

.register-form {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.register-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.register-form input {
  width: 100%;
  height: 34px;
  border: 1px solid rgba(55, 40, 26, 0.16);
  border-radius: 12px;
  outline: none;
  background: rgba(255, 252, 247, 0.82);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 0 11px;
}

.register-form input:focus {
  border-color: rgba(194, 90, 33, .55);
  box-shadow: 0 0 0 3px rgba(194, 90, 33, .12);
}

.register-form button {
  background: rgba(27, 22, 17, .92);
  color: #fffaf3;
  cursor: pointer;
}

.logout-button {
  width: 100%;
  margin: 0 0 10px;
  background: rgba(194, 90, 33, .14);
  color: #7b3111;
  cursor: pointer;
}

.register-form button:disabled,
.logout-button:disabled {
  cursor: wait;
  opacity: .64;
}

.register-status {
  margin-bottom: 10px;
}

.register-status.is-ok {
  border-color: rgba(47, 201, 194, .46);
  background: rgba(47, 201, 194, .14);
}

.register-status.is-error {
  border-color: rgba(194, 90, 33, .46);
  background: rgba(194, 90, 33, .14);
  color: #7b3111;
}

@media (max-width: 1040px) {
  .user-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .top-strip,
  .account-panel,
  .subscription-panel,
  .library-panel,
  .retention-panel,
  .preference-panel,
  .security-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .security-panel {
    align-self: stretch;
  }

  .top-strip {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 4px;
  }

  .nav-pills {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .user-page {
    padding: 10px;
  }

  .account-panel,
  .subscription-panel,
  .library-panel,
  .retention-panel,
  .preference-panel,
  .security-panel {
    padding: 14px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

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

  .progress-bar {
    grid-column: 1;
  }
}
