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

.account-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.account-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.account-back-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
  white-space: nowrap;
}
.account-back-btn:hover {
  color: var(--text);
  background: var(--hover-overlay);
}

.account-header-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.account-header-title .app-name {
  font-size: var(--fs-subhead);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.account-label {
  font-size: var(--fs-hint);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Body layout ─────────────────────────────────────────────────────────── */
.account-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Tab sidebar ─────────────────────────────────────────────────────────── */
.account-tabs {
  display: flex;
  flex-direction: column;
  width: 180px;
  flex-shrink: 0;
  padding: 1.25rem 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  gap: 2px;
}

.account-tab {
  display: block;
  width: 100%;
  padding: 0.55rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--muted);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.account-tab:hover {
  color: var(--text);
  background: var(--hover-overlay);
}
.account-tab.active {
  color: var(--text);
  border-left-color: var(--accent2);
  background: var(--surface2);
}

.account-tab-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 1rem;
  margin-top: auto;
}

.account-tab--danger       { color: var(--danger); }
.account-tab--danger:hover { color: var(--danger); background: var(--danger-subtle); }
.account-tab--danger.active {
  color: var(--danger);
  border-left-color: var(--danger);
  background: var(--surface2);
}

/* ── Panel area ──────────────────────────────────────────────────────────── */
.account-main {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

.account-panel { display: none; max-width: 520px; }
.account-panel.active { display: block; }

.account-panel-title {
  font-size: var(--fs-note);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.account-panel-title--danger { color: var(--danger); }

.account-placeholder {
  font-size: var(--fs-body);
  color: var(--muted);
}

/* ── Settings primitives ─────────────────────────────────────────────────── */
.settings-group {
  margin-bottom: 1.5rem;
}

.settings-label {
  font-size: var(--fs-secondary);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.settings-desc {
  font-size: var(--fs-hint);
  color: var(--muted);
  margin-bottom: 0.45rem;
  opacity: 0.7;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.settings-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-body-lg);
  padding: 0.4rem 0.6rem;
  outline: none;
  transition: border-color 0.1s;
  min-width: 0;
}
.settings-input:focus { border-color: var(--accent2); }
.settings-input--readonly {
  color: var(--muted);
  cursor: default;
}

.settings-value {
  font-size: var(--fs-body-lg);
  color: var(--text);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-body);
  color: var(--text);
  cursor: pointer;
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-faint);
  border-color: var(--accent-border);
  color: var(--accent);
}
.btn-primary:hover   { background: var(--accent-subtle); border-color: var(--accent); }
.btn-primary:active  { background: var(--accent-subtle); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: none;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--hover-overlay); }

.btn-danger {
  background: none;
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover { background: var(--danger-subtle); border-color: var(--danger); }

/* ── Save status ─────────────────────────────────────────────────────────── */
.save-status {
  font-size: var(--fs-hint);
  color: var(--success);
  opacity: 0;
  transition: opacity 0.2s;
}
.save-status--visible { opacity: 1; }
.save-status--error   { color: var(--danger); }

/* ── Settings hint text ──────────────────────────────────────────────────── */
.settings-hint {
  font-size: var(--fs-hint);
  color: var(--muted);
  margin: -0.25rem 0 0.75rem;
  line-height: 1.4;
}

/* ── Survey fields ───────────────────────────────────────────────────────── */
.survey-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.survey-field-label {
  font-family: var(--font-mono);
  font-size: var(--fs-hint);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.survey-select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.1s;
  cursor: pointer;
}
.survey-select:focus { border-color: var(--accent2); }

.survey-other-input {
  margin-top: 0.1rem;
}

/* ── Profile avatar ──────────────────────────────────────────────────────── */
.profile-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent2-faint);
  border: 2px solid var(--accent2-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-display-sm);
  font-weight: 600;
  color: var(--accent2);
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar--photo { background: none; border-color: var(--border); }
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ── Theme toggle ────────────────────────────────────────────────────────── */
.theme-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1;
}
.theme-btn:hover  { background: var(--surface2); color: var(--text); }
.theme-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ── Custom theme buttons (inline with Auto / Light / Dark) ──────────────── */
.theme-btn--add {
  border-style: dashed;
}

.theme-btn-custom {
  display: inline-flex;
  align-items: stretch;
  border-radius: 3px;
  border: 1px solid var(--border);
  overflow: hidden;
  line-height: 1;
  transition: border-color 0.1s;
}
.theme-btn-custom:hover { border-color: var(--text); }
.theme-btn-custom.active {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
}

.theme-btn-custom__name {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
}
.theme-btn-custom:hover .theme-btn-custom__name { color: var(--text); }
.theme-btn-custom.active .theme-btn-custom__name { color: var(--accent); }

.theme-btn-custom__del {
  font-size: var(--fs-body);
  padding: 0.2rem 0.4rem;
  background: none;
  border: none;
  border-left: 1px solid transparent;
  color: transparent;
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.theme-btn-custom:hover .theme-btn-custom__del {
  color: var(--muted);
  border-left-color: var(--border);
}
.theme-btn-custom__del:hover {
  color: var(--danger) !important;
  background: var(--danger-subtle);
}

/* ── New theme form + import/export row ──────────────────────────────────── */
.new-theme-form {
  display: none;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.theme-io-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ── Color vars list ─────────────────────────────────────────────────────── */
.color-var-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.3rem;
}

.color-var-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 2px; }

