/* ═══════════════════════════════════════════════════════════
   PyOrbit — style.css
   Calm Charcoal Coding Theme
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Backgrounds — dark charcoal family, slight warm tint */
  --bg-0: #141415;
  /* deepest: body bg              */
  --bg-1: #1c1c1e;
  /* panel bg                      */
  --bg-2: #222224;
  /* toolbar / bars                */
  --bg-3: #2a2a2d;
  /* hover / elevated              */
  --bg-4: #323235;
  /* selected / active             */

  /* Borders */
  --bd-0: rgba(255, 255, 255, 0.055);
  /* very subtle  */
  --bd-1: rgba(255, 255, 255, 0.09);
  /* normal       */
  --bd-2: rgba(255, 255, 255, 0.14);
  /* active/hover */

  /* Text */
  --tx-0: rgba(255, 255, 255, 0.88);
  /* primary      */
  --tx-1: rgba(255, 255, 255, 0.55);
  /* secondary    */
  --tx-2: rgba(255, 255, 255, 0.32);
  /* muted        */
  --tx-3: rgba(255, 255, 255, 0.18);
  /* dimmed       */

  /* Accent — calm blue, not neon */
  --ac: #4f8ef7;
  /* primary accent          */
  --ac-dim: rgba(79, 142, 247, 0.15);
  /* accent bg tint */
  --ac-ring: rgba(79, 142, 247, 0.3);
  /* focus ring     */

  /* Semantic */
  --green: #4dbf9e;
  --yellow: #e8a030;
  --red: #e05c5c;
  --purple: #9b7ced;

  /* Typography */
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', 'Menlo', monospace;

  /* Geometry */
  --r-sm: 4px;
  --r-md: 7px;
  --r-lg: 10px;
  --topbar-h: 48px;
  --toolbar-h: 36px;
  --foot-h: 24px;

  /* Transitions */
  --t-fast: 100ms ease;
  --t-base: 180ms ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--tx-0);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(79, 142, 247, 0.25);
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin-stroke {
  0% {
    stroke-dashoffset: 28;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

/* ── Topbar ───────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--bd-0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-hex {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--bd-1);
  border-radius: var(--r-md);
  color: var(--ac);
  transition: all var(--t-base);
}

.brand-hex:hover {
  background: var(--bg-4);
  border-color: var(--bd-2);
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--tx-0);
}

.brand-pill {
  font-size: 9px;
  font-family: var(--font-code);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  border: 1px solid var(--bd-1);
  color: var(--tx-2);
}

/* Status pill */
#status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--bd-1);
  background: var(--bg-1);
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--tx-2);
  white-space: nowrap;
}

/* Status dot */
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--t-base), box-shadow var(--t-base);
}

.sdot.init {
  background: var(--yellow);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.sdot.ready {
  background: var(--green);
  box-shadow: 0 0 7px rgba(77, 191, 158, 0.5);
}

.sdot.running {
  background: var(--ac);
  animation: pulse-dot 0.7s ease-in-out infinite;
}

.sdot.error {
  background: var(--red);
}

.sdot.small {
  width: 6px;
  height: 6px;
}

/* Topbar actions */
.tb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  color: var(--tx-1);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
}

.tb-btn:hover {
  background: var(--bg-3);
  border-color: var(--bd-1);
  color: var(--tx-0);
}

/* Run button */
.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: #fff;
  background: var(--ac);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-base);
  white-space: nowrap;
}

.run-btn:not(:disabled):hover {
  background: #6099f8;
  box-shadow: 0 2px 12px rgba(79, 142, 247, 0.3);
  transform: translateY(-1px);
}

.run-btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: none;
}

.run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.run-btn:focus-visible {
  outline: 2px solid var(--ac-ring);
  outline-offset: 2px;
}

.run-kbd {
  font-size: 10px;
  font-family: var(--font-code);
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}

/* Spinner */
.spin-circle {
  animation: spin 0.9s linear infinite;
  transform-origin: center;
}

.hidden {
  display: none !important;
}

/* ── Layout ───────────────────────────────────────────────── */
#layout {
  display: flex;
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

/* ── Pane (shared by both panels) ────────────────────────── */
.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#editor-panel {
  width: 54%;
  min-width: 260px;
  max-width: 78%;
  border-right: 1px solid var(--bd-0);
  background: var(--bg-1);
  flex-shrink: 0;
}

#output-panel {
  flex: 1;
  min-width: 220px;
  background: var(--bg-1);
}

/* ── Pane Toolbar ─────────────────────────────────────────── */
.pane-bar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--bd-0);
  flex-shrink: 0;
}

