:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E3E6EB;
  --border-strong: #C9CED6;
  --text: #111827;
  --muted: #5B6472;
  --accent: #1D4ED8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

[hidden] { display: none !important; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.header-top { display: flex; flex-direction: column; gap: 6px; }
.header h1 { margin: 0; font-size: 22px; font-weight: 700; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 24px; }
.tabs button {
  padding: 12px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

main { flex-grow: 1; display: flex; flex-direction: column; }
.tab { padding: 16px; display: flex; flex-direction: column; flex-grow: 1; }

.empty, .notice { color: var(--muted); text-align: center; }
.empty { margin: 48px 0; font-size: 14px; }
.notice { padding: 64px 24px; }

/* Общие элементы вкладок */

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: #EEF0F3;
  color: #374151;
}
.badge-ok { background: #E7F5EC; color: #14532D; }
.badge-warn { background: #FEF3C7; color: #78350F; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.button-primary {
  min-height: 48px;
  flex-grow: 1;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
}
.button:disabled { opacity: 0.5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.hint { margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #FDECEC;
  color: #991B1B;
  font-size: 14px;
}
.busy { opacity: 0.6; pointer-events: none; }

/* Вкладка «Цепочка» */

.chain { display: flex; flex-direction: column; flex-grow: 1; }
.file-row { display: flex; gap: 12px; align-items: center; }
.file-icon {
  flex-shrink: 0;
  width: 40px;
  height: 48px;
  border-radius: 6px;
  background: #FDECEC;
  color: #991B1B;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-name { flex-grow: 1; min-width: 0; }
.file-title { font-weight: 600; overflow-wrap: anywhere; }
.footer {
  position: sticky;
  bottom: 0;
  margin: 16px -16px -16px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* Вкладка «Меню» */
.tab.menu { padding: 0; }
.menu-body { padding: 16px; display: flex; flex-direction: column; gap: 20px; flex-grow: 1; }
.menu-hint { margin: 0 2px; font-size: 13px; color: var(--muted); }
.menu .field { display: flex; flex-direction: column; gap: 8px; }
.menu .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.menu textarea, .menu input {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}
.menu textarea { resize: vertical; }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; }
.menu-button, .menu-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.menu-button { padding: 6px 6px 6px 8px; display: flex; align-items: center; gap: 10px; }
.menu-button-order { display: flex; flex-direction: column; }
.menu-button-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.menu-button-label { font-weight: 600; overflow-wrap: anywhere; }
.menu-button-url { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.menu-form { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.menu-form-actions { display: flex; gap: 8px; }
.menu button { font: inherit; cursor: pointer; }
.menu button:disabled { opacity: 0.4; cursor: default; }
.menu button.icon {
  min-width: 36px;
  min-height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}
.menu button.link {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.menu button.link.muted { color: var(--muted); }
.menu button.link.danger { color: #B91C1C; margin-left: auto; }
.menu button.dashed {
  min-height: 44px;
  border: 1px dashed #8A93A1;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.menu button.primary {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}
.menu-preview {
  background: #DCE3EC;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.menu-preview-empty { margin: 0; font-size: 13px; color: var(--muted); }
.menu-preview .bubble {
  max-width: 280px;
  background: var(--surface);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.menu-preview .bubble-button {
  width: 280px;
  max-width: 100%;
  background: var(--surface);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.menu-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-status { margin: 0; font-size: 13px; color: var(--muted); }
.menu-status:empty { display: none; }
.menu-status.error { padding: 0; border-radius: 0; background: none; color: #B91C1C; }
