/* ─── Fonts ─────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: "Sora";
  src: url("../../assets/fonts/Sora-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Sora";
  src: url("../../assets/fonts/Sora-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Sora";
  src: url("../../assets/fonts/Sora-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/OpenSans-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/OpenSans-Italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/OpenSans-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/OpenSans-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:        #f4f5f7;
  --color-panel:     #ffffff;
  --color-border:    #e0e2e8;
  --color-header:    #1a1a2e;
  --color-accent:    #4361ee;
  --color-accent-dk: #3451d1;
  --color-text:      #1a1a2e;
  --color-muted:     #6b7280;
  --radius:          8px;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --font-ui:         "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-head:       "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --panel-width:     340px;
}

html { height: 100%; }

body {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
header {
  background: var(--color-header);
  color: #fff;
  padding: 16px 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  z-index: 100;
}

.header-logo { line-height: 0; color: #fff; }
.header-logo svg { height: 19px; width: auto; display: block; }

.header-inner h1 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
}

.header-inner p {
  font-size: 12px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.header-all-apps {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  white-space: nowrap;
  justify-self: end;
  transition: color .15s;
}
.header-all-apps:hover { color: #fff; }

/* ─── Footer ───────────────────────────────────────────────────────────────── */
footer {
  padding: 16px 28px;
  font-size: 12px;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

footer a { color: var(--color-muted); text-decoration: none; }
footer a:hover { color: var(--color-accent); }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
main {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ─── Form panel ───────────────────────────────────────────────────────────── */
.form-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding-bottom: 40px;
}

.form-panel::-webkit-scrollbar { width: 5px; }
.form-panel::-webkit-scrollbar-track { background: transparent; }
.form-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ─── Form sections ────────────────────────────────────────────────────────── */
.form-section {
  border-bottom: 1px solid var(--color-border);
}

.section-title {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-muted);
  padding: 14px 20px;
  user-select: none;
}

.section-body { padding: 0 20px 20px; }

.hint {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ─── Dimension pair ───────────────────────────────────────────────────────── */
.dim-pair {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.dim-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dim-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
}

.dim-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dim-input-wrap input[type="number"] {
  width: 100%;
  padding: 9px 32px 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -moz-appearance: textfield;
}

.dim-input-wrap input[type="number"]::-webkit-inner-spin-button,
.dim-input-wrap input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.dim-input-wrap input[type="number"]:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

.dim-unit {
  position: absolute;
  right: 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  pointer-events: none;
}

.dim-sep {
  font-size: 20px;
  color: var(--color-muted);
  padding-bottom: 8px;
  flex-shrink: 0;
  line-height: 1;
}

/* ─── Ratio badge ──────────────────────────────────────────────────────────── */
.ratio-badge {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 12px;
  background: rgba(67,97,238,.08);
  border: 1px solid rgba(67,97,238,.2);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--color-accent);
  letter-spacing: .5px;
}

/* ─── Scale stats ──────────────────────────────────────────────────────────── */
.scale-stats {
  display: flex;
  gap: 16px;
}

.stat {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--color-text);
  line-height: 1;
}

/* ─── Preview panel ────────────────────────────────────────────────────────── */
.preview-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.visual-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ─── Rectangle scene ──────────────────────────────────────────────────────── */
.rect-scene {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ratio-rect {
  background: var(--color-accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-md);
  transition: width .25s ease, height .25s ease;
  min-width: 40px;
  min-height: 40px;
}

.rect-dims {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  text-align: center;
  padding: 8px;
  pointer-events: none;
  white-space: nowrap;
}

/* ─── Mobile (≤768px) ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { height: auto; min-height: 100%; display: block; overflow: visible; }

  main {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .form-panel {
    width: 100%;
    min-width: 0;
    overflow-y: visible;
    padding-bottom: 20px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .preview-panel {
    overflow-y: visible;
    min-height: 300px;
  }

  .visual-area {
    padding: 24px;
    min-height: 280px;
  }

  header {
    grid-template-columns: 1fr;
    padding: 14px 20px;
    gap: 6px;
    text-align: center;
  }
  .header-logo    { order: -1; justify-self: center; }
  .header-inner   { order: 0; }
  .header-all-apps { order: 1; justify-self: center; }
  .header-inner p { display: block; font-size: 11px; }
  .header-inner h1 { font-size: 16px; }
}
