:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #1a2130;
  --border: #232b3a;
  --text: #d7deea;
  --muted: #8b93a7;
  --accent: #3aa0ff;
}
/* светлая тема: переопределяем токены + правим точечные тёмные фоны */
body.light {
  --bg: #f4f6fb; --panel: #ffffff; --panel-2: #eef1f7; --border: #d6dae4;
  --text: #1c2230; --muted: #5b6270; --accent: #2b7fff;
}
body.light .menu-drop, body.light #lun-news, body.light #lun-cal, body.light #lun-style-panel { background: #ffffff; }
body.light .btns button { background: #eef1f7; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* ---- toolbar ---- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.group { display: flex; align-items: center; gap: 6px; }
.glabel { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.btns { display: flex; gap: 4px; }
.btns button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 9px; cursor: pointer; font-size: 12px;
}
.btns button:hover { border-color: var(--accent); }
.btns button.active { background: var(--accent); color: #04121f; border-color: var(--accent); font-weight: 600; }
.btns button.danger:hover { border-color: #ef5350; color: #ef5350; }
.btns button.find-btn { padding: 5px 14px; font-size: 13px; font-weight: 600; background: #1f2b3d; border-color: var(--accent); }
.btns button.find-btn:hover { background: var(--accent); color: #04121f; }

/* ---- menubar (верхнее меню с выпадашками) ---- */
.menubar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 8px; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.menu { position: relative; }
.menu-btn {
  background: transparent; color: var(--text); border: 1px solid transparent;
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.menu-btn:hover { background: var(--panel-2); }
.menu.open > .menu-btn { background: var(--panel-2); border-color: var(--border); }
.menu-drop {
  display: none; position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 50;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px; min-width: 190px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.menu.open > .menu-drop { display: block; }
#layouts-drop { left: auto; right: 0; }
.menu-drop.scroll { max-height: 70vh; overflow-y: auto; }
.menu-sub { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 6px 3px; }
.menu-note { color: var(--muted); padding: 8px 10px; font-size: 12px; }
/* кнопки внутри выпадашек — списком, во всю ширину */
.menu-drop .btns { display: flex; flex-direction: column; gap: 3px; align-items: stretch; }
.menu-drop .btns button { text-align: left; padding: 6px 10px; }
/* галочки-тумблеры для индикаторов / циклов / аспектов */
#indicators button::before, #cycles button::before, #aspects button::before { content: '☐ '; color: var(--muted); }
#indicators button.active::before, #cycles button.active::before, #aspects button.active::before { content: '☑ '; color: var(--accent); }
#indicators button.active, #cycles button.active, #aspects button.active { background: var(--panel-2); color: var(--text); font-weight: 400; }
/* подсказка хоткея справа на кнопке рисования */
.menu-drop .btns button .hk { float: right; color: var(--muted); font-size: 11px; margin-left: 14px; }

/* ---- chart / grid ---- */
.sym-title { padding: 4px 12px; color: var(--muted); font-size: 12px; }
#chart { flex: 1 1 auto; min-height: 0; }
#chart .cell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
#chart .cell.cell-active { box-shadow: inset 0 0 0 2px var(--accent); }   /* активная ячейка */
.sync-vline { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(58,160,255,.55); pointer-events: none; display: none; z-index: 6; }
.sync-hline { position: absolute; left: 0; right: 0; height: 1px; background: rgba(58,160,255,.30); pointer-events: none; display: none; z-index: 6; }

/* ---- status bar ---- */
.statusbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; background: var(--panel);
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.statusbar b { color: var(--text); }
.spacer { flex: 1 1 auto; }

/* ---- мобильная раскладка ---------------------------------------------------
 * Узкий экран: верхнее меню прокручивается ГОРИЗОНТАЛЬНО само по себе (свайп),
 * а не расширяет страницу и не сдвигает график. Открытая выпадашка — фикс.
 * панель во всю ширину (не обрезается прокруткой меню и не двигает график). */
html, body { overflow-x: hidden; }
@media (max-width: 820px) {
  .menubar {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  }
  .menubar .spacer { display: none; }         /* не растягиваем панель вправо */
  .menu-btn { padding: 6px 9px; font-size: 13px; }
  .menu.open > .menu-drop {
    position: fixed; left: 6px; right: 6px; top: 46px; margin-top: 0;
    min-width: 0; max-height: 78vh; overflow-y: auto; z-index: 200;
  }
  #layouts-drop { left: 6px; right: 6px; }
}
