:root {
  --blue: #1473e6;
  --blue-hover: #0d5bbf;
  --blue-soft: #e8f4ff;
  --blue-border: #b7d6f7;
  --navy: #0f172a;
  --slate: #475569;
  --slate-light: #64748b;
  --white: #ffffff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 4px 20px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--navy);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
}

.edit-page {
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.app-shell {
  max-width: 100%;
  min-height: 100vh;
  padding: 0 14px;
  padding-top: calc(8px + env(safe-area-inset-top, 0));
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 14px;
  min-height: 40px;
}

.header .brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.header .brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.025em;
}

/* --- Intro --- */
.intro-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  color: var(--white);
}

.intro-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.3;
}

.intro-card p {
  font-size: 13px;
  margin: 0;
  opacity: 0.9;
  line-height: 1.45;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
}

.card-desc {
  font-size: 13px;
  color: var(--slate);
  margin: 0 0 16px;
}

/* --- Builder --- */
.builder-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.builder-step h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--navy);
}

.builder-step h3 .ti {
  font-size: 18px;
  color: var(--blue);
}

.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder {
  color: var(--slate-light);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20, 115, 230, 0.15);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

/* --- Cover upload --- */
.cover-upload {
  margin: 8px 0;
}

.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  background: var(--blue-soft);
  border: 2px dashed var(--blue-border);
  border-radius: var(--radius-sm);
  color: var(--blue);
}

.cover-placeholder .ti {
  font-size: 28px;
  opacity: 0.8;
}

.cover-placeholder span {
  font-size: 13px;
}

.btn-ghost {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  background: transparent;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-ghost:active {
  background: rgba(20, 115, 230, 0.1);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  margin-top: 8px;
}

.cover-preview {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: #f1f5f9;
}

.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-preview .btn-change {
  position: absolute;
  bottom: 8px;
  right: 8px;
}

/* --- Crop modal --- */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.92);
  padding: env(safe-area-inset-top, 12px) 16px calc(env(safe-area-inset-bottom, 0) + 16px);
  isolation: isolate;
}

.crop-modal:not([hidden]) {
  display: flex;
}

.crop-container {
  flex: 1 1 0;
  min-height: 200px;
  max-height: 55vh;
  overflow: hidden;
  position: relative;
}

.crop-container > img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.crop-actions {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  padding-top: 16px;
  margin-top: 8px;
}

.crop-btn {
  flex: 1;
  min-width: 0;
  max-width: none;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.crop-btn-cancel {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}

.crop-btn-apply {
  background: #1473e6;
  color: #fff;
}

/* --- Buttons --- */
.btn-primary {
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary .ti {
  font-size: 18px;
}

.btn-primary:active {
  background: var(--blue-hover);
}

.btn-submit {
  width: 100%;
  margin-top: 4px;
}

.form-result {
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.form-result:empty {
  display: none;
}

.form-result.success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.form-result.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.form-result a {
  color: inherit;
  text-decoration: underline;
}

/* --- Pricing --- */
.plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}

.plan:first-child {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.plan-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.plan-meta {
  font-size: 12px;
  color: var(--slate);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-meta .ti {
  font-size: 14px;
  color: var(--slate-light);
}

.plan-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
}

.plan:first-child .plan-badge {
  background: var(--blue);
  color: var(--white);
}

/* --- Bottom nav --- */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0));
  max-width: 100%;
  overflow: hidden;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  min-width: 0;
  transition: color 0.15s;
}

.nav-item .ti {
  font-size: 20px;
}

.nav-item.active {
  color: var(--blue);
  font-weight: 600;
}

/* --- Public showcase (showcase.html) --- */
.showcase-page {
  padding-bottom: 24px;
}

.showcase-hero {
  position: relative;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  overflow: hidden;
}

.showcase-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.showcase-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.85) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 16px;
}

.showcase-hero h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--white);
  margin: 0 0 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.showcase-hero-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  margin: 0;
}

.showcase-section {
  padding: 18px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.showcase-section:last-of-type {
  border-bottom: none;
}

.showcase-section h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  margin: 0 0 10px;
}

.showcase-cta {
  padding: 24px 16px;
  text-align: center;
}

.showcase-cta .btn-primary {
  min-width: 200px;
}

.showcase-watermark {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.showcase-watermark-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate);
  text-decoration: none;
}

.showcase-watermark .brand-mark {
  width: 18px;
  height: 18px;
}

.showcase-loading,
.showcase-error {
  padding: 40px 16px;
  text-align: center;
  color: var(--slate);
}

.showcase-error {
  color: var(--slate);
}

.showcase-section h3 .ti {
  margin-right: 6px;
  vertical-align: middle;
}

.showcase-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--navy);
}

.showcase-desc {
  font-size: 15px !important;
  line-height: 1.5 !important;
}

.showcase-price {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--blue) !important;
}

.showcase-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--blue);
  word-break: break-all;
}

.showcase-link .ti {
  flex-shrink: 0;
}

.showcase-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.showcase-back,
.showcase-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.showcase-back .ti,
.showcase-edit .ti {
  font-size: 18px;
}

.plan-clickable {
  cursor: pointer;
}

.plan-clickable:active {
  opacity: 0.9;
}

.intro-card {
  cursor: pointer;
}

.wip-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.wip-toast.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.wip-toast .ti {
  font-size: 18px;
}

/* --- Edit page header --- */
.header a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .ti {
  font-size: 20px;
}

/* --- Shared --- */
.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

.muted { color: var(--slate); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--blue-soft);
  padding: 4px 10px;
  font-size: 11px;
  color: var(--blue);
}
.watermark-pill { margin-top: 8px; }
.brand-mark.tiny { width: 16px; height: 16px; display: inline-block; vertical-align: middle; }
.brand-logo.full { height: 28px; width: auto; }

pre {
  width: 100%;
  overflow-x: auto;
  font-size: 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0;
}

/* --- Cropper overrides --- */
.cropper-view-box, .cropper-face { border-radius: 0; }
.cropper-modal { background: transparent; }

/* --- Responsive --- */
@media (max-width: 360px) {
  .field-row { grid-template-columns: 1fr; }
  .nav-item { font-size: 10px; }
  .nav-item .ti { font-size: 18px; }
}

@media (min-width: 390px) {
  .app-shell { padding-left: 18px; padding-right: 18px; }
  .card { padding: 20px 18px; }
}

@media (min-width: 431px) {
  .app-shell { max-width: 430px; margin: 0 auto; }
  .nav-bottom { left: 50%; right: auto; transform: translateX(-50%); max-width: 430px; border-radius: 14px 14px 0 0; }
}