.color-var-label {
  font-size: var(--fs-secondary);
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-var-reset {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-heading-sm);
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  flex-shrink: 0;
  line-height: 1;
}
.color-var-item:hover .color-var-reset { opacity: 1; }
.color-var-reset--active { opacity: 1; color: var(--accent2); }
.color-var-reset:hover { color: var(--text); }

/* ── Subscription plan card ──────────────────────────────────────────────── */
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
}

.plan-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.plan-name {
  font-size: var(--fs-content);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.plan-tagline {
  font-size: var(--fs-label);
  color: var(--muted);
}

.plan-badge {
  font-size: var(--fs-meta);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--accent2-border);
  color: var(--accent2);
  background: var(--accent2-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Usage bars ──────────────────────────────────────────────────────────── */
.usage-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.usage-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.usage-item-label {
  font-size: var(--fs-label);
  color: var(--text);
}

.usage-item-value {
  font-size: var(--fs-label);
  color: var(--muted);
}

.usage-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--accent2);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.plan-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* ── Account Management / Danger Zone ───────────────────────────────────── */
.danger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--danger-subtle);
  border: 1px solid var(--danger-soft);
  border-radius: 4px;
}

.danger-item-title {
  font-size: var(--fs-subhead);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.danger-item-desc {
  font-size: var(--fs-label);
  color: var(--muted);
  line-height: 1.5;
}

/* ── Allowances list ─────────────────────────────────────────────────────── */
.allowance-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.allowance-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  font-size: var(--fs-caption);
  border-bottom: 1px solid var(--border);
}
.allowance-item:last-child { border-bottom: none; }
.allowance-item:nth-child(even) { background: var(--hover-overlay); }

.allowance-label { color: var(--muted); }
.allowance-value { color: var(--text); text-align: right; }

/* ── Tier selector modal ─────────────────────────────────────────────────── */
.tier-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: min(1060px, calc(100vw - 2rem));
  box-shadow: 0 8px 40px var(--shadow-lg);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
}

.tier-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.tier-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-content);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}
.tier-modal-close:hover { color: var(--text); background: var(--hover-overlay); }

.billing-toggle-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 1.5rem 0;
}

.billing-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px;
  gap: 2px;
}

.billing-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  padding: 0.3rem 0.85rem;
  border-radius: 3px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.billing-btn:hover  { color: var(--text); }
.billing-btn.active { background: var(--surface); color: var(--text); }

.billing-discount {
  font-size: var(--fs-label-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--success);
  background: var(--success-faint);
  border: 1px solid var(--success-border);
  border-radius: 2px;
  padding: 1px 5px;
}

.tier-modal-body {
  padding: 1.5rem;
}

/* ── Tier cards grid ─────────────────────────────────────────────────────── */
.tier-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.tier-card {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.25rem 1rem 1rem;
  position: relative;
}

.tier-card--featured {
  border-color: var(--accent2-border);
  background: color-mix(in srgb, var(--surface2), var(--accent2) 4%);
}

.tier-card--current {
  border-color: var(--accent-border);
}

.tier-card-highlight {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-label-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent2);
  background: var(--surface);
  border: 1px solid var(--accent2-border);
  border-radius: 0 0 3px 3px;
  padding: 2px 8px;
  white-space: nowrap;
}

.tier-name {
  font-size: var(--fs-note);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  margin-top: 0.5rem;
}

.tier-price {
  margin-bottom: 1rem;
}
.tier-price-amount {
  font-size: var(--fs-display-sm);
  font-weight: 600;
  color: var(--text);
}
.tier-price-period {
  font-size: var(--fs-label);
  color: var(--muted);
  margin-left: 2px;
}

.tier-price-breakdown {
  font-size: var(--fs-secondary);
  color: var(--muted);
  margin-top: 0.25rem;
}

.tier-features {
  list-style: none;
  flex: 1;
  margin-bottom: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tier-features li {
  font-size: var(--fs-label);
  color: var(--muted);
  padding-left: 0.9rem;
  position: relative;
}
.tier-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent2);
  font-size: var(--fs-secondary);
}

.tier-select-btn {
  width: 100%;
  justify-content: center;
  border-color: var(--border);
  color: var(--text);
  background: none;
}
.tier-select-btn:hover    { border-color: var(--accent); color: var(--accent); background: var(--accent-faint); }
.tier-select-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Account settings drawer (used in main app) ──────────────────────────── */
.account-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  pointer-events: none;
  overflow: hidden;
}

.account-drawer-overlay.open {
  pointer-events: auto;
}

.account-drawer-panel {
  width: 780px;
  max-width: calc(100vw - 2rem);
  flex-shrink: 0;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg);
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.account-drawer-overlay.open .account-drawer-panel {
  transform: translateX(0);
  box-shadow: 4px 0 32px var(--shadow-lg);
}

.account-drawer-scrim {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.account-drawer-overlay.open .account-drawer-scrim {
  opacity: 1;
}

#accountDrawerFrame {
  width: 100%;
  flex: 1;
  border: none;
  display: block;
}
