/* KIIN Cross-Section & Train Studio — Architectural Drafting UI
 * Responsive Strategy:
 *   - Component adaptation uses @container (Container Queries) first.
 *   - @media is strictly limited to global shell grid layout & prefers-reduced-motion.
 *   - ZERO vw units anywhere in typography for full browser zoom accessibility.
 */
:root {
  --ink: #243a34;
  --ink-strong: #172722;
  --muted: #6c7770;
  --green: #245242;
  --green-hover: #1c4235;
  --accent: #b18b4c;
  --line: #dde1d7;
  --line-strong: #c8cfc1;
  --paper: #f7f8f3;
  --panel: #fffefa;
  --soft: #edf2eb;
  --soft-hover: #e2ebe0;
  --danger: #a04437;
  --stage-bg: #222d2a;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(24, 42, 36, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 28, 24, 0.24);
  --font-sans: "Yu Gothic UI", "Hiragino Sans", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
button:hover:not(:disabled) { background: var(--soft); border-color: #b7c2b3; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

button.primary {
  background: var(--green);
  color: #fffef9;
  border-color: var(--green);
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }

button.quiet { background: transparent; border-color: transparent; }
button.quiet:hover:not(:disabled) { background: var(--soft); border-color: var(--line); }

button.soft-btn { background: var(--soft); border-color: var(--line-strong); font-weight: 600; }
button.soft-btn:hover:not(:disabled) { background: var(--soft-hover); }

button.danger-btn { color: var(--danger); border-color: #dfbbb4; background: #fff9f8; }
button.danger-btn:hover:not(:disabled) { background: #fbece9; }

button.text-btn {
  background: transparent;
  border: none;
  padding: 4px 6px;
  color: var(--green);
  font-weight: 600;
  font-size: 12.5px;
  text-align: left;
}
button.text-btn:hover { background: var(--soft); }

button.full { width: 100%; }
button.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ===== APP SHELL ===== */
body {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.app-header {
  container-type: inline-size;
  container-name: header;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  max-width: 100%;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
  flex-shrink: 1;
}
.brand-logo { display: block; border-radius: 7px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 14.5px; letter-spacing: 0.01em; color: var(--ink-strong); }
.brand-text small {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.edition-label {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  letter-spacing: 0.05em;
}
.edition-label.pro { background: #e4efe9; color: var(--green); border: 1px solid #b8d2c6; }
.edition-label.lite { background: #f6eedb; color: #8c6626; border: 1px solid #e0ca96; }

.document-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 360px;
  min-width: 140px;
}
.document-name input {
  width: 100%;
  min-width: 110px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-weight: 600;
  color: var(--ink-strong);
}
.document-name input:hover { border-color: var(--line-strong); }
.document-name input:focus { background: var(--panel); border-color: var(--green); }
.save-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.save-status.warn { color: var(--danger); font-weight: 700; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}
.header-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

@container header (max-width: 980px) {
  .brand-text small { display: none; }
  .save-status { display: none; }
}
@container header (max-width: 760px) {
  .document-name { display: none; }
  .header-sep { display: none; }
}

/* Segmented controls */
.seg-group {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  max-width: 100%;
}
.seg-group button {
  border: none;
  background: transparent;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 4px;
  white-space: nowrap;
}
.seg-group button:hover:not(.active) { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.seg-group button.active {
  background: var(--panel);
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}

/* ===== 3-PANE GLOBAL WORKSPACE SHELL ===== */
.app-layout {
  display: grid;
  grid-template-columns: clamp(262px, 22%, 312px) minmax(0, 1fr) clamp(256px, 21%, 306px);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* ===== LEFT TOOL PANEL ===== */
.tool-panel {
  container-type: inline-size;
  container-name: leftpanel;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.step-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}
.step-tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 9px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}
.step-tabs button small { font-size: 10px; opacity: 0.72; letter-spacing: 0.06em; }
.step-tabs button.active {
  background: var(--panel);
  color: var(--green);
  border-bottom-color: var(--green);
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 13px 13px 16px;
}
.tab-content[hidden] { display: none; }

.panel-heading { margin-bottom: 11px; }
.panel-heading h2 { margin: 0 0 2px; font-size: 15px; color: var(--ink-strong); }
.panel-heading p { margin: 0; font-size: 12px; color: var(--muted); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 6px;
}
.section-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  margin: 11px 0 6px;
}
.section-head .section-label { margin: 0; }
.count-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--soft);
  color: var(--green);
  padding: 1px 7px;
  border-radius: 99px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-weight: 500;
}

.form-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
@container leftpanel (max-width: 280px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  margin: 7px 0;
  cursor: pointer;
}
.check-row input[type="checkbox"] { margin-top: 2px; accent-color: var(--green); }
.check-row.align-end { align-items: center; margin-top: 18px; }

.range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  font-size: 12px;
  font-weight: 600;
}
.range-field > span { display: flex; justify-content: space-between; align-items: center; }
.range-field output { font-weight: 700; color: var(--green); }
.range-field input[type="range"] { width: 100%; accent-color: var(--green); }

.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.add-car-bar { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 8px; }

.chip-actions, .chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.chip-actions button, .chip-bar button {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--paper);
}
.chip-bar button.active { background: var(--green); color: #fff; border-color: var(--green); }

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stack-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.stack-item:hover { border-color: var(--line-strong); background: var(--soft); }
.stack-item.active { border-color: var(--green); background: #ebf3ee; }
.stack-item-main { display: flex; flex-direction: column; min-width: 0; }
.stack-item-main b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-item-main small { font-size: 11px; color: var(--muted); }
.stack-item-btns { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.stack-item-btns button {
  padding: 2px 6px;
  font-size: 11px;
  min-width: 24px;
  height: 24px;
}
.gl-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  margin: 2px 0;
}
.gl-divider::before, .gl-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #d9c9a2;
}

.divider { height: 1px; background: var(--line); margin: 13px 0; }
.subtle { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* Asset Grid */
.tool-mode-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 9px;
}
.tool-mode-bar button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  font-weight: 600;
  font-size: 12px;
}
.tool-mode-bar button.active { background: #e8f1ec; border-color: var(--green); color: var(--green); }
kbd {
  font-size: 10.5px;
  font-family: inherit;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.search-box { display: block; margin-bottom: 8px; }
.search-box input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
@container leftpanel (max-width: 235px) {
  .asset-grid { grid-template-columns: 1fr; }
}
.asset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}
.asset-card:hover { background: var(--soft); border-color: var(--line-strong); }
.asset-card.active {
  background: #e6f0eb;
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}
.asset-card svg {
  width: 100%;
  height: 52px;
  background: #ece8db;
  border-radius: 4px;
  display: block;
}
.asset-card b { font-size: 11.5px; line-height: 1.25; color: var(--ink-strong); }
.asset-card small { font-size: 10px; color: var(--muted); }

/* Style Cards */
.style-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.style-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.style-card:hover { background: var(--soft); }
.style-card.active { border-color: var(--green); background: #e8f1ec; }
.style-card .swatch {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
}
.style-card .style-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.style-card b { font-size: 12.5px; display: flex; align-items: center; gap: 5px; }
.style-card small { font-size: 11px; color: var(--muted); }
.style-card .check-mark { color: var(--green); font-weight: 700; opacity: 0; }
.style-card.active .check-mark { opacity: 1; }

.pro-mini-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  background: #f5ead2;
  color: #8c6321;
  border: 1px solid #dec388;
}
html[data-edition="pro"] .pro-mini-pill { display: none; }

/* Quick Samples in Left Panel (Rich teal-leaning blue strip for clear hierarchy vs panel & green banner) */
#openStartDialogBtn {
  background: #a5cbcd;
  border-color: #6d999e;
  color: #0e2426;
  font-weight: 700;
}
#openStartDialogBtn:hover:not(:disabled) {
  background: #94bec1;
  border-color: #55848a;
}
.sample-mini-list { display: flex; flex-direction: column; gap: 5px; margin-top: 7px; }
.sample-mini-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
  text-align: left;
  background: #bedbdc;
  border: 1px solid #80aaae;
  color: #102628;
}
.sample-mini-btn:hover:not(:disabled) {
  background: #accfd1;
  border-color: #619297;
}
.sample-mini-btn b { font-size: 12px; display: flex; align-items: center; gap: 5px; color: #0c2022; }
.sample-mini-btn small { display: block; font-size: 10.5px; color: #1d3f42; }

/* Left Panel Footer & KIIN Cross-Sell Carousel (Deep brand forest green matching .primary with crisp white text) */
.panel-footer {
  border-top: 1px solid #193c30;
  padding: 9px 11px;
  background: var(--green);
  color: #ffffff;
  flex-shrink: 0;
}
.edition-panel-cta { margin-bottom: 8px; }
.pro-cta-btn {
  width: 100%;
  background: #f6eedb;
  border-color: #d7be83;
  color: #5b3e0e;
  font-weight: 700;
  font-size: 12px;
}
.pro-cta-btn:hover { background: #efe2c4; }

.studio-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  color: #ffffff;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
.studio-banner:hover {
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.16);
}
.studio-banner:focus-visible { outline-color: #ffffff; }
.studio-banner-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #f7f9f5;
  border: 1px solid rgba(255, 255, 255, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.studio-banner-icon.dark-icon {
  background: #14221d;
  border-color: rgba(255, 255, 255, 0.30);
}
.studio-banner-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}
.studio-banner-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.studio-banner-body em { font-style: normal; font-size: 9.5px; font-weight: 700; color: #e8f2ec; letter-spacing: 0.04em; }
.studio-banner-body b { font-size: 12px; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-banner-body small { font-size: 10.5px; color: rgba(255, 255, 255, 0.86); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.studio-ad-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 6px;
}
.studio-ad-caption { font-size: 10px; color: rgba(255, 255, 255, 0.86); font-weight: 600; }
.ad-dots { display: flex; gap: 4px; }
.ad-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.34);
}
.ad-dots button[aria-pressed="true"] { background: #ffffff; }
#studioAdPause {
  border: none;
  background: transparent;
  padding: 1px 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.88);
}
#studioAdPause:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

/* ===== CENTER WORKSPACE ===== */
.workspace {
  container-type: inline-size;
  container-name: workspace;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--stage-bg);
}

.workspace-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 99px;
  background: var(--paper);
}
.pill-toggle[aria-pressed="true"] {
  background: #1b5369;
  border-color: #1b5369;
  color: #e9f9fc;
}

.canvas-host {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: radial-gradient(circle at 50% 42%, #2c3a36 0%, #1d2724 100%);
  user-select: none;
  touch-action: none;
}
.canvas-host.panning { cursor: grab; }
.canvas-host.panning-active { cursor: grabbing; }
.canvas-host svg#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 34, 29, 0.9);
  color: #f4f1e4;
  border: 1px solid rgba(212, 224, 214, 0.28);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  pointer-events: none;
}

.workspace-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 6px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-width: 0;
}
.tool-hint-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
  flex: 1 1 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3d8e6b;
  flex-shrink: 0;
}
.viewport-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  max-width: 100%;
}
.viewport-controls output {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}
.compact-btn { padding: 4px 8px; font-size: 12px; }

/* ===== RIGHT INSPECTOR ===== */
.inspector {
  container-type: inline-size;
  container-name: inspector;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 13px;
}
.insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.insp-head small { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.insp-head h3 { margin: 2px 0 0; font-size: 14.5px; color: var(--ink-strong); }

.insp-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  margin-bottom: 10px;
}
.insp-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.insp-stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
}
.insp-stat small { display: block; font-size: 10.5px; color: var(--muted); }
.insp-stat b { font-size: 14px; color: var(--ink-strong); }

.inspector-footer {
  border-top: 1px solid var(--line);
  padding: 8px 11px;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.footer-links { display: flex; align-items: center; gap: 6px; }
.inspector-footer button {
  border: none;
  background: transparent;
  padding: 2px 4px;
  font-size: 11px;
  color: var(--muted);
}
.inspector-footer button:hover { color: var(--ink); background: var(--soft); }
.inspector-footer small { font-size: 11px; color: var(--muted); }

/* ===== DIALOGS ===== */
dialog.studio-dialog {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0;
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.wide-dialog { width: min(740px, calc(100% - 28px)); }
dialog::backdrop { background: rgba(16, 26, 22, 0.52); backdrop-filter: blur(2px); }

.dialog-content {
  container-type: inline-size;
  container-name: dialogbox;
  padding: 18px 20px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 40px);
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.dialog-heading small { display: block; font-size: 10.5px; font-weight: 700; color: var(--green); letter-spacing: 0.06em; }
.dialog-heading h2 { margin: 2px 0 0; font-size: 18px; color: var(--ink-strong); }

.dialog-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 10px 0 14px;
}
.dialog-tabs button {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dialog-tabs button.active { color: var(--green); border-bottom-color: var(--green); }

.export-preview-box {
  background: #1f2b27;
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
  max-height: 230px;
  overflow: hidden;
}
.export-preview-box svg { max-width: 100%; max-height: 210px; height: auto; width: auto; display: block; }

.spec-summary-card {
  background: #edf4f0;
  border: 1px solid #c3d6cb;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
}
.spec-summary-card b { color: var(--green); }

.ccfolia-checks { margin: 8px 0 12px; }
.progress-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.progress-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.progress-wrap progress { width: 100%; height: 8px; accent-color: var(--green); }

.export-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
@container dialogbox (max-width: 520px) {
  .export-action-row, .form-row-2 { grid-template-columns: 1fr; }
}
.sub-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 4px;
}
.meta-note {
  font-size: 12px;
  color: var(--green);
  background: var(--soft);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* Start Dialog Choices */
.resume-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #edf4f0;
  border: 1px solid #b5cfc0;
  margin: 10px 0 12px;
  text-align: left;
}
.resume-card small { display: block; font-size: 11px; color: var(--muted); }
.resume-card b { font-size: 14px; color: var(--ink-strong); }
.resume-card strong { color: var(--green); }

.start-choices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
@container dialogbox (max-width: 540px) {
  .start-choices-grid { grid-template-columns: 1fr; }
}
.start-choice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-align: left;
}
.start-choice-card:hover { border-color: var(--green); background: var(--soft); }
.start-thumb {
  width: 100%;
  height: 118px;
  background: #1f2b27;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.start-thumb svg { width: 100%; height: 100%; display: block; }
.start-choice-card b { font-size: 13.5px; color: var(--ink-strong); display: flex; align-items: center; gap: 6px; }
.start-choice-card small { font-size: 11.5px; color: var(--muted); }

.start-footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.start-blank-btns { display: flex; flex-wrap: wrap; gap: 6px; }

/* Pro Modal */
.pro-reason {
  background: #fbf4e4;
  border: 1px solid #e2ca94;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12.5px;
  color: #5e4212;
  margin: 8px 0;
}
.pro-reason:empty { display: none; }
.pro-summary-box {
  background: #ebf3ee;
  border: 1px solid #bdd4c6;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 8px 0;
}
.pro-benefits-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
}
.pro-benefits-box ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.pro-benefits-box li { margin-bottom: 4px; }
.pro-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 6px;
}
.pro-shop-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #b18b4c;
  color: #fffef9;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}
