/* AI writer start step (source choice, template / idea pickers, undo) and template HTML layouts (rendered preview, layout editor,
   layout mode of the article editor). Component styles only – colours come from the theme tokens (css/theme.css). */

/* ---------- rendered layouts (sandboxed iframe, js/templates.js mountLayout) ---------- */
.lyt-box { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.lyt-frame { display: block; width: 100%; height: 420px; border: 0; background: #fff; }
.lyt-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-3); margin-bottom: 10px; }
.lyt-seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-xs);
  font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.lyt-seg button .ico { width: 15px; height: 15px; }
.lyt-seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.lyt-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lyt-note { margin: 0 0 10px; }

/* thumbnails: the page rendered at 800 px and scaled down; not interactive, the button around it opens the preview */
.lyt-thumb { position: relative; display: block; width: 100%; height: 168px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: #fff; cursor: zoom-in; text-align: left; }
.lyt-thumb > span:first-child { position: absolute; inset: 0; display: block; }
.lyt-thumb-frame { position: absolute; top: 0; left: 0; width: 250%; height: 250%; transform: scale(.4); transform-origin: 0 0; pointer-events: none; }
.lyt-thumb-tag { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  background: rgba(11, 16, 51, .82); color: #fff; font-size: var(--fs-xs); font-weight: 600; opacity: 0; transition: opacity .15s; }
.lyt-thumb-tag .ico { width: 14px; height: 14px; }
.lyt-thumb:hover .lyt-thumb-tag, .lyt-thumb:focus-visible .lyt-thumb-tag { opacity: 1; }
.lyt-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lyt-thumb-sm { height: 120px; margin-top: 10px; }
@media (hover: none) { .lyt-thumb-tag { opacity: 1; } }

/* template editor: layout block */
.lyt-ed { display: flex; flex-direction: column; gap: 10px; }
.lyt-aiform { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.lyt-aiform[hidden] { display: none; }
.lyt-code { width: 100%; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; resize: vertical; }
.lyt-empty { display: flex; align-items: center; gap: 8px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.lyt-empty .ico { width: 18px; height: 18px; flex: none; }
.lyt-undo { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 14px;
  border-radius: var(--radius-lg); background: var(--text); color: var(--surface); }
.lyt-undo .btn { flex: none; }

/* article editor: layout mode */
.lyt-edit[hidden] { display: none; }
.lyt-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; margin: 6px 0 10px;
  border-radius: var(--radius); background: var(--surface-3); color: var(--text-2); }
.lyt-bar > span:first-child { display: inline-flex; align-items: flex-start; gap: 6px; min-width: 0; flex: 1 1 280px; }
.lyt-doc { min-height: 320px; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; color: #0b1033; color-scheme: light;
  font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; outline: none; }
.lyt-doc:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.lyt-doc > :first-child { margin-top: 0; }
.lyt-doc table { max-width: 100%; }
.lyt-doc a { color: #c2410c; }
.lyt-code-lg { min-height: 420px; }
@media (max-width: 600px) { .lyt-doc { padding: 16px; } .lyt-doc table { font-size: 14px; } }

/* ---------- AI wizard: start step ---------- */
.wz-src { margin-bottom: 14px; }
.wz-q { margin: 0 0 8px; font-weight: 600; }
.wz-src-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wz-src-opt { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
.wz-src-opt:hover:not(:disabled) { border-color: var(--border-strong); }
.wz-src-opt.on { border-color: var(--accent); background: var(--accent-50); box-shadow: 0 0 0 1px var(--accent) inset; }
[data-mode="dark"] .wz-src-opt.on { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.wz-src-opt:disabled { opacity: .55; cursor: not-allowed; }
.wz-src-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wz-src-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-2); }
.wz-src-opt.on .wz-src-ic { background: var(--accent); color: var(--accent-contrast); }
.wz-src-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wz-what { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 0; color: var(--text-2); }
.wz-what .ico { margin-top: 3px; flex: none; }
.wz-undo, .wz-link { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 12px; margin: 0 0 12px;
  border-radius: var(--radius); background: var(--surface-3); }
.wz-undo { background: var(--text); color: var(--surface); }
.wz-link > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.wz-pick { margin-bottom: 4px; }
.wz-sub { margin: 4px 0 8px; font-weight: 600; font-size: var(--fs-xs); color: var(--text-2); }
.wz-tpls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-height: 420px; overflow: auto; padding: 2px; margin-bottom: 12px; }
.wz-grp { grid-column: 1 / -1; margin: 4px 0 0; }
.wz-tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.wz-tpl:hover { border-color: var(--border-strong); }
.wz-tpl.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.wz-tpl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wz-tpl > b { font-size: 14px; line-height: 1.3; }
.wz-tpl > .xs { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wz-tpl-thumb { position: relative; display: block; width: 100%; height: 96px; border-radius: var(--radius); overflow: hidden; background: #fff; border: 1px solid var(--border); }
.wz-tpl-thumb .lyt-thumb-frame { width: 400%; height: 400%; transform: scale(.25); }
.wz-tpl-secs { display: flex; flex-direction: column; gap: 4px; width: 100%; height: 96px; overflow: hidden; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.wz-tpl-secs span { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-tpl-secs span::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); margin-right: 6px; vertical-align: middle; }
.wz-tplsel { gap: 8px; align-items: center; margin: -4px 0 10px; }
.wz-ideas { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; padding: 2px; margin-bottom: 12px; }
.wz-idea { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wz-idea:hover { border-color: var(--border-strong); }
.wz-idea.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.wz-idea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) {
  .wz-src-grid { grid-template-columns: 1fr; gap: 8px; }
  .wz-src-opt { padding: 10px 12px; }
  .wz-tpls { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 360px; }
}
@media (max-width: 420px) { .wz-tpls { grid-template-columns: 1fr; } }
.bp-quill[hidden] { display: none; }
/* a layout must never widen the editor column (grid min-content) – wide tables scroll inside the article */
.bp-main:has(.lyt-edit:not([hidden])) { min-width: 0; }
.lyt-edit { min-width: 0; max-width: 100%; }
.lyt-doc { overflow-x: auto; }
