/* CONV: the house frame in a deep slate-teal, with the tool's own glass working surface. */

.house-frame:has(.conv-cover) {
  --cover-a: #24505c;
  --cover-b: #0e232c;
  --cover-glow: rgba(118, 204, 214, .3);
  --cover-warm: rgba(255, 207, 102, .14);
  --accent: #2a6a80;
  --conv-ink: #22394a;
  --conv-muted: #536a78;
  --conv-blue: #1d5f9e;
  --conv-edge: #8ba7b8;
  --conv-field: #f6f9fb;
}

/* The working surface. */
.conv-body { padding-top: 32px; }
.conv-tool { min-width: 0; color: var(--conv-ink); font: 13px/1.5 var(--h-sans); }
.conv-tool [hidden] { display: none !important; }
.conv-tool *, .conv-tool *::before, .conv-tool *::after { box-sizing: border-box; }
.conv-small { font-size: 12.5px; line-height: 1.5; color: var(--conv-muted); }
.conv-tool label { font-size: 13px; }
.conv-tool select,
.conv-tool input[type="number"] {
  min-height: 34px; min-width: 0; max-width: 100%; padding: 6px 8px;
  color: var(--conv-ink); font: 13px var(--h-sans); font-variant-numeric: tabular-nums;
  background: var(--conv-field); border: 1px solid var(--conv-edge); border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(34, 57, 74, .14);
}
.conv-tool input[type="range"] { accent-color: var(--conv-blue); }
.conv-tool input[type="checkbox"] { accent-color: var(--conv-blue); }

