:root {
  color-scheme: light;
  --ink: #14231f;
  --muted: #63716c;
  --line: #d8e1dd;
  --panel: #ffffff;
  --soft: #f4f8f6;
  --brand: #12613d;
  --brand-dark: #0d422b;
  --warn: #8a4b00;
}

* { box-sizing: border-box; }

#metasync-otto-debug-bar,
.metasync-otto-debug-bar {
  display: none !important;
  pointer-events: none !important;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef4f1;
}

.app-shell {
  min-height: 100vh;
  display: block;
}

@media (min-width: 861px) and (hover: hover) and (pointer: fine) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 420px;
  }
}

body[data-mvr-page="result"] .app-shell {
  display: block;
}

body[data-mvr-page="result"] .preview-pane {
  display: none;
}

body[data-mvr-page="result"] .tool-pane {
  width: min(1180px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  border-left: 0;
}

body[data-mvr-page="result"] .brand,
body[data-mvr-page="result"] .steps {
  display: none;
}

.preview-pane {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  align-items: stretch;
}

.preview-frame {
  position: relative;
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  background: #d9e3df;
  overflow: hidden;
}

.preview-frame canvas,
.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty[hidden] {
  display: none !important;
}

.tool-pane {
  min-height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.brand img {
  width: 38px;
  height: 38px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.steps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dot.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.page {
  display: none;
  gap: 12px;
}

.page.active {
  display: grid;
}

h1 {
  margin: 0;
  font-size: 22px;
}

h2 {
  margin: 0;
  font-size: 16px;
}

.section-title {
  margin-top: 4px;
}

.material-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 7px;
}

#accentControls {
  display: grid;
  gap: 10px;
}

#accentControls[hidden] {
  display: none;
}

.help,
.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.note {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
}

.brand-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.brand-field > strong {
  font-weight: 800;
}

.upload-button {
  cursor: pointer;
  border: 2px dashed var(--brand);
  border-radius: 8px;
  background: #f3faf6;
  padding: 16px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.upload-button:hover,
.upload-button:focus-within {
  border-color: var(--brand-dark);
  background: #eaf6ef;
}

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

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-cta {
  display: grid;
  place-items: center;
  min-height: 58px;
  border-radius: 7px;
  background: var(--brand);
  color: white;
  font-size: 20px;
  font-weight: 900;
}

.upload-file {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: white;
  min-height: 42px;
}

.native-brand-select {
  display: none !important;
}

.brand-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  position: relative;
  z-index: 3;
}

.brand-choice {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(27, 111, 64, 0.18);
  -webkit-user-select: none;
  user-select: none;
}

.brand-choice.active {
  border-color: var(--brand);
  background: #e8f6ef;
  box-shadow: inset 0 0 0 2px var(--brand);
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segment button,
.actions button,
.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 7px;
  padding: 10px 12px;
  min-height: 42px;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
  -webkit-text-fill-color: currentColor;
}

.segment button.active,
.actions button.primary,
button.primary,
.primary {
  border-color: var(--brand) !important;
  background: var(--brand) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.primary {
  border-radius: 7px;
  padding: 12px 14px;
  min-height: 44px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

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

.check-list {
  display: grid;
  gap: 8px;
}

.area-row,
.check-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--soft);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

button.area-row {
  width: 100%;
  text-align: left;
  font: inherit;
}

.area-row.active {
  border-color: var(--brand);
  background: #e8f6ef;
  box-shadow: inset 0 0 0 2px rgba(18, 97, 61, 0.18);
}

.area-number {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #ffffff;
  font-weight: 900;
  font-size: 13px;
}

.area-row input,
.check-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
}

.area-row strong,
.area-row span {
  display: block;
  line-height: 1.35;
}

.area-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.area-row .area-evidence {
  color: #315f4a;
  font-size: 12px;
}

.area-row em {
  display: inline-block;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  color: var(--warn);
  background: #fff4df;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.role-pill {
  color: var(--ink) !important;
  font-weight: 800;
}

.role-controls {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px !important;
}

.role-controls button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.role-controls button[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.role-controls button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 4px;
  background: var(--panel);
  min-height: 66px;
}

.actions button[data-action-label] {
  font-size: 0 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.actions button[data-action-label]::after {
  content: attr(data-action-label);
  display: block !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-size: 16px !important;
  font-weight: 800;
  line-height: 1.15;
  white-space: normal;
}

.actions .primary {
  margin-left: auto;
  min-width: 154px;
}

.summary,
.status {
  display: grid;
  gap: 8px;
}

.summary-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--soft);
}

.summary-row strong,
.summary-row span {
  display: block;
}

.summary-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.price {
  border: 2px solid var(--brand);
  border-radius: 7px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price strong {
  font-size: 22px;
}

.generation-wait {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3faf6;
  text-align: center;
}

.generation-wait[hidden] {
  display: none !important;
}

.generation-wait strong {
  font-size: 20px;
}

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

.pinwheel {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, var(--brand), #33a36f, #d7efe4, var(--brand));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 0);
  animation: pinwheel-spin .85s linear infinite;
}

@keyframes pinwheel-spin {
  to { transform: rotate(1turn); }
}

.compare {
  position: relative;
  width: 100%;
  aspect-ratio: var(--generated-aspect, 4 / 3);
  max-height: calc(100vh - 160px);
  background: #d9e3df;
  overflow: hidden;
  border: 1px solid var(--line);
}

body[data-mvr-page="result"] .compare {
  min-height: min(72vh, 760px);
  max-height: calc(100vh - 190px);
  background: #d9e3df;
}

.compare canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split-x, 50%);
  width: 3px;
  background: white;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
  pointer-events: none;
  transform: translateX(-1.5px);
}

.slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
}

@media (max-width: 860px), (hover: none), (pointer: coarse) {
  .app-shell {
    display: block !important;
  }
  .preview-pane {
    min-height: 36vh;
    padding: 10px;
  }
  .preview-frame {
    min-height: 300px;
  }
  .upload-cta {
    min-height: 64px;
    font-size: 21px;
  }
  .tool-pane {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
    overflow: visible;
  }
  .page.active {
    padding-bottom: 96px;
  }
  .actions {
    position: sticky;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 20;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    box-shadow: 0 12px 36px rgba(20, 35, 31, .18);
    align-items: stretch;
  }
  .actions button {
    flex: 1;
    min-height: 56px;
    font-size: 17px;
  }
  .actions button[data-action-label]::after {
    font-size: 18px !important;
  }
  .actions .primary {
    box-shadow: none;
  }
  .area-row,
  .check-row {
    padding: 12px;
  }
  .actions .primary {
    margin-left: 0;
    min-width: 0;
  }
  body[data-mvr-page="result"] .tool-pane {
    width: 100%;
    padding: 12px 10px calc(130px + env(safe-area-inset-bottom));
  }
  body[data-mvr-page="result"] .compare {
    min-height: min(70vh, 620px);
    max-height: none;
  }
}
