:root {
  --ink: #202124;
  --muted: #687078;
  --line: #d9dde1;
  --soft-line: #e9ebed;
  --panel: #ffffff;
  --subtle: #f5f6f7;
  --blue: #2463c7;
  --blue-dark: #174b9a;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overflow: clip; }
body { position: fixed; inset: 0; width: 100%; margin: 0; color: var(--ink); background: #fff; font-family: Arial, Helvetica, sans-serif; line-height: 1.4; }
button, input, select { font: inherit; }
button { color: inherit; }

.app-header {
  position: relative;
  z-index: 30;
  display: flex;
  height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.header-left { display: flex; min-width: 0; align-items: center; gap: 18px; }
.app-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 700; }
.app-brand-mark { display: block; width: 36px; height: 36px; object-fit: contain; }
.top-nav { display: flex; min-width: 0; height: 58px; align-items: stretch; gap: 2px; }
.top-nav a { position: relative; display: inline-flex; align-items: center; padding: 0 11px; color: #535a61; text-decoration: none; white-space: nowrap; font-size: 11px; font-weight: 700; }
.top-nav a:hover { color: var(--ink); background: #f7f8f9; }
.top-nav a.is-active { color: var(--blue-dark); }
.top-nav a.is-active::after { content: ""; position: absolute; right: 10px; bottom: 0; left: 10px; height: 3px; background: var(--blue); }
.top-nav a.is-disabled { color: #93999e; cursor: default; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.button, .layout-menu-button {
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.button:hover, .layout-menu-button:hover { background: var(--subtle); }
.button-primary { border-color: var(--blue); color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { color: #4f565c; }

.preset-menu { position: relative; }
.layout-menu-button::after { content: "▾"; margin-left: 7px; color: var(--muted); }
.preset-popover { position: absolute; top: calc(100% + 9px); right: 0; width: min(620px, calc(100vw - 24px)); padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 12px 32px rgba(31, 35, 38, .15); }
.popover-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.popover-heading strong { font-size: 14px; }
.popover-heading span { color: var(--muted); font-size: 11px; }
.preset-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.preset-card { position: relative; width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; border: 1px solid var(--soft-line); border-radius: 4px; text-align: left; background: #fff; cursor: pointer; }
.preset-card:hover { border-color: #aeb6bd; background: var(--subtle); }
.preset-card.is-active { border-color: #8aaee6; background: #eef4ff; }
.preset-card b { font-size: 11px; }
.preset-card.is-active::after { content: "✓"; position: absolute; top: 11px; right: 10px; color: var(--blue); font-weight: 900; }
.preset-preview { position: absolute; top: 14px; left: 11px; display: flex; gap: 2px; }
.preset-preview i { display: block; width: 8px; height: 2px; margin-top: 3px; background: #aab0b5; }
.preset-preview span { display: block; width: 13px; height: 7px; border-radius: 1px; background: #efad28; }

.editor-shell { display: grid; height: calc(100vh - 58px); grid-template-columns: 370px minmax(0, 1fr); overflow: hidden; background: #fff; }
.controls-panel { min-width: 0; overflow-y: auto; border-right: 1px solid var(--line); background: #fff; }
.controls-heading { padding: 18px 20px 16px; border-bottom: 1px solid var(--line); }
.controls-heading h1 { margin: 0 0 3px; font-size: 17px; }
.controls-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.control-group { border-bottom: 1px solid var(--line); }
.control-group-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 14px 20px; border: 0; text-align: left; background: #fff; cursor: pointer; }
.control-group-toggle:hover { background: #fafafa; }
.control-group-toggle span:first-child { display: flex; flex-direction: column; }
.control-group-toggle b { font-size: 13px; }
.control-group-toggle small { margin-top: 1px; color: var(--muted); font-size: 10px; font-weight: 400; }
.toggle-icon { color: #747b81; font-size: 18px; transition: transform .15s ease; }
.control-group.is-open .toggle-icon { transform: rotate(45deg); }
.control-group-body { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 0 20px 18px; }
.control-group.is-open .control-group-body { display: grid; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 5px; color: #4f565c; font-size: 10px; font-weight: 700; }
.field-full { grid-column: 1 / -1; }
.field-row { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.field input:not([type="range"]):not([type="color"]), .field select { width: 100%; min-height: 35px; padding: 7px 9px; border: 1px solid #cbd0d4; border-radius: 4px; color: var(--ink); outline: 0; background: #fff; font-size: 12px; font-weight: 400; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(36, 99, 199, .12); }
.field input[type="color"] { width: 100%; height: 35px; padding: 3px; border: 1px solid #cbd0d4; border-radius: 4px; background: #fff; cursor: pointer; }
.field input[type="range"] { width: 100%; accent-color: var(--blue); }
.field output { float: right; color: var(--muted); font-weight: 400; }
fieldset.field { margin: 0; padding: 0; border: 0; }
fieldset.field legend { margin-bottom: 6px; }
.swatch-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.swatch-picker label { position: relative; cursor: pointer; }
.swatch-picker input { position: absolute; opacity: 0; }
.swatch { display: block; height: 29px; border: 2px solid #fff; border-radius: 4px; box-shadow: 0 0 0 1px #bdc3c7; }
.swatch-picker input:checked + .swatch { box-shadow: 0 0 0 2px #202124; }
.swatch-yellow { background: linear-gradient(#ffdb55, #efa01c); }.swatch-green { background: linear-gradient(#6ad686, #26944d); }.swatch-red { background: linear-gradient(#ff7166, #cf3028); }.swatch-blue { background: linear-gradient(#69baff, #287ec9); }.swatch-dark { background: linear-gradient(#46504c, #18211d); }.swatch-grey { background: linear-gradient(#dce0dd, #919b96); }
.color-control { gap: 8px; }
.color-preset-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.color-preset-picker .swatch { width: 100%; padding: 0; cursor: pointer; }
.color-preset-picker .swatch.is-active { box-shadow: 0 0 0 2px #202124; }
.swatch-none { position: relative; overflow: hidden; color: #555d63; background: #fff; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.swatch-none::after { content: ""; position: absolute; top: 50%; left: -10%; width: 120%; height: 2px; background: #c52b22; transform: rotate(-22deg); }
.swatch-none span { position: relative; z-index: 1; padding: 1px 2px; background: rgba(255,255,255,.86); }
.hex-color-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; font-weight: 700; }
.hex-color-input { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; }
.hex-color-input[aria-invalid="true"] { border-color: #c52b22 !important; box-shadow: 0 0 0 2px rgba(197,43,34,.12) !important; }
.toggle-grid { grid-template-columns: 1fr 1fr; }
.switch { display: flex; align-items: center; gap: 7px; color: #4a5156; cursor: pointer; font-size: 11px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; width: 29px; height: 17px; flex: 0 0 auto; border-radius: 20px; background: #c8cdd1; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(12px); }

.preview-workspace { display: grid; min-width: 0; grid-template-rows: 54px minmax(0, 1fr) 52px; overflow: hidden; background: #fff; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); background: #fff; }
.preview-title { display: flex; align-items: center; gap: 9px; }
.preview-title div { display: flex; flex-direction: column; }
.preview-title strong { font-size: 12px; }
.preview-title small { color: var(--muted); font-size: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #25a55b; }
.device-switcher { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: #f6f7f8; }
.device-switcher button { min-height: 28px; padding: 4px 10px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.device-switcher button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.preview-stage { display: flex; min-height: 0; align-items: flex-start; justify-content: center; padding: 14px; overflow: auto; background: #f7f7f7; }
.preview-viewport { flex: 0 0 auto; width: 100%; overflow: hidden; border: 1px solid #d7dadd; background: #fff; box-shadow: 0 6px 20px rgba(31, 35, 38, .1); transition: width .18s ease; }
.preview-viewport.is-desktop { max-width: 920px; }.preview-viewport.is-tablet { width: 680px; }.preview-viewport.is-mobile { width: 375px; }
.preview-viewport iframe { display: block; width: 100%; height: 500px; border: 0; background: #fff; }
.preview-footer { display: flex; align-items: center; justify-content: flex-end; padding: 0 20px; border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 10px; }
.preview-copy { min-height: 32px; }
.preview-actions { display: flex; align-items: center; gap: 6px; }
.export-label { margin-right: 2px; }

.code-drawer { border-bottom: 1px solid var(--line); }
.code-drawer > summary { padding: 14px 20px; cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; }
.code-drawer > summary::after { content: "+"; float: right; color: var(--muted); font-size: 17px; line-height: 1; }
.code-drawer[open] > summary::after { content: "−"; }
.output-toolbar { display: flex; flex-direction: column; gap: 8px; padding: 0 20px 12px; }
.code-tabs { display: flex; gap: 3px; }
.code-tabs button { padding: 5px 8px; border: 1px solid var(--line); color: var(--muted); background: #fff; cursor: pointer; font-size: 9px; font-weight: 700; }
.code-tabs button.is-active { color: #fff; border-color: #444; background: #444; }
.code-window { max-height: 240px; margin: 0 20px 18px; padding: 12px; overflow: auto; color: #dcebdc; background: #202522; font: 9px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.toast { position: fixed; z-index: 50; right: 18px; bottom: 18px; padding: 10px 14px; border-radius: 4px; color: #fff; background: #202124; box-shadow: 0 6px 18px rgba(0,0,0,.2); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .15s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.content-document, .content-document body { height: auto; min-height: 100%; overflow: auto; overflow: visible; }
.content-page { position: static; width: auto; min-height: 100vh; background: #f7f7f7; }
.content-page .app-header { position: sticky; top: 0; }
.page-content { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 64px 0 80px; }
.training-hero { text-align: center; }
.training-hero h1 { max-width: 820px; margin: 0 auto 32px; color: #1f252a; font-size: clamp(28px, 4vw, 46px); line-height: 1.12; letter-spacing: -.025em; }
.video-frame { width: min(100%, 900px); aspect-ratio: 16 / 9; margin: 0 auto; overflow: hidden; border: 1px solid #d2d6da; border-radius: 8px; background: #000; box-shadow: 0 16px 38px rgba(31,35,38,.15); }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.legal-document { max-width: 820px; padding: clamp(28px, 5vw, 58px); border: 1px solid #dfe2e5; border-radius: 8px; background: #fff; box-shadow: 0 10px 30px rgba(31,35,38,.08); }
.legal-document h1 { margin: 0 0 8px; color: #1f252a; font-size: clamp(30px, 4vw, 44px); line-height: 1.1; }
.legal-updated { margin: 0 0 34px; color: var(--muted); font-size: 13px; }
.legal-document h2 { margin: 32px 0 10px; color: #252b30; font-size: 19px; line-height: 1.25; }
.legal-document p, .legal-document li { color: #444c53; font-size: 15px; line-height: 1.7; }
.legal-document p { margin: 0 0 14px; }
.legal-document ul { margin: 8px 0 16px; padding-left: 23px; }
.legal-document address { color: #444c53; font-size: 15px; font-style: normal; line-height: 1.8; }
.tools-page { width: min(1180px, calc(100% - 32px)); }
.tools-heading { margin: 0 0 34px; text-align: center; }
.tools-heading h1 { margin: 0 0 9px; color: #1f252a; font-size: clamp(32px, 4vw, 46px); line-height: 1.1; }
.tools-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.tools-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.tool-card { display: flex; min-width: 0; flex-direction: column; overflow: hidden; border: 1px solid #dce0e3; border-radius: 9px; color: var(--ink); background: #fff; box-shadow: 0 8px 24px rgba(31,35,38,.08); text-decoration: none; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.tool-card:hover { border-color: #aebbd0; box-shadow: 0 14px 32px rgba(31,35,38,.14); transform: translateY(-4px); }
.tool-card:focus-visible { outline: 4px solid rgba(36,99,199,.28); outline-offset: 4px; }
.tool-card-image { aspect-ratio: 1 / 1; overflow: hidden; border-bottom: 1px solid #e1e4e7; background: #eef1f4; }
.tool-card-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tool-card-body { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; }
.tool-card-body h2 { margin: 0; font-size: 20px; }
.tool-card-action { flex: 0 0 auto; padding: 7px 11px; border-radius: 4px; color: #fff; background: var(--blue); font-size: 11px; font-weight: 800; }

@media (max-width: 900px) {
  html, body { height: auto; overflow: auto; }
  body { position: static; width: auto; }
  .editor-shell { height: auto; min-height: calc(100vh - 58px); grid-template-columns: 1fr; overflow: visible; }
  .preview-workspace { position: sticky; z-index: 10; top: 58px; order: -1; height: 62vh; min-height: 430px; border-bottom: 1px solid var(--line); }
  .controls-panel { overflow: visible; border-right: 0; }
  .preview-stage { padding: 18px; }
  .top-nav a { padding-inline: 8px; font-size: 10px; }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-header { gap: 8px; padding-inline: 10px; }
  .header-left { gap: 6px; }
  .top-nav a.is-disabled { display: none; }
  .header-tools { gap: 4px; }
}
@media (max-width: 560px) {
  .app-header { padding: 0 10px; }
  .top-nav a { padding-inline: 6px; }
  .top-nav a:first-child { display: none; }
  .button, .layout-menu-button { padding-inline: 9px; }
  .editor-shell { min-height: calc(100vh - 58px); }
  .preview-workspace { height: 60vh; min-height: 410px; }
  .preview-toolbar { padding-inline: 10px; }
  .preview-title small { display: none; }
  .device-switcher button { padding-inline: 7px; }
  .preview-stage { align-items: flex-start; justify-content: flex-start; padding: 10px; }
  .preview-viewport.is-mobile { width: 350px; }
  .preview-footer { padding-inline: 10px; }
  .preview-footer > span, .export-label { display: none; }
  .preview-actions { width: 100%; }
  .preview-actions .button { flex: 1; padding-inline: 5px; }
  .preset-list { grid-template-columns: 1fr; max-height: 320px; overflow-y: auto; }
  .toggle-grid { grid-template-columns: 1fr; }
  .page-content { width: min(100% - 22px, 960px); padding-block: 42px 56px; }
  .training-hero h1 { margin-bottom: 24px; font-size: 28px; }
  .legal-document { padding: 26px 20px; }
  .legal-document h2 { margin-top: 27px; }
  .tools-page { width: min(100% - 22px, 1180px); }
  .tools-heading { margin-bottom: 24px; }
  .tools-grid { grid-template-columns: 1fr; gap: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }
