/* ============ PyCode — темы и базовый стиль ============ */
:root,
body[data-theme="dark"] {
  --bg: #12151c;
  --bg-soft: #171b24;
  --panel: #1c2130;
  --border: #2b3244;
  --text: #e6eaf2;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #38c172;
  --err: #ff5c6c;
  --warn: #ffb454;
  --editor-bg: #151922;
  --caret: rgba(79, 140, 255, 0.12);
  --tok-kw: #c792ea;
  --tok-str: #9fd28a;
  --tok-num: #f78c6c;
  --tok-com: #5f6b85;
  --tok-bi: #82aaff;
  --tok-fn: #ffcb6b;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

body[data-theme="light"] {
  --bg: #eef1f6;
  --bg-soft: #e6eaf2;
  --panel: #ffffff;
  --border: #d7ddea;
  --text: #1d2333;
  --muted: #67718a;
  --accent: #2f6fe4;
  --accent-soft: rgba(47, 111, 228, 0.1);
  --ok: #1a9e55;
  --err: #d93a4a;
  --warn: #b9761c;
  --editor-bg: #fbfcfe;
  --caret: rgba(47, 111, 228, 0.1);
  --tok-kw: #9333ea;
  --tok-str: #1a7f37;
  --tok-num: #c2410c;
  --tok-com: #8b94a7;
  --tok-bi: #1d4ed8;
  --tok-fn: #a16207;
  --shadow: 0 6px 20px rgba(30, 40, 70, 0.1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Huninn", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

/* ============ Шапка ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============ Кнопки ============ */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.08s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-ghost { background: transparent; }
.btn-mini { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }

.btn-run {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.btn-run:hover { filter: brightness(1.08); }

.select {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}

/* ============ Рабочая область ============ */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 16px;
  min-height: 0;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { min-height: 320px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.panel-head-actions { display: flex; align-items: center; gap: 10px; }
.panel-title { font-weight: 600; font-size: 14px; }
.panel-hint { color: var(--muted); font-size: 12px; }

/* ============ Редактор ============ */
.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  overflow: auto;
  background: var(--editor-bg);
}

.highlight,
.code-input {
  margin: 0;
  padding: 14px 16px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, "Cascadia Code", monospace;
  font-size: 14.5px;
  line-height: 22px;
  tab-size: 4;
  white-space: pre;
  word-wrap: normal;
  border: 0;
}

.highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--text);
  min-width: 100%;
  min-height: 100%;
  overflow: hidden;
}

.code-input {
  position: relative;
  display: block;
  width: 100%;
  min-height: 100%;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  resize: none;
  outline: none;
  overflow: hidden;
}
.code-input::placeholder { color: var(--muted); opacity: 0.7; }

.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-bi { color: var(--tok-bi); }
.tok-fn { color: var(--tok-fn); }

.caret-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 22px;
  background: var(--caret);
  border-left: 3px solid var(--err);
  pointer-events: none;
}

.editor-foot {
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12.5px;
}
.py-status.is-ready { color: var(--ok); }

/* ============ Вывод ============ */
.output {
  flex: 1;
  min-height: 160px;
  overflow: auto;
  padding: 14px 16px;
  background: var(--editor-bg);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 21px;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-placeholder { color: var(--muted); font-family: inherit; font-size: 13.5px; line-height: 1.6; }
.output-placeholder b { color: var(--text); }

.out-line { display: block; }
.out-stderr { color: var(--err); }
.out-ok { color: var(--ok); }
.out-info { color: var(--muted); }

/* ============ Подсказки по исправлению ============ */
.fixbox {
  border-top: 1px solid var(--border);
  background: var(--accent-soft);
  padding: 12px 16px 14px;
  max-height: 190px;
  overflow: auto;
}
.fixbox-head { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; color: var(--warn); }
.fix-list { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.55; }
.fix-list li { margin: 4px 0; }
.fix-list code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12.5px;
}

/* ============ Подвал ============ */
.footer {
  text-align: center;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

/* Скроллбары */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