.pro-shop-link:hover { background: #987439; }
.pro-saved-status { font-size: 12px; color: var(--green); font-weight: 600; min-height: 18px; margin: 4px 0; }

/* Shortcuts & Prose */
.shortcut-list { margin: 10px 0 0; display: grid; gap: 6px; }
.shortcut-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: var(--paper);
  border-radius: 5px;
}
.shortcut-list dt { font-weight: 600; }
.shortcut-list dd { margin: 0; color: var(--muted); font-size: 12.5px; }

.prose-body h3 { font-size: 14px; margin: 12px 0 4px; color: var(--green); }
.prose-body p, .prose-body li { font-size: 12.5px; margin: 4px 0; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2e28;
  color: #f7f4e8;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 90;
}

/* Global Shell Layout Media Queries ONLY (never component breakpoints) */
@media (max-width: 1020px) {
  .app-layout {
    grid-template-columns: 270px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 235px;
  }
  .tool-panel { grid-row: 1 / 3; }
  .inspector { grid-column: 2; border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 740px) {
  body { overflow-y: auto; overflow-x: clip; }
  .app-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    max-width: 100%;
  }
  .workspace { min-height: 440px; order: 1; }
  .tool-panel { order: 2; border-right: none; border-top: 1px solid var(--line); max-width: 100%; }
  .inspector { order: 3; border-left: none; border-top: 1px solid var(--line); max-width: 100%; }
  .brand-text b { font-size: 13px; }
  .seg-group button { padding: 4px 7px; font-size: 11.5px; }
  .workspace-top { padding: 6px 8px; gap: 6px; }
  .workspace-bottom { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
