#roomTemplateDialog {
  --rt-ink: #20382f;
  --rt-accent: #295e47;
  color: var(--rt-ink);
  background: #fffefa;
  border: 1px solid #aebcaf;
  border-radius: 16px;
  box-shadow: 0 24px 90px #17291e38;
  padding: 0;
  width: min(850px, calc(100vw - 32px));
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  font: 14px/1.4 "Segoe UI", sans-serif;
}
#roomTemplateDialog::backdrop { background: rgb(24 41 32 / .43); }
#roomTemplateDialog * { box-sizing: border-box; }
#roomTemplateDialog [hidden] { display: none; }
.rt-form { margin: 0; padding: 0; }
.rt-heading, .rt-form footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rt-heading { padding: 16px 18px 12px 24px; }
.rt-heading h2 { margin: 0; color: var(--rt-ink); font: 600 27px/1.2 "Segoe UI", sans-serif; letter-spacing: -.035em; }
.rt-imports { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 24px 18px; padding-bottom: 16px; border-bottom: 1px solid #dbe1d6; }
.rt-imports strong { font-size: 15px; margin-right: 6px; }
#roomTemplateDialog .rt-imports button { border: 1px solid #bccbbc; background: #f6f8f2; }
#roomTemplateDialog .rt-imports button:hover { border-color: var(--rt-accent); background: #eaf0e7; }
.rt-body { display: grid; grid-template-columns: .8fr 1.25fr; gap: 24px; padding: 0 24px 24px; }
.rt-preview {
  display: flex; flex-direction: column; justify-content: center;
  margin: 0; min-width: 0; padding: 16px 8px 0; border-radius: 10px; overflow: hidden;
  color: #fffdf0; background-color: #294f45;
  background-image: linear-gradient(90deg, #abc9b710 1px, transparent 1px), linear-gradient(#abc9b710 1px, transparent 1px);
  background-size: 16px 16px;
}
.rt-drawing { flex: 1; display: grid; align-items: center; }
.rt-drawing svg { display: block; width: 100%; max-height: 250px; }
.rt-preview figcaption { padding: 12px 10px 15px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rt-preview figcaption strong { font-size: 15px; font-weight: 600; }
.rt-preview figcaption span { color: #d1e2d7; font-size: 12px; }
.rt-floor { fill: #e4f0d8; stroke: #708774; stroke-dasharray: 2 2; stroke-width: 1; }
.rt-walls { fill: none; stroke: #41604a; stroke-width: 2.7; stroke-linejoin: round; stroke-linecap: square; }
.rt-preview .rt-floor { fill: #acc9b522; stroke: #c5ddca80; stroke-dasharray: 3 4; }
.rt-preview .rt-walls { stroke: #edf4dc; stroke-width: 3.5; }
.rt-measures path { stroke: #c8d9ba; stroke-width: .85; fill: none; }
.rt-measures text { fill: #e8f2d9; font: 11px Consolas, monospace; text-anchor: middle; }
.rt-settings { display: grid; align-content: start; gap: 20px; }
.rt-form fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.rt-form legend { display: flex; align-items: baseline; gap: 8px; padding: 0; margin: 0 0 9px; font-size: 15px; font-weight: 650; color: var(--rt-ink); }
.rt-form legend small { font-size: 12px; font-weight: 400; color: #586a5e; }
.rt-choices, .rt-dimensions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.rt-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rt-choice span { text-align: center; }
.rt-choice small { display: block; font: inherit; color: #506453; text-transform: capitalize; }
.rt-form .rt-choice {
  position: relative; display: grid; gap: 5px; place-items: center; align-content: center;
  min-height: 72px; padding: 6px 2px; margin: 0;
  background: #f9faf4; border: 1px solid #cfd6c9; border-radius: 7px;
  color: #3b4d41; font-size: 12px; font-weight: 500; cursor: pointer;
}
.rt-choice svg { width: 50px; height: 30px; }
.rt-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rt-choice:hover { border-color: #869c89; }
.rt-form .rt-choice:has(:checked) { border-color: var(--rt-accent); box-shadow: inset 0 0 0 1px var(--rt-accent); background: #e8f0e2; color: #203f2c; }
.rt-choice:has(:focus-visible), #roomTemplateDialog :is(button,select,input[type=text]):focus-visible { outline: 2px solid #427daa; outline-offset: 2px; }
.rt-dimensions label { display: grid; gap: 5px; color: #4c5c51; font-size: 13px; font-weight: 500; margin: 0; }
.rt-form :is(select,input[type=text]) {
  width: 100%; min-width: 0; min-height: 44px; padding: 7px 10px;
  border: 1px solid #bbc7ba; border-radius: 6px; background: #fff; color: #1c3327; font: 16px "Segoe UI", sans-serif;
}
.rt-error, .rt-replace { margin: 0; font-size: 13px; }
.rt-error { color: #973b27; }
.rt-replace { padding: 0 24px 16px; color: #5c5546; }
.rt-form footer { padding: 12px 20px; border-top: 1px solid #dbe1d6; }
.rt-form footer div { display: flex; align-items: center; gap: 6px; }
#roomTemplateDialog button {
  appearance: none; border: 0; border-radius: 7px; min-height: 44px; padding: 9px 12px;
  color: var(--rt-accent); background: transparent; font: 600 14px/1.2 "Segoe UI", sans-serif; cursor: pointer;
}
#roomTemplateDialog button:hover { background: #eaf0e7; }
#roomTemplateDialog .rt-close { width: 44px; font-size: 24px; font-weight: 400; }
#roomTemplateDialog .rt-create { padding-inline: 18px; color: white; background: var(--rt-accent); }
#roomTemplateDialog .rt-create:hover { background: #204b38; }
@media (max-width: 640px) {
  #roomTemplateDialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .rt-body { grid-template-columns: 1fr; gap: 16px; padding: 0 16px 16px; }
  .rt-heading { padding: 8px 10px 8px 16px; }
  .rt-imports { margin: 0 16px 14px; padding-bottom: 12px; }
  .rt-imports strong { flex-basis: 100%; }
  .rt-preview { padding: 0 8px; }
  .rt-drawing svg { height: 125px; }
  .rt-preview figcaption { padding: 0 6px 8px; }
  .rt-settings { gap: 14px; }
  .rt-form footer { flex-wrap: wrap; padding: 8px; gap: 4px; }
  .rt-form footer div { margin-left: auto; }
}
