:root {
  --bg: #fff1f7;
  --block: #ffffff;
  --accent: #ff91af;
  --btn-text: #ffffff;
  --btn-border: transparent;
  --text: #3c3340;
  --muted: #8d7f8b;
  --border: #f4cfe1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SF Pro Display", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.bg-effect {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background-image: radial-gradient(circle at 15% 25%, #ffe6f1 0, transparent 30%), radial-gradient(circle at 85% 75%, #ffd3e6 0, transparent 30%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 112px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.topbar p {
  margin: 4px 0 14px;
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card {
  background: var(--block);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}

.card h2 {
  margin-top: 0;
}

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

.summary-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fffafd;
  min-height: 72px;
}

.summary-grid span,
.settings-user span {
  font-size: 12px;
  color: var(--muted);
}

.summary-actions {
  grid-column: span 3;
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid var(--btn-border);
  background: var(--accent);
  color: var(--btn-text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-ghost {
  background: #f8eef4;
  color: var(--text);
  border: 1px solid #f0d8e6;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.subscription-actions {
  text-align: center;
  padding: 12px;
}

.subscription-buttons {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

#subUrl {
  margin: 0;
  font-size: 12px;
}

#subUrl:empty {
  display: none;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #f0d8e6;
  background: #fff6fb;
  color: #b44370;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 11, 17, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
}

.qr-modal.show {
  display: flex;
}

.qr-modal-card {
  width: min(420px, 100%);
  background: var(--block);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  position: relative;
  display: grid;
  gap: 10px;
}

#qrImage {
  width: min(320px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  justify-self: center;
}

.qr-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.theme-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-preset {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.theme-preset.is-active {
  border-color: #c9477c;
  box-shadow: 0 0 0 1px rgba(201, 71, 124, 0.35);
}

.theme-preset:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.lock-badge {
  margin-left: auto;
  font-size: 11px;
  color: #8f6f7e;
  white-space: nowrap;
}

.preset-swatches {
  display: inline-grid;
  grid-template-columns: repeat(3, 10px);
  gap: 4px;
}

.preset-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #d7ccd4;
  background: var(--swatch);
}

.preset-label {
  font-size: 12px;
  line-height: 1.15;
}

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

.color-option {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  min-height: 38px;
}

.color-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.color-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #d7ccd4;
  background: var(--swatch);
  flex: 0 0 auto;
}

.color-name {
  font-size: 12px;
  line-height: 1.15;
}

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

.effect-option {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
}

.effect-option.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.effect-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.color-palette.is-locked-group,
.effect-palette.is-locked-group {
  position: relative;
  pointer-events: none;
}

.color-palette.is-locked-group::before,
.effect-palette.is-locked-group::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  z-index: 2;
}

.color-palette.is-locked-group::after,
.effect-palette.is-locked-group::after {
  content: attr(data-lock-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #8f6f7e;
  z-index: 3;
}

.settings-user > div:not(.settings-actions) {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #fbeaf2;
  align-items: center;
}

.settings-user > div:not(.settings-actions):last-child {
  border-bottom: none;
}

.plans {
  display: grid;
  gap: 10px;
}

.link-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.link-panel.is-collapsed {
  display: none;
}

.link-value {
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fffafd;
}

.settings-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  width: 100%;
  border-bottom: none;
  padding: 0;
}

.copy-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #f0d8e6;
  background: #fff6fb;
  color: #b44370;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.copy-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.section-toggle-icon {
  transition: transform .2s ease;
}

.section-toggle[aria-expanded="true"] .section-toggle-icon {
  transform: rotate(180deg);
}

.section-panel {
  margin-top: 10px;
}

.section-panel.is-collapsed {
  display: none;
}

.session-list {
  display: grid;
  gap: 8px;
}

.session-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.session-main strong {
  display: block;
  font-size: 14px;
}

.session-main small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.session-remove {
  border: 1px solid #f0d8e6;
  background: #fff6fb;
  color: #b44370;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
}

.session-remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.session-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.plan {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  position: relative;
  overflow: hidden;
}

.plan.is-buyable {
  cursor: pointer;
}

.plan.is-buyable:hover {
  transform: translateY(-1px);
}

.plan-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.plan-title {
  font-size: 16px;
}

.plan-features {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 2px;
}

.plan-features li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.plan.is-selected {
  border-color: #efb1ca;
  box-shadow:
    0 0 0 1px rgba(255, 145, 175, 0.28),
    0 8px 26px rgba(255, 145, 175, 0.2);
}

.plan.is-current {
  border-color: #9fd9b8;
  box-shadow:
    0 0 0 1px rgba(128, 211, 167, 0.3),
    0 8px 24px rgba(128, 211, 167, 0.18);
}

.plan.is-selected::after,
.plan.is-current::after {
  content: "";
  position: absolute;
  inset: -26%;
  z-index: 0;
  pointer-events: none;
  border-radius: 24px;
}

.plan.is-selected::after {
  background: radial-gradient(circle at 20% 15%, rgba(255, 145, 175, 0.24), transparent 55%);
}

.plan.is-current::after {
  background: radial-gradient(circle at 20% 15%, rgba(128, 211, 167, 0.22), transparent 55%);
}

.plan > * {
  position: relative;
  z-index: 1;
}

.plan-lite {
  background: linear-gradient(180deg, #fff8fc 0%, #ffffff 100%);
}

.plan-plus {
  background: linear-gradient(180deg, #f8fff9 0%, #ffffff 100%);
}

.plan-premium {
  background: linear-gradient(180deg, #fff8ef 0%, #ffffff 100%);
  border-color: #f0d8b2;
}

.plan-action {
  margin-top: 10px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.plan-action.is-current {
  background: #ecf8f0;
  color: #2f8b52;
  border: 1px solid #bde6c8;
  cursor: default;
}

.plan-action.is-soon {
  background: #ffe8f1;
  color: #b85b84;
  border: 1px solid #f4bfd4;
}

.plan-action:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.renew-btn {
  border: 1px solid #f0d8e6;
  border-radius: 10px;
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
  background: #f6f0f4;
  color: #756772;
}

.renew-btn.is-on {
  background: #e8f8ee;
  color: #2f8b52;
  border-color: #bde6c8;
}

.renew-btn.is-off {
  background: #ffeef1;
  color: #b94f67;
  border-color: #f2bfd0;
}

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

.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: 0 14px 34px rgba(159, 86, 118, 0.18);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  border-radius: 18px;
  z-index: 10;
}

.nav-btn {
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.nav-label {
  line-height: 1;
  font-size: 11px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn.active {
  color: #c9477c;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.72);
}

@media (max-width: 640px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-actions {
    grid-column: span 2;
    flex-direction: column;
  }

  .subscription-buttons {
    grid-template-columns: 1fr auto;
  }

  .bottom-nav {
    width: calc(100vw - 16px);
    bottom: 8px;
  }

  .color-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .effect-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-presets {
    grid-template-columns: 1fr;
  }

  .session-actions {
    grid-template-columns: 1fr;
  }
}
