:root {
  --paper: #ffffff;
  --stage: #eef2f5;
  --card: #ffffff;
  --ink: #3a3a3d;
  --ink-soft: #5b5b60;
  --muted: #8a8f98;
  --line: #e7ebef;
  --line-strong: #d3dae1;
  --coral: #f0565f;
  --coral-soft: #fdecee;
  --green: #12bfa3;
  /* logo petal palette */
  --p-orange: #f89828;
  --p-coral: #f0565f;
  --p-yellow: #f5c531;
  --p-green: #7cc24a;
  --p-teal: #2fd3bf;
  --p-blue: #4fa9e4;
  --p-purple: #8e7ed6;
  --p-pink: #e85ca6;
  --brand-gradient: linear-gradient(100deg, var(--p-teal), var(--p-blue) 55%, var(--p-purple));
  --brand-ring: conic-gradient(from 210deg, var(--p-orange), var(--p-coral), var(--p-pink), var(--p-purple), var(--p-blue), var(--p-teal), var(--p-green), var(--p-yellow), var(--p-orange));
  --dark: #0e1116;
  --bench: #14171c;
  --bench-2: #1c2027;
  --bench-line: #2a2f38;
  --bench-text: #e6e3dd;
  --bench-muted: #9aa0aa;
  --radius-card: 20px;
  --h-pad: 40px;
  --font: -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 700px at 18% -10%, #20252d 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 0%, #1b2630 0%, transparent 55%),
    var(--bench);
  color: var(--bench-text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ---------------------------------------------------------------- toolbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(20, 23, 28, 0.88);
  border-bottom: 1px solid var(--bench-line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__dot {
  width: 34px;
  height: 34px;
  background: url("../assets/logo-icon.png") center / contain no-repeat;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand__sub {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--bench-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--bench-line);
  border-radius: 10px;
  background: var(--bench-2);
  font-size: 12px;
  color: var(--bench-muted);
}

.tool select {
  border: 0;
  background: transparent;
  color: var(--bench-text);
  font-size: 13px;
  outline: none;
  font-family: var(--font);
}

.tool select option {
  background: #1c2027;
}

.tool--switch {
  cursor: pointer;
  user-select: none;
}

.tool--switch input {
  accent-color: var(--green);
  margin: 0;
}

.btn {
  font-family: var(--font);
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

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

.btn--ghost {
  background: transparent;
  border-color: var(--bench-line);
  color: var(--bench-text);
}

.btn--ghost:hover {
  background: #232830;
}

.btn--primary {
  width: 100%;
  margin-top: 12px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 16px;
}

.btn--primary:hover {
  filter: brightness(1.06);
}

.btn--disabled,
.btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ stage */

.stage {
  display: flex;
  gap: 34px;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 32px 56px;
}

.deviceArea {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.deviceWrap {
  position: relative;
  width: 100%;
  min-height: 320px;
}

.device {
  --frame-thickness: 26px;
  position: absolute;
  top: 0;
  left: 50%;
  width: 800px;
  height: 1280px;
  flex: none;
  padding: var(--frame-thickness);
  box-sizing: border-box;
  border-radius: 20px;
  overflow: hidden;
  transform: translateX(-50%) scale(1);
  transform-origin: top center;
  /* Light walnut wood: warm tan base + vertical grain + horizontal grain + edge vignette */
  background-color: #b9884f;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 240, 210, 0.18), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(60, 35, 10, 0.22), transparent 50%),
    repeating-linear-gradient(91deg,
      rgba(90, 55, 20, 0.00) 0px,
      rgba(90, 55, 20, 0.00) 2px,
      rgba(90, 55, 20, 0.05) 3px,
      rgba(90, 55, 20, 0.00) 6px,
      rgba(255, 230, 190, 0.04) 8px,
      rgba(90, 55, 20, 0.00) 11px),
    repeating-linear-gradient(178deg,
      rgba(120, 75, 30, 0.00) 0px,
      rgba(120, 75, 30, 0.00) 14px,
      rgba(120, 75, 30, 0.06) 16px,
      rgba(120, 75, 30, 0.00) 22px,
      rgba(255, 235, 200, 0.03) 26px,
      rgba(120, 75, 30, 0.00) 34px),
    linear-gradient(135deg, #c69a5e 0%, #b07c44 35%, #a67238 60%, #c29356 100%);
  background-blend-mode: normal, normal, multiply, soft-light, normal;
  box-shadow:
    /* outer drop shadow */
    0 44px 96px rgba(0, 0, 0, 0.6),
    0 12px 30px rgba(0, 0, 0, 0.45),
    /* outer rim highlight (top-left light) */
    inset 0 1px 0 rgba(255, 240, 215, 0.35),
    inset 0 -1px 0 rgba(60, 35, 10, 0.35),
    inset 1px 0 0 rgba(255, 235, 200, 0.18),
    inset -1px 0 0 rgba(60, 35, 10, 0.28),
    /* recessed screen: dark inner shadow right at the screen opening */
    inset 0 0 0 1px rgba(40, 22, 6, 0.55),
    inset 0 4px 10px rgba(40, 22, 6, 0.45),
    inset 0 -2px 6px rgba(40, 22, 6, 0.35);
  transition: width 0.2s ease, height 0.2s ease;
}

.device--small {
  --frame-thickness: 18px;
}

.veil {
  position: absolute;
  inset: var(--frame-thickness);
  z-index: 25;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.screenHost {
  position: absolute;
  inset: var(--frame-thickness);
  overflow: hidden;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.stageHint {
  margin: 22px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--bench-muted);
  line-height: 1.7;
  max-width: 620px;
}

/* ------------------------------------------------------------ phone stage */

.phoneStage {
  --phone-scale: 0.78;
  width: calc(390px * var(--phone-scale) + 26px);
  flex: none;
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phoneStage__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bench-line);
}

.phoneHead__logo {
  width: 32px;
  height: 32px;
  flex: none;
  background: url("../assets/logo-icon.png") center / contain no-repeat;
}

.phoneStage__title {
  flex: 1;
  min-width: 0;
}

.phoneStage__title strong {
  display: block;
  font-size: 13px;
}

.phoneStage__title span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--bench-muted);
}

.phoneStage__open {
  flex: none;
  font-size: 11px;
  color: var(--bench-muted);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}

.phoneStage__open:hover {
  color: var(--bench-text);
}

.phoneBezel {
  padding: 9px;
  border-radius: calc(390px * var(--phone-scale) * 0.145);
  background: linear-gradient(160deg, #2b3038 0%, #14171c 55%, #0c0e12 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 30px 60px rgba(0, 0, 0, 0.55);
}

.phoneViewport {
  position: relative;
  width: calc(390px * var(--phone-scale));
  height: calc(844px * var(--phone-scale));
  border-radius: calc(390px * var(--phone-scale) * 0.125);
  overflow: hidden;
  background: #fff;
}

/* island / notch */
.phoneViewport::before {
  content: "";
  position: absolute;
  top: calc(844px * var(--phone-scale) * 0.012);
  left: 50%;
  transform: translateX(-50%);
  width: calc(390px * var(--phone-scale) * 0.21);
  height: calc(844px * var(--phone-scale) * 0.028);
  border-radius: 999px;
  background: #0b0d10;
  z-index: 3;
  pointer-events: none;
}

.phoneApp {
  width: 390px;
  height: 844px;
  border: 0;
  display: block;
  transform-origin: top left;
  transform: scale(var(--phone-scale));
  background: #fff;
}

/* ------------------------------------------------------------------ modal */

.modalLayer {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  background: rgba(40, 42, 46, 0.42);
  animation: fadeIn 0.18s ease;
}

.modalCard {
  width: 100%;
  max-width: 640px;
  padding: 28px;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.25);
  animation: sheetUp 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modalCard h3 {
  margin: 0;
  font-size: 22px;
}

.modalCard p {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.fieldLabel {
  display: block;
  margin: 18px 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.textField {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  font-family: var(--font);
  color: var(--ink);
  background: #f6f8fa;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
}

.textField:focus {
  border-color: var(--green);
}

.textField:disabled {
  color: var(--ink-soft);
  opacity: 0.8;
}

.fieldError {
  margin-top: 8px;
  font-size: 12px;
  color: var(--coral);
  min-height: 16px;
}

.modalActions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.modalActions .btn {
  flex: 1;
  padding: 14px 16px;
  font-size: 15px;
}

.btn--soft {
  background: var(--stage);
  border-color: var(--line-strong);
  color: var(--ink);
}

/* --------------------------------------------------------------- utilities */

.is-hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
  flex: none;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1180px) {
  .stage {
    gap: 22px;
    padding: 22px 18px 44px;
  }
}

@media (max-width: 900px) {
  .stage {
    flex-direction: column;
    align-items: center;
  }

  .phoneStage {
    position: static;
    margin-top: 10px;
  }

  .topbar {
    padding: 14px 16px;
  }
}

/* ----------------------------------------------------- embed (frame wall) */

/* ?embed=1 strips the simulator chrome so multi.html can tile many frames in
   iframes — only the wooden frame itself stays. */
html.embed .topbar,
html.embed .phoneStage,
html.embed .stageHint {
  display: none;
}

html.embed body {
  min-height: 0;
}

html.embed .stage {
  display: block;
  padding: 8px;
}
