:root {
  --bg: #faf9f6;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #888888;
  --brand: #b73434;
  --brand-dark: #8f2727;
  --navy: #3a445d;
  --line: #e0e0e0;
  --ok: #27ae60;
  --warn: #eb5757;
  --shadow: 0 4px 20px rgba(58, 68, 93, 0.08);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
}

body {
  min-height: 100vh;
}

.app-shell {
  width: 100%;
  max-width: 448px;
  margin: 0 auto;
  padding: 0 0 36px;
}

.view {
  width: 100%;
}

.view-login {
  padding: 40px 24px 0;
}

.view-login > * {
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.brand-dot {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  background: var(--brand);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.brand-dot img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.auth-brand h1 {
  margin: 16px 0 0;
  color: var(--brand);
  font-family: 'Merriweather', serif;
  font-size: 24px;
  line-height: 36px;
}

.auth-title {
  margin: 24px 0 0;
  color: var(--navy);
  font-family: 'Merriweather', serif;
  font-size: 28px;
  line-height: 36.4px;
  text-align: center;
  max-width: 342px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 32px;
}

.auth-field {
  margin-bottom: 24px;
}

.auth-card .field-input {
  height: 58px;
}

.auth-card .field-with-icon {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 8px;
}

.field-input {
  width: 100%;
  height: 51px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field-input::placeholder {
  color: rgba(26, 26, 26, 0.5);
}

.field-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(183, 52, 52, 0.12);
}

.field-with-icon {
  position: relative;
  margin-bottom: 16px;
}

.field-with-icon .field-input {
  padding-right: 50px;
}

.icon-btn {
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.field-with-icon .icon-btn {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
}

.btn {
  border: 0;
  border-radius: var(--radius-lg);
  height: 51px;
  width: 100%;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: transform .12s ease, opacity .2s ease, background-color .2s ease, color .2s ease;
}

.btn svg {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.btn-lg {
  height: 56px;
  font-size: 16px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.btn-black {
  margin-top: 12px;
  background: #000;
  color: #fff;
  font-size: 16px;
}

.btn-black img {
  filter: invert(1);
}

.btn-outline {
  border: 2px solid var(--navy);
  color: var(--navy);
  background: transparent;
}

.btn-text-danger {
  color: var(--warn);
  background: transparent;
  font-size: 14px;
  font-weight: 400;
  height: 48px;
  line-height: 21px;
  width: auto;
  margin: 0 auto;
  display: block;
}

.btn-muted {
  background: #cccccc;
  color: #27ae60;
}

.form-error {
  margin: 8px 0 0;
  min-height: 20px;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-line;
}

.auth-hint {
  margin-top: 32px;
  padding: 25px 25px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  display: flex;
  gap: 12px;
  box-shadow: none;
}

.auth-hint p {
  margin: 0;
  font-size: 14px;
  line-height: 21px;
}

.hint-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.hint-icon img {
  width: 24px;
  height: 24px;
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn.plain {
  width: 24px;
  height: 24px;
  color: var(--navy);
}

.identity-block {
  margin-top: 0;
  padding: 0 24px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.identity-block p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

#identity-id {
  font-family: 'Cousine', monospace;
  font-size: 12px;
  color: #aaaaaa;
}

.currency-switch {
  margin: 20px 24px 0;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.currency-btn {
  border: 0;
  height: 37px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  background: transparent;
  cursor: pointer;
}

.currency-btn.active {
  background: var(--brand);
  color: #fff;
}

.tier-card {
  margin: 22px 24px 0;
  border-radius: var(--radius-xl);
  padding: 24px;
  min-height: 156px;
}

.tier-card.master {
  background: linear-gradient(159deg, #3a445d 0%, #2c3549 100%);
  color: #fff;
}

.tier-card.free {
  background: linear-gradient(152deg, #3a445d 0%, #2c3549 100%);
  color: #fff;
}

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

.tier-title {
  margin: 0;
  font-family: 'Merriweather', serif;
  font-size: 24px;
  line-height: 1.1;
}

.badge {
  background: var(--ok);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 10px;
  line-height: 15px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 4px 12px;
  text-transform: uppercase;
}

.tier-date {
  margin: 16px 0 12px;
  font-size: 14px;
  opacity: .85;
}

.autorenew-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: var(--radius-pill);
  border: none;
  padding: 2px;
  cursor: pointer;
  background: #ccc;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
}

.switch.on {
  background: var(--ok);
}

.switch.on::after {
  transform: translateX(16px);
}

.switch:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.upgrade-chip {
  margin-top: 12px;
  background: #27ae60;
  color: #fff;
  border: 0;
  border-radius: var(--radius-pill);
  height: 36px;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.limits-section {
  margin-top: 32px;
  padding: 0 24px;
}

.limits-section h2 {
  margin: 0 0 16px;
  color: var(--navy);
  font-family: 'Merriweather', serif;
  font-size: 20px;
  line-height: 1.15;
}

.limit-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.limit-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.limit-icon {
  width: 48px;
  height: 48px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.limit-icon img {
  width: 24px;
  height: 24px;
  display: block;
}

.limit-content {
  flex: 1;
}

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

.limit-name {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.limit-count {
  margin: 0;
  color: var(--navy);
  font-size: 16px;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: #f0f0f0;
  margin-top: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand);
}

.limit-empty {
  margin: 8px 0 0;
  color: var(--warn);
  font-size: 13px;
  font-weight: 500;
}

.buy-btn {
  margin-top: 14px;
  height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  width: fit-content;
  border: 1.5px solid var(--brand);
  color: var(--brand);
  background: transparent;
  cursor: pointer;
}

.buy-btn.primary {
  background: var(--brand);
  color: #fff;
}

.buy-btn.disabled {
  border-color: #999;
  color: #999;
  cursor: not-allowed;
}

.dashboard-error {
  margin: 20px 24px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.dashboard-error p {
  margin: 0 0 10px;
  color: var(--warn);
  font-size: 14px;
}

.dashboard-skeleton {
  margin: 16px 24px 0;
}

.skeleton-line,
.skeleton-card {
  background: linear-gradient(90deg, #efefef 0%, #f7f7f7 50%, #efefef 100%);
  background-size: 220% 100%;
  animation: pulse 1.2s infinite;
  border-radius: var(--radius-lg);
}

.skeleton-line {
  height: 24px;
  width: 65%;
  margin-bottom: 16px;
}

.skeleton-card {
  height: 160px;
  margin-bottom: 14px;
}

@keyframes pulse {
  from { background-position: 200% 0; }
  to { background-position: -20% 0; }
}

.settings-header {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}

.settings-header h1 {
  margin: 0;
  font-family: 'Merriweather', serif;
  color: var(--navy);
  font-size: 24px;
  line-height: 36px;
}

.compact {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.settings-link {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.settings-link:last-child {
  border-bottom: 0;
}

.settings-link span {
  display: block;
}

.settings-link img {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.data-shield {
  margin: 24px 24px 0;
  display: flex;
  gap: 16px;
  padding: 24px;
}

.settings-actions {
  margin: 24px 24px 0;
}

.shield-icon {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: #e8f5e9;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.shield-icon img {
  width: 20px;
  height: 20px;
  display: block;
}

.data-shield h3 {
  margin: 0;
  font-family: 'Merriweather', serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 22.5px;
}

.data-shield p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 22.4px;
  font-size: 14px;
  max-width: 296px;
}

.text-link {
  display: block;
  text-align: center;
  margin-top: 26px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 400;
  line-height: 21px;
  text-decoration: underline;
}

#settings-logout-open {
  width: calc(100% - 48px);
  margin: 32px 24px 0;
  height: 59px;
  border-width: 1.5px;
  font-weight: 500;
}

.info-note {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 16px;
}

.modal {
  width: 100%;
  max-width: 448px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #faf9f6;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  color: var(--navy);
  font-family: 'Merriweather', serif;
  font-size: 20px;
  line-height: 1.2;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 16px;
  background: #e0e0e0;
  color: var(--navy);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-body h4 {
  margin: 6px 0 12px;
  color: var(--navy);
  font-family: 'Merriweather', serif;
  font-size: 18px;
}

.modal-note {
  text-align: center;
  color: var(--muted);
  margin: 4px 0 16px;
  font-size: 13px;
}

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

.choice-item {
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
}

.choice-item.selected {
  border-color: var(--brand);
}

.choice-radio {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  border: 2px solid #ccc;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
}

.choice-item.selected .choice-radio {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.choice-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.choice-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.price-row {
  margin: 16px -24px 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price-row .label {
  color: var(--muted);
  font-size: 14px;
}

.price-row .value {
  color: var(--brand);
  font-family: 'Merriweather', serif;
  font-size: 50px;
  font-weight: 700;
}

.modal-footer {
  padding: 16px 24px 24px;
}

.modal-footer .form-error {
  margin-top: 8px;
}

.stacked-fields {
  display: grid;
  gap: 16px;
}

.inline-actions {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.info-block {
  margin-top: 12px;
  border-radius: 20px;
  background: #e3f2fd;
  color: #1976d2;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  line-height: 19.5px;
}

.info-block img {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.info-block p {
  margin: 0;
  color: #1976d2;
}

.field-with-leading-icon {
  position: relative;
}

.leading-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: block;
}

.field-input.with-leading-icon {
  padding-left: 48px;
}

.field-with-leading-icon.readonly-email .field-input {
  height: 48px;
  border: 0;
  background: #e8e8e8;
  color: #888;
}

.field-with-leading-icon.readonly-email .field-input:focus {
  border: 0;
  box-shadow: none;
}

.modal.form-modal .modal-header {
  border-bottom: 0;
  padding: 24px 24px 0;
}

.modal.form-modal .modal-header h3 {
  font-size: 24px;
  line-height: 36px;
}

.modal.form-modal .modal-close {
  background: #fff;
}

.modal.form-modal .modal-body {
  padding: 24px;
}

.modal.form-modal .field-label {
  color: var(--navy);
}

.modal.form-modal .field-label.muted-label {
  color: var(--muted);
}

.modal.form-modal .field-input {
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
}

.modal.form-modal .field-with-icon {
  margin-bottom: 0;
}

.modal.form-modal .inline-actions .btn {
  border-radius: 20px;
  height: 51px;
  font-size: 16px;
  font-weight: 500;
}

.modal.form-modal .inline-actions .btn-outline {
  border: 1.5px solid #e0e0e0;
  background: #fff;
  color: var(--navy);
}

.modal.form-modal .inline-actions .btn-primary {
  background: var(--brand);
  color: #fff;
}

.upgrade-modal {
  padding-bottom: 18px;
}

.upgrade-head {
  background: linear-gradient(159deg, #b73434 0%, #8f2727 100%);
  color: #fff;
  border-radius: 24px 24px 0 0;
  padding: 20px 24px;
  position: relative;
}

.upgrade-title {
  margin: 8px 0 0;
  font-family: 'Merriweather', serif;
  font-size: 44px;
}

.upgrade-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0.95;
}

.upgrade-price {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}

.upgrade-price .meta {
  color: var(--muted);
  font-size: 13px;
}

.upgrade-price .amount {
  margin-top: 6px;
  color: var(--brand);
  font-family: 'Merriweather', serif;
  font-size: 50px;
}

.upgrade-benefits {
  padding: 20px 24px;
  display: grid;
  gap: 12px;
}

.upgrade-item {
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.upgrade-item strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 3px;
}

.upgrade-item .check {
  color: var(--ok);
  font-weight: 700;
}

.upgrade-extra {
  margin: 0 24px 12px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  padding: 14px;
}

.upgrade-footer {
  padding: 0 24px;
}

.legal-note {
  margin: 10px 24px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.confirm-modal .modal-body {
  text-align: center;
}

.confirm-modal p {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(90vw, 420px);
  z-index: 25;
  display: grid;
  gap: 8px;
}

.toast {
  border-radius: 12px;
  padding: 10px 12px;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}

.toast.success { background: #2e7d32; }
.toast.error { background: #b73434; }
.toast.info { background: #3a445d; }

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 768px) {
  .app-shell {
    max-width: 1014px;
    padding: 0 0 60px;
  }

  .view {
    width: 448px;
    margin: 0 auto;
  }

  .view-login {
    padding-top: 48px;
  }
}