/* Small glass keys for presets, zoom and cancel; the house buttons carry the main actions. */
.conv-key, .conv-modes button {
  min-height: 34px; padding: 6px 12px; cursor: pointer;
  color: #17486f; font: 600 13px/1.2 var(--h-sans);
  background: linear-gradient(#f7fcff, #cfe2ef); border: 1px solid #86a7bd; border-radius: 5px;
  box-shadow: inset 0 1px #fff, 0 1px 2px rgba(34, 64, 90, .16);
}
.conv-key:hover, .conv-modes button:hover { background: linear-gradient(#fff, #dcebf6); border-color: #4b84b3; }
.conv-key:active, .conv-modes button:active { box-shadow: inset 0 2px 4px rgba(34, 64, 90, .3); }
.conv-key:disabled { opacity: .5; cursor: default; }
.conv-key[aria-pressed="true"], .conv-modes button[aria-pressed="true"] {
  color: #fff; background: linear-gradient(#5d8fb0, #2e6489); border-color: #2b5a7b;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .25);
}
.conv-tool .house-btn { cursor: pointer; }
.conv-tool .house-btn:disabled { opacity: .5; cursor: default; }

.conv-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 14px; }
.conv-toolbar > label:not(.conv-file) { display: flex; gap: 8px; align-items: center; }
.conv-file { position: relative; overflow: hidden; margin: 0; }
.conv-file input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.conv-file:focus-within { outline: 3px solid var(--h-focus); outline-offset: 3px; }

.conv-modes { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 14px; }
.conv-modes button { border-radius: 0; margin-left: -1px; padding: 8px 16px; font-size: 14px; }
.conv-modes button:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
.conv-modes button:last-child { border-radius: 0 5px 5px 0; }

.work-progress { margin: 0 0 14px; }
.progress-caption { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; font-size: 12.5px; color: var(--conv-muted); }
.progress-caption #progress-label { flex: 1; }
.progress-caption .conv-key { min-height: 28px; padding: 3px 10px; font-size: 12px; }
#progress-value { font-variant-numeric: tabular-nums; }
#progress-bar { display: block; width: 100%; height: 7px; border: 0; border-radius: 4px; overflow: hidden; background: #c3d5df; accent-color: var(--conv-blue); }
#progress-bar::-webkit-progress-bar { background: #c3d5df; }
#progress-bar::-webkit-progress-value { background: linear-gradient(90deg, #2f6f9f, #4fa0b3); }
#progress-bar::-moz-progress-bar { background: #2f6f9f; }
.work-progress[data-error="true"] .progress-caption { color: #982f25; }

/* Opalescent glass housing for the controls and the viewer. */
.workspace {
  display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 22px; padding: 20px;
  border: 1px solid rgba(255, 255, 255, .9); border-radius: 10px;
  background: linear-gradient(140deg, rgba(247, 252, 255, .92), rgba(205, 225, 234, .55) 42%, rgba(242, 248, 251, .8));
  box-shadow: inset 0 1px #fff, 0 0 0 1px rgba(110, 140, 160, .28), 0 10px 28px rgba(30, 60, 80, .18);
}
.settings { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings > canvas { width: 100%; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; background: #d3e0e7; border: 1px solid var(--conv-edge); }
.settings > p { margin: -6px 0 0; }
.settings label, .conv-group label { display: flex; flex-direction: column; gap: 5px; }
.settings .check { flex-direction: row; align-items: center; gap: 7px; }
.settings select { width: 100%; }
.conv-group { display: flex; flex-direction: column; gap: 14px; }
.conv-size { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.conv-size legend { padding: 0 0 6px; font-weight: 700; }
.conv-size p { margin: 0; }
.conv-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.conv-presets .conv-key { padding: 6px 0; }
.output-dimensions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.output-dimensions label { display: grid; gap: 5px; min-width: 0; }
.output-dimensions input { width: 100%; }
.exports { display: grid; gap: 8px; }
.exports .house-btn { justify-content: center; }

.display { min-width: 0; }
.display-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.display-head span { color: var(--conv-muted); font-size: 12px; text-align: right; }
.scene { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 12px; align-items: stretch; max-width: 724px; margin: 0 auto; }
.stage {
  position: relative; width: 100%; aspect-ratio: 1; min-height: 220px; max-height: 660px; margin-inline: auto; overflow: hidden;
  touch-action: none; cursor: grab; outline: 1px solid var(--conv-edge);
  background-color: #d3e0e5;
  background-image: linear-gradient(45deg, rgba(185, 204, 212, .6) 25%, transparent 25%), linear-gradient(-45deg, rgba(185, 204, 212, .6) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(185, 204, 212, .6) 75%), linear-gradient(-45deg, transparent 75%, rgba(185, 204, 212, .6) 75%);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  box-shadow: inset 0 2px 9px rgba(21, 47, 65, .16);
}
.stage.panning { cursor: grabbing; }
.stage canvas, .stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.stage svg { overflow: visible; }
#comparison-overlay { clip-path: inset(0 100% 0 0); }
#outline { fill: none; stroke: #76b8e7; stroke-width: 1.5; }
#grid-lines { stroke: #e2f7ff; stroke-width: 1; opacity: .45; }
.corner {
  position: absolute; width: 28px; height: 28px; padding: 0; transform: translate(-50%, -50%); touch-action: none; cursor: grab;
  border: 2px solid #ebf9ff; border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #f6ffff, #9dcefa 40%, #357bb9); box-shadow: 0 2px 5px rgba(22, 66, 98, .53);
}
.corner:active, .edge-handle:active, .edge-hit:active, .rotation-handle:active { cursor: grabbing; }
.edge-hit { stroke: transparent; stroke-width: 22; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: grab; touch-action: none; }
.edge-handle {
  position: absolute; width: 32px; height: 14px; padding: 0; transform: translate(-50%, -50%) rotate(var(--angle, 0rad)); touch-action: none; cursor: grab;
  border: 2px solid #ebf9ff; border-radius: 6px; background: linear-gradient(#bce4ff, #357bb9); box-shadow: 0 2px 5px rgba(22, 66, 98, .4);
}
#rotation-stem { stroke: #76b8e7; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.rotation-handle {
  position: absolute; width: 30px; height: 30px; padding: 0; transform: translate(-50%, -50%); touch-action: none; cursor: grab;
  color: #17486f; font-size: 23px; line-height: 25px;
  border: 2px solid #ebf9ff; border-radius: 50%; background: linear-gradient(#e3f8ff, #86bde6); box-shadow: 0 2px 5px rgba(22, 66, 98, .4);
}
.conv-tool:not([data-mode="warp"]) :is(#overlay, .corner, .edge-handle, .rotation-handle) { display: none; }
.conv-tool:not([data-mode="warp"]) .stage { touch-action: pan-y; }

.zoom-rail { display: flex; flex-direction: column; align-items: center; gap: 9px; min-height: 220px; padding: 7px 0; }
.zoom-rail label, .zoom-rail output { font-size: 12px; font-variant-numeric: tabular-nums; }
.zoom-rail input { flex: 1; width: 24px; min-height: 100px; writing-mode: vertical-lr; direction: rtl; }
.zoom-rail .conv-key { width: 50px; padding: 7px 0; }
.view-note { min-height: 2.8em; margin: 10px 0 0; color: var(--conv-muted); font-size: 12px; line-height: 1.5; }
.reveal-control, .rotation-control { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.reveal-control input, .rotation-control > input { flex: 1; min-width: 40px; }
.reveal-control output { width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.angle-input { display: flex; align-items: center; gap: 4px; }
.angle-input input { width: 76px; }
.coordinates { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.coordinates label { display: flex; align-items: center; gap: 7px; }
.coordinates input { width: 84px; }
.hint { margin: 12px 0 0; color: var(--conv-muted); font-size: 12.5px; line-height: 1.6; }

.compare-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; align-items: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(110, 140, 160, .35); }
.compare-row canvas { width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; background: #d3e0e5; }
.compare-row h2 { margin: 0 0 6px; font: 600 17px/1.3 var(--h-serif); }
.compare-row p { margin: 6px 0; font-size: 12.5px; line-height: 1.6; }
.readings { margin: 10px 0; font-size: 12.5px; }
.readings > div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.readings dd { margin: 0; font-variant-numeric: tabular-nums; }

.status-strip { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 14px 2px 6px; font-size: 12.5px; }
.status-strip p { margin: 0; }
#status[data-error="true"] { color: #982f25; }
#timing { color: var(--conv-muted); text-align: right; }
.audit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding: 12px 2px 0; border-top: 1px solid rgba(110, 140, 160, .35); }
.audit div { display: grid; gap: 6px; }
.audit span { color: var(--conv-muted); font-size: 12px; }
.audit strong { font-size: 15px; font-weight: 400; font-variant-numeric: tabular-nums; }

/* The ringing figure. */
.conv-ringing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.conv-ringing figure { min-width: 0; margin: 0; }
.conv-ringing svg { display: block; width: 100%; height: auto; padding: 8px; background: linear-gradient(#fbfdfe, #f0f5f8); border: 1px solid #c9d6e0; border-radius: 3px; box-sizing: border-box; }
.conv-ringing figcaption { margin-top: 8px; color: var(--h-muted); font: 15px/1.45 var(--h-serif); }
.ring-axis { fill: none; stroke: rgba(34, 57, 74, .24); stroke-width: 2; }
.ring-guide { fill: none; stroke: rgba(34, 57, 74, .25); stroke-width: 3; stroke-dasharray: 7 7; }
.ring-step { fill: none; stroke: var(--conv-ink); stroke-width: 4; }
.ring-samples circle { fill: var(--conv-ink); stroke: #fff; stroke-width: 3; }
.ring-curve { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-curve--linear { stroke: #c4493f; }
.ring-curve--conv { stroke: #1f7a80; }
.ring-turns circle { fill: #f0b84c; stroke: #c4493f; stroke-width: 3; }

.conv-figure { margin: 22px 0 0; max-width: 760px; }
.conv-figure img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid #c9d6e0; border-radius: 3px; box-shadow: 0 8px 22px rgba(22, 31, 52, .12); }
.conv-figure figcaption { margin-top: 10px; max-width: 68ch; color: var(--h-muted); font: 15px/1.5 var(--h-serif); }

@media (min-width: 950px) { .stage { max-width: 660px; } }
@media (max-width: 760px) {
  .conv-body { padding-left: 12px; padding-right: 12px; }
  .conv-body > .house-section { padding: 0 8px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 12px; }
  .settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .settings > canvas { max-width: 120px; }
  .settings > p { align-self: center; margin: 0; }
  .conv-size, .conv-group, .exports, .settings > output, .settings > label { grid-column: 1 / -1; }
  .conv-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .scene { grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
  .zoom-rail .conv-key { width: 43px; }
  .compare-row { grid-template-columns: 110px minmax(0, 1fr); gap: 14px; }
  .status-strip { flex-direction: column; gap: 6px; }
  #timing { text-align: left; }
  .audit { gap: 10px; }
  .audit strong { font-size: 13px; }
  .corner { width: 30px; height: 30px; }
  .conv-ringing { grid-template-columns: minmax(0, 1fr); }
  .conv-ringing figure { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; align-items: center; }
  .conv-ringing figcaption { margin: 0; }
}
@media (max-width: 420px) {
  .conv-modes button { padding: 8px 10px; font-size: 13px; }
  .coordinates label:first-child { width: 100%; }
  .coordinates select { flex: 1; }
  .compare-row { grid-template-columns: 90px minmax(0, 1fr); }
  .conv-ringing figure { grid-template-columns: 110px minmax(0, 1fr); }
}