.pane-bar-left,
.pane-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pane-title {
  font-size: 12px;
  font-family: var(--font-code);
  font-weight: 400;
  color: var(--tx-1);
}

/* Snippet select */
.snippet-sel {
  -webkit-appearance: none;
  appearance: none;
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--tx-2);
  background: var(--bg-3);
  border: 1px solid var(--bd-1);
  border-radius: var(--r-sm);
  padding: 3px 22px 3px 8px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='rgba(255,255,255,0.25)' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  transition: all var(--t-fast);
}

.snippet-sel option {
  background: #222224;
  color: rgba(255, 255, 255, 0.7);
}

.snippet-sel:hover {
  border-color: var(--bd-2);
  color: var(--tx-1);
}

.snippet-sel:focus {
  outline: none;
  border-color: var(--ac-ring);
}

/* Icon buttons */
.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--tx-2);
  cursor: pointer;
  transition: all var(--t-fast);
}

.icon-btn:hover {
  background: var(--bg-3);
  border-color: var(--bd-1);
  color: var(--tx-1);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--ac-ring);
  outline-offset: 1px;
}

/* ── Pane Tabs ────────────────────────────────────────────── */
.tabs-bar {
  padding: 0;
  padding-right: 10px;
}

.tabs {
  display: flex;
  align-items: stretch;
  height: var(--toolbar-h);
}

.tab {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 13px;
  font-size: 11px;
  font-family: var(--font-code);
  font-weight: 400;
  color: var(--tx-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.tab:hover {
  color: var(--tx-1);
}

.tab.active {
  color: var(--tx-0);
  border-bottom-color: var(--ac);
}

.badge {
  font-size: 9px;
  font-family: var(--font-code);
  padding: 1px 5px;
  border-radius: 99px;
  background: var(--ac-dim);
  border: 1px solid rgba(79, 142, 247, 0.25);
  color: var(--ac);
}

/* ── Tab panes ────────────────────────────────────────────── */
.tab-pane {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

/* ── Monaco mount ─────────────────────────────────────────── */
#monaco-mount {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

/* ── Console output ───────────────────────────────────────── */
#console-out {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: var(--font-code);
  font-size: 12.5px;
  line-height: 1.65;
}

.c-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 1px 0;
  animation: fadeUp 0.15s ease-out;
}

.c-line:hover {
  background: rgba(255, 255, 255, 0.015);
  border-radius: 3px;
}

.c-glyph {
  flex-shrink: 0;
  font-size: 10px;
  margin-top: 2px;
  user-select: none;
  width: 10px;
  text-align: center;
}

.c-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

/* Line types */
.c-line.output .c-glyph {
  color: rgba(79, 142, 247, 0.5);
}

.c-line.output .c-text {
  color: rgba(255, 255, 255, 0.82);
}

.c-line.error .c-glyph {
  color: var(--red);
}

.c-line.error .c-text {
  color: #e87070;
}

.c-line.warning .c-glyph {
  color: var(--yellow);
}

.c-line.warning .c-text {
  color: #e8b060;
}

.c-line.success .c-glyph {
  color: var(--green);
}

.c-line.success .c-text {
  color: var(--green);
}

.c-line.info .c-glyph {
  color: var(--ac);
}

.c-line.info .c-text {
  color: rgba(79, 142, 247, 0.9);
}

.c-line.system .c-glyph {
  color: var(--tx-3);
}

.c-line.system .c-text {
  color: var(--tx-2);
  font-style: italic;
}

.c-divider {
  height: 1px;
  background: var(--bd-0);
  margin: 8px 0;
}

/* ── Plots tab ────────────────────────────────────────────── */
#plot-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg-1);
}

#plot-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--tx-3);
  pointer-events: none;
}

.empty-h {
  font-size: 13px;
  font-weight: 500;
  color: var(--tx-2);
}

.empty-p {
  font-size: 11px;
  font-family: var(--font-code);
  color: var(--tx-3);
}

#plot-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plot-card {
  border: 1px solid var(--bd-1);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-2);
  animation: fadeUp 0.25s ease-out;
}

.plot-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--bd-0);
}

