:root {
  --bg: #0d1621;
  --panel: #162331;
  --panel2: #1d2b3a;
  --line: #314356;
  --text: #f4f7fb;
  --muted: #8fa3b7;
  --accent: #5f9ee6;
  --accent2: #8fc3ff;
  --danger: #ff6b6b;
  --ok: #61d394;
  --warn: #ffd166;
  --shadow: 0 20px 60px rgba(0,0,0,.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; }
.app-shell { width: min(860px, 100%); margin: 0 auto; padding: 22px 16px 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: .01em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { color: var(--muted); line-height: 1.5; }
.icon-button { border: 0; color: var(--text); background: var(--panel); width: 44px; height: 44px; border-radius: 14px; font-size: 25px; cursor: pointer; }
.status-box { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 14px 16px; margin-bottom: 16px; }
.status-title { font-weight: 700; margin-bottom: 4px; }
.status-text { color: var(--muted); font-size: 14px; line-height: 1.45; }
.status-ok { border-color: rgba(97,211,148,.45); }
.status-warn { border-color: rgba(255,209,102,.45); }
.status-error { border-color: rgba(255,107,107,.55); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--panel2); border-radius: 22px; padding: 5px; margin: 16px 0 22px; }
.tab { border: 0; background: transparent; color: var(--muted); border-radius: 17px; padding: 13px 8px; cursor: pointer; font-weight: 700; }
.tab.active { background: var(--bg); color: var(--text); }
.panel { display: none; }
.panel.active { display: block; }
.section-head { margin: 0 0 16px; }
.section-head p { margin-top: 6px; }
.section-head.split { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-list { display: grid; gap: 14px; }
.item-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 8px 20px rgba(0,0,0,.12); display: grid; gap: 14px; }
.item-card.disabled { opacity: .55; }
.item-main p { margin-top: 8px; }
.item-meta { color: var(--accent2); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; background: rgba(95,158,230,.15); color: var(--accent2); font-weight: 700; }
.primary, .secondary, .danger { border: 0; border-radius: 16px; padding: 14px 18px; cursor: pointer; font-weight: 800; color: #fff; }
.primary { background: var(--accent); }
.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.danger { background: rgba(255,107,107,.14); color: #ffaaa9; border: 1px solid rgba(255,107,107,.35); }
.small { padding: 10px 14px; font-size: 14px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(4,8,13,.74); overflow: auto; padding: 16px; }
.editor-card { width: min(760px, 100%); margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 18px; }
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.field { display: grid; gap: 8px; margin-bottom: 15px; }
.field span { font-weight: 800; }
.field small { color: var(--muted); line-height: 1.4; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #132030; color: var(--text); border-radius: 15px; padding: 13px 14px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(95,158,230,.16); }
textarea { resize: vertical; min-height: 98px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 10px; }
.checkbox-field input { width: 20px; height: 20px; }
.preview-box { white-space: pre-wrap; min-height: 80px; border: 1px solid var(--line); background: #0b131d; border-radius: 18px; padding: 14px; color: var(--text); overflow: auto; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 20px; padding: 20px; text-align: center; }
@media (max-width: 640px) {
  .app-shell { padding: 18px 12px 28px; }
  h1 { font-size: 26px; }
  .grid2, .actions { grid-template-columns: 1fr; }
  .editor-card { padding: 16px; border-radius: 22px; }
}
.top-actions { display: flex; align-items: center; gap: 8px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.link-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.event-card { gap: 12px; }
.event-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.event-grid > div { border: 1px solid var(--line); background: rgba(13,22,33,.45); border-radius: 15px; padding: 11px 12px; }
.event-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.event-grid b { font-size: 14px; }
.hint { margin-top: 12px; font-size: 13px; }
@media (max-width: 640px) {
  .top-actions { gap: 6px; }
  .event-grid { grid-template-columns: 1fr; }
}

.label-row { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.info-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 999px; background: rgba(143,195,255,.14); border: 1px solid rgba(143,195,255,.40); color: var(--accent2); font-size: 12px; font-weight: 900; line-height: 1; cursor: help; flex: 0 0 auto; user-select: none; }
.info-icon:focus { outline: none; box-shadow: 0 0 0 3px rgba(95,158,230,.20); }
.tg-tooltip { position: fixed; left: 12px; top: 12px; z-index: 1000; width: max-content; max-width: min(320px, calc(100vw - 24px)); background: #07101a; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12px; line-height: 1.35; font-weight: 600; text-transform: none; letter-spacing: 0; pointer-events: none; white-space: normal; overflow-wrap: anywhere; box-sizing: border-box; opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease; }
.tg-tooltip.visible { opacity: 1; transform: translateY(0); }
.checkbox-card { border: 1px solid var(--line); background: #132030; color: var(--text); border-radius: 15px; padding: 13px 14px; min-height: 50px; margin-bottom: 15px; }
.checkbox-card .label-row { flex: 1; }
.field[hidden] { display: none !important; }
.params-fields .checkbox-field { align-items: center; }
#messageTemplateInput { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.45; }
.preview-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.45; }

/* TG Alerts 3.3: preview is hidden until explicitly requested. */
.preview-box[hidden] { display: none !important; }
