﻿:root {
  --bg-top: #f5efe6;
  --bg-bottom: #e7ddd1;
  --panel: rgba(255, 250, 244, 0.82);
  --line: #ddcfbf;
  --line-strong: #c8b299;
  --text: #2f241f;
  --muted: #746257;
  --accent: #8e5d47;
  --accent-dark: #6c4331;
  --accent-soft: #f1e5d9;
  --shadow: 0 22px 60px rgba(76, 53, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.75), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.phone-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  padding: 24px 18px 120px;
  display: grid;
  gap: 16px;
}

.budget-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(200, 178, 153, 0.68);
  border-radius: 20px;
  background: rgba(48, 36, 31, 0.92);
  color: #f8eee4;
  box-shadow: var(--shadow);
}

.budget-label {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d8b69f;
}

.budget-bar strong {
  font-size: 22px;
}

.budget-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  font-size: 12px;
  color: #dbc8ba;
  text-align: right;
}

.hero-card,
.panel,
.sticky-bar,
.sticky-sketch-dock {
  border: 1px solid rgba(200, 178, 153, 0.68);
  box-shadow: 0 10px 24px rgba(76, 53, 39, 0.08);
}

.hero-card {
  padding: 22px 20px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.96), rgba(249, 239, 227, 0.92));
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-card h1,
.panel h2,
.field-group h3 {
  margin: 0;
}

.hero-card h1 {
  font-size: 28px;
  line-height: 1.05;
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-note {
  margin: 12px 0 0;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

.panel {
  padding: 18px;
  border-radius: 24px;
  background: var(--panel);
}

.form-panel.is-hidden {
  display: none;
}

.summary-panel.is-hidden {
  display: none;
}

.sticky-sketch-dock {
  position: sticky;
  top: 12px;
  z-index: 5;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255, 250, 244, 0.96);
}

.sticky-sketch-dock.is-hidden {
  display: none;
}

.sticky-sketch-dock img {
  width: 100%;
  max-width: 100%;
  max-height: 180px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 14px;
  background: #efe4d8;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 20px;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff9f4;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill-soft {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.source-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.source-action-button {
  width: 100%;
  padding: 14px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(77, 136, 255, 0.65);
  color: var(--accent-dark);
  font-weight: 700;
}

.source-action-button-archive {
  border-color: rgba(185, 106, 61, 0.55);
}

.source-action-button-archive.is-active {
  border-color: #b96a3d;
  box-shadow: 0 0 0 3px rgba(185, 106, 61, 0.14);
}

.preview-card {
  margin-top: 14px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.rotate-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.rotate-controls.is-hidden {
  display: none;
}

.rotate-button {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 700;
}

.preview-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  background: #efe4d8;
}

.preview-card.is-empty img {
  display: none;
}

.preview-card.is-empty {
  display: none;
}

.preview-card.is-hidden-after-load {
  display: none;
}

.preview-title {
  margin: 0;
  font-weight: 700;
}

.preview-meta {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.field-group {
  display: grid;
  gap: 12px;
}

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

.dimensions-row-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-group + .field-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.field-group h3 {
  font-size: 16px;
}

.construction-summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.is-hidden {
  display: none;
}

.field-checkbox {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.field-checkbox input {
  width: 20px;
  height: 20px;
}

.field span {
  font-size: 14px;
  color: var(--muted);
}

.section-width-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.section-width-row .field {
  min-width: 0;
}

.section-width-field input {
  text-align: center;
}

.section-width-field.is-fixed span {
  color: var(--accent-dark);
}

.section-width-field.is-fixed input {
  background: rgba(47, 36, 31, 0.08);
  color: var(--muted);
  border-color: rgba(200, 178, 153, 0.9);
}

.section-width-field input:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.section-inline-action {
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: #d44631;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(142, 93, 71, 0.18);
  border-color: var(--accent);
}

.sections-editor {
  display: grid;
  gap: 10px;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.section-toggle-text {
  display: grid;
  gap: 4px;
  text-align: left;
}

.section-toggle-title {
  font-weight: 700;
}

.section-toggle-meta {
  color: var(--muted);
  font-size: 13px;
}

.section-toggle-icon {
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
}

.section-body {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
}

.section-card.is-collapsed .section-body {
  display: none;
}

.section-card.is-collapsed .section-toggle {
  padding-bottom: 14px;
}

.summary-panel pre {
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  background: #2f241f;
  color: #f7ede3;
  overflow: auto;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.summary-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-action-button {
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 700;
}

.summary-description {
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  white-space: pre-line;
  line-height: 1.45;
}

.summary-panel pre.is-hidden {
  display: none;
}

.sticky-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 456px);
  padding: 12px;
  border-radius: 24px;
  background: rgba(255, 250, 244, 0.98);
}

button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff9f4;
  font-weight: 700;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.secondary-button {
  margin-top: 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 2px solid #4d88ff;
  box-shadow: 0 0 0 3px rgba(77, 136, 255, 0.12);
}

.secondary-button:disabled {
  opacity: 0.75;
  cursor: wait;
}

.secondary-button.is-loading {
  position: relative;
}

.secondary-button.is-hidden {
  display: none;
}

.secondary-button.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  margin-left: 10px;
  display: inline-block;
  vertical-align: -3px;
  border-radius: 50%;
  border: 2px solid rgba(77, 136, 255, 0.25);
  border-top-color: #4d88ff;
  animation: spin 0.8s linear infinite;
}

.action-status {
  margin: 10px 2px 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.action-status.is-success {
  color: #3c6f47;
}

.action-status.is-error {
  color: #9b3d35;
}

.archive-picker {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.archive-picker-label {
  font-size: 14px;
  color: var(--muted);
}

.archive-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.archive-empty {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.archive-item {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.archive-item-thumb {
  width: 62px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  background: #eee2d5;
}

.archive-item-title {
  font-size: 14px;
  line-height: 1.25;
  color: var(--accent-dark);
}

.archive-item.is-selected {
  border-color: #b96a3d;
  box-shadow: 0 0 0 2px rgba(185, 106, 61, 0.2);
}

.archive-preview {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.archive-preview img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #efe4d8;
}

.archive-picker.is-active .archive-item,
.archive-picker.is-active .archive-preview,
.archive-picker.is-active .archive-load-button {
  border-color: #b96a3d;
  box-shadow: 0 0 0 3px rgba(185, 106, 61, 0.14);
}

.archive-load-button {
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 700;
}

.archive-picker.is-hidden {
  display: none;
}

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

@media (min-width: 700px) {
  .phone-shell {
    padding-top: 32px;
  }
}

@media (max-width: 640px) {
  .budget-bar {
    box-shadow: 0 8px 18px rgba(76, 53, 39, 0.08);
  }

  .hero-card,
  .panel {
    border-radius: 22px;
  }

  .preview-card,
  .section-card,
  .construction-summary {
    background: rgba(255, 255, 255, 0.9);
  }

  .sticky-sketch-dock {
    top: 8px;
    padding: 6px;
  }

  .sticky-bar {
    bottom: 10px;
    padding: 10px;
  }
}

@media (max-width: 420px) {
  .dimensions-row {
    grid-template-columns: 1fr;
  }

  .dimensions-row-two {
    grid-template-columns: 1fr;
  }

  .summary-toolbar {
    grid-template-columns: 1fr;
  }
}