.plot-card-title {
  font-size: 10px;
  font-family: var(--font-code);
  color: var(--tx-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plot-card-actions {
  display: flex;
  gap: 4px;
}

.plot-card-body {
  padding: 10px;
}

.plot-card-body img {
  width: 100%;
  border-radius: var(--r-md);
  display: block;
}

/* ── Packages tab ─────────────────────────────────────────── */
.pkgs-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.section-hd {
  font-size: 10px;
  font-family: var(--font-code);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tx-3);
  margin-bottom: 10px;
}

.pkg-install-row {
  display: flex;
  gap: 8px;
}

.pkg-input {
  flex: 1;
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  font-family: var(--font-code);
  background: var(--bg-3);
  border: 1px solid var(--bd-1);
  border-radius: var(--r-md);
  color: var(--tx-0);
  transition: border-color var(--t-fast);
}

.pkg-input::placeholder {
  color: var(--tx-3);
}

.pkg-input:focus {
  outline: none;
  border-color: var(--ac-ring);
}

.install-btn {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--ac);
  background: var(--ac-dim);
  border: 1px solid rgba(79, 142, 247, 0.25);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-base);
  white-space: nowrap;
}

.install-btn:not(:disabled):hover {
  background: rgba(79, 142, 247, 0.25);
  border-color: rgba(79, 142, 247, 0.45);
}

.install-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Package list rows */
.pkg-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--bd-0);
  margin-bottom: 5px;
  background: var(--bg-2);
  transition: border-color var(--t-fast);
}

.pkg-item:hover {
  border-color: var(--bd-1);
}

.pkg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--yellow);
  transition: all var(--t-base);
}

[data-s="ready"] .pkg-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(77, 191, 158, 0.4);
  animation: none;
}

[data-s="loading"] .pkg-dot {
  animation: pulse-dot 1.2s ease-in-out infinite;
}

[data-s="error"] .pkg-dot {
  background: var(--red);
}

.pkg-nm {
  font-size: 12px;
  font-family: var(--font-code);
  color: var(--tx-1);
  flex: 1;
}

.pkg-ver {
  font-size: 10px;
  font-family: var(--font-code);
  color: var(--tx-3);
  letter-spacing: 0.02em;
}

/* ── Pane footer / statusbar ──────────────────────────────── */
.pane-foot {
  height: var(--foot-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  background: var(--bg-2);
  border-top: 1px solid var(--bd-0);
  flex-shrink: 0;
  font-size: 10px;
  font-family: var(--font-code);
  color: var(--tx-3);
}

.foot-sep {
  color: var(--tx-3);
  opacity: 0.5;
}

.foot-spacer {
  flex: 1;
}

#py-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Resize divider ───────────────────────────────────────── */
#divider {
  width: 4px;
  height: 100%;
  background: var(--bd-0);
  cursor: col-resize;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  position: relative;
  z-index: 10;
}

#divider:hover,
#divider.active {
  background: rgba(79, 142, 247, 0.3);
}

.divider-grip {
  width: 2px;
  height: 28px;
  border-radius: 2px;
  background: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.18) 0, rgba(255, 255, 255, 0.18) 2px,
      transparent 2px, transparent 5px);
  opacity: 0;
  transition: opacity var(--t-fast);
}

#divider:hover .divider-grip,
#divider.active .divider-grip {
  opacity: 1;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-lg);
  background: var(--bg-4);
  border: 1px solid var(--bd-1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  font-family: var(--font-code);
  color: var(--tx-1);
  animation: toast-in 0.25s ease-out;
  pointer-events: none;
}

#toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success #toast-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(77, 191, 158, 0.5);
}

.toast.error #toast-dot {
  background: var(--red);
}

.toast.info #toast-dot {
  background: var(--ac);
}

.toast.warning #toast-dot {
  background: var(--yellow);
}

/* ── Monaco Editor overrides ──────────────────────────────── */
.monaco-editor,
.monaco-editor-background,
.monaco-editor .inputarea.ime-input {
  background: var(--bg-1) !important;
}

.monaco-editor .margin {
  background: var(--bg-1) !important;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  #layout {
    flex-direction: column;
  }

  #editor-panel {
    width: 100% !important;
    min-width: unset;
    max-width: unset;
    height: 52%;
    border-right: none;
    border-bottom: 1px solid var(--bd-0);
  }

  #divider {
    width: 100%;
    height: 4px;
    cursor: row-resize;
  }

  .divider-grip {
    width: 28px;
    height: 2px;
    background: repeating-linear-gradient(to right,
        rgba(255, 255, 255, 0.18) 0, rgba(255, 255, 255, 0.18) 2px,
        transparent 2px, transparent 5px);
  }

  #output-panel {
    flex: 1;
    min-width: unset;
  }

  .run-kbd {
    display: none;
  }

  #status-pill {
    display: none;
  }
}

@media (max-width: 480px) {
  #editor-panel {
    height: 48%;
  }

  .brand-pill {
    display: none;
  }

  #run-label {
    display: none;
  }
}

/* ── Focus visible ─────────────────────────────────────────── */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--ac-ring);
  outline-offset: 2px;
}