:root {
  --bg: #f5f5f4;
  --panel: #fff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #1d4ed8;
  --accent-text: #fff;
  --danger: #b91c1c;
  --ok: #15803d;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; }

button { font: inherit; border-radius: 8px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: .6; cursor: progress; }
button.link { border: 0; background: none; padding: 2px 6px; color: var(--muted); }
button.link:hover { color: var(--text); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lang { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
select, input, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; color: var(--text); width: 100%; }
textarea { resize: vertical; }

.layout { flex: 1; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; min-height: 0; }
.editor { overflow-y: auto; padding: 16px 20px 80px; border-right: 1px solid var(--line); }
.preview { position: relative; display: flex; flex-direction: column; min-height: 0; }
.preview iframe { flex: 1; border: 0; width: 100%; }
.fit { font-size: 13px; padding: 6px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.fit.ok { color: var(--ok); }
.fit.over { color: var(--danger); }

.block { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.block > summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.block-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.item { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 10px; }
.item-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.current { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.current input { width: auto; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(680px, 92vw); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
.import-form { padding: 20px; display: grid; gap: 12px; }
.import-form h2, .import-form p { margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.error { color: var(--danger); min-height: 1em; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .editor { border-right: 0; }
  .preview iframe { height: 80vh; }
}
