:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #172033;
  --text-soft: #64748b;
  --border: #dce4ee;
  --primary: #0b76ff;
  --primary-dark: #0758c8;
  --danger: #c5163d;
  --warning: #9a5b00;
  --radius: 18px;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

.brand-line {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #009df7, #00ba9e, #7bd600, #ffb100, #ff6c00, #fb2717, #ff0076);
}

.tool-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(22px, calc((100% - 1220px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 118px;
}

.brand span {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-size: 0.9rem;
}

.back-link {
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 750;
  text-decoration: none;
}

main {
  width: min(calc(100% - 40px), 1220px);
  margin: 0 auto;
  padding: 68px 0 90px;
}

.tool-intro {
  max-width: 820px;
  margin-bottom: 34px;
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tool-intro h1 {
  margin: 11px 0 13px;
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: -0.06em;
}

.tool-intro p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1.08rem;
}

.tool-panel {
  display: grid;
  grid-template-columns: minmax(270px, 0.72fr) minmax(0, 1.28fr);
  gap: 34px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.instructions {
  padding: 3px 25px 3px 3px;
  border-right: 1px solid var(--border);
}

.instructions h2,
.preview-heading h2 {
  margin: 0 0 14px;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
}

.instructions ol {
  margin: 0;
  padding-left: 21px;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.instructions li + li {
  margin-top: 10px;
}

.tester-form {
  display: grid;
  gap: 16px;
}

.tester-form label:not(.file-drop-area) {
  display: grid;
  gap: 6px;
}

.tester-form label > span {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
}

.tester-form select,
.tester-form input[type="number"] {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

.tester-form select:focus,
.tester-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 118, 255, 0.12);
}

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

.file-drop-area {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  gap: 17px;
  padding: 22px;
  border: 2px dashed #b9c8da;
  border-radius: 16px;
  background: #f8fbff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.file-drop-area:hover,
.file-drop-area.is-dragging {
  border-color: var(--primary);
  background: #edf5ff;
}

.file-drop-area input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop-area img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.file-drop-area > span {
  display: grid;
  gap: 3px;
}

.file-drop-area strong {
  max-width: 390px;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop-area small {
  color: var(--text-soft);
  font-size: 0.75rem;
}

.notice {
  padding: 12px 14px;
  border: 1px solid #f0d7a7;
  border-radius: 11px;
  background: #fff8e9;
  color: var(--warning);
  font-size: 0.82rem;
  font-weight: 700;
}

.notice-error {
  border-color: #f3c2cd;
  background: #fff1f4;
  color: var(--danger);
}

.preview-section {
  margin-top: 48px;
}

.preview-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.preview-heading h2 {
  margin: 6px 0 0;
}

.status {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 750;
}

.preview-viewport {
  overflow: auto;
  min-height: 620px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background:
    linear-gradient(45deg, #e8edf4 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf4 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf4 75%),
    #f5f8fc;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.creative {
  position: relative;
  width: var(--creative-width);
  min-width: var(--creative-width);
  height: calc(var(--creative-height) + 80px);
  margin: 0 auto;
}

.portal-header {
  display: grid;
  width: var(--creative-width);
  min-height: 80px;
  place-items: center;
  overflow: hidden;
}

.portal-header img {
  display: block;
  max-width: 1366px;
  max-height: 80px;
  object-fit: cover;
}

.preview-stage {
  position: relative;
  width: var(--creative-width);
  height: var(--creative-height);
  overflow: hidden;
  background: #dfe7f1;
}

.preview-stage iframe {
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 0;
  background: transparent;
}

.site-print {
  position: absolute;
  z-index: 2;
  top: var(--opening);
  left: 50%;
  pointer-events: none;
}

.cold-area {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: var(--creative-width);
  height: var(--creative-height);
  pointer-events: none;
}

.cold {
  position: absolute;
  background: rgba(220, 20, 60, 0.43);
}

.cold-left {
  top: 0;
  left: 0;
  height: var(--creative-height);
}

.cold-right {
  top: 0;
  height: var(--creative-height);
}

.cold-bottom {
  top: 626px;
}

.loading-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #d7e5f7;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 850px) {
  main {
    width: min(calc(100% - 26px), 1220px);
    padding-top: 48px;
  }

  .tool-panel {
    grid-template-columns: 1fr;
  }

  .instructions {
    padding: 0 0 24px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 560px) {
  .tool-header {
    min-height: 68px;
    padding: 0 14px;
  }

  .brand img {
    width: 100px;
  }

  .brand span {
    display: none;
  }

  .back-link {
    font-size: 0.76rem;
  }

  .tool-intro h1 {
    font-size: 2.7rem;
  }

  .tool-panel {
    padding: 20px;
  }

  .dimension-grid {
    grid-template-columns: 1fr;
  }

  .file-drop-area {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-viewport {
    min-height: 500px;
    padding: 15px;
  }
}

/* Light and dark theme */
.tool-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--surface-soft, #f8fafc);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(11, 118, 255, 0.2);
  outline-offset: 2px;
}

.theme-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-icon-moon {
  display: none;
}

.brand img {
  filter: brightness(0) saturate(100%);
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-soft: #172033;
  --text: #e7eef8;
  --text-soft: #9eacc0;
  --border: #28364b;
  --primary: #5ba6ff;
  --primary-dark: #91c4ff;
  --danger: #ff7895;
  --warning: #ffc466;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-icon-moon {
  display: block;
}

html[data-theme="dark"] .brand img {
  filter: none;
}

html[data-theme="dark"] .tool-header {
  background: rgba(11, 17, 32, 0.92);
}

html[data-theme="dark"] .tester-form label > span {
  color: var(--text-soft);
}

html[data-theme="dark"] .tester-form select,
html[data-theme="dark"] .tester-form input[type="number"] {
  background: #0e1728;
  color: var(--text);
  color-scheme: dark;
}

html[data-theme="dark"] .file-drop-area {
  border-color: #42536b;
  background: #101a2c;
}

html[data-theme="dark"] .file-drop-area:hover,
html[data-theme="dark"] .file-drop-area.is-dragging {
  background: #142641;
}

html[data-theme="dark"] .notice {
  border-color: #6b5125;
  background: #2a2112;
}

html[data-theme="dark"] .notice-error {
  border-color: #693247;
  background: #2d1520;
}

html[data-theme="dark"] .preview-viewport {
  background:
    linear-gradient(45deg, #151f30 25%, transparent 25%),
    linear-gradient(-45deg, #151f30 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151f30 75%),
    linear-gradient(-45deg, transparent 75%, #151f30 75%),
    #0f1828;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] .loading-overlay {
  background: rgba(5, 9, 20, 0.84);
}

html[data-theme="dark"] .spinner {
  border-color: #29405e;
  border-top-color: var(--primary);
}

@media (max-width: 650px) {
  .tool-header-actions {
    gap: 8px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }
}
