@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600&family=Source+Code+Pro:wght@400;600&display=swap');

:root {
  --ink: #e2e8f0;
  --paper: #0b1220;
  --panel: #121b2f;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --muted: #94a3b8;
  --panel-border: #23324d;
  --panel-glow: rgba(56, 189, 248, 0.1);
  --col-left: 280px;
  --col-mid: 520px;
  --col-right: 380px;

  /* Centralized scrollbar theme (override per-surface by setting --scrollbar-track) */
  --scrollbar-size: 10px;
  --scrollbar-radius: 999px;
  --scrollbar-track: rgba(15, 23, 42, 0.35);
  --scrollbar-thumb: rgba(148, 163, 184, 0.55);
  --scrollbar-thumb-hover: rgba(226, 232, 240, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #18233b 0%, var(--paper) 60%);
  color: var(--ink);
  font-family: "Source Sans 3", sans-serif;
  height: 100vh;
  overflow: hidden;
}

/*
  Centralized scrollbar styling.
  Applies to any scrollable element within the app shell, including CodeMirror
  autocomplete tooltips, so new scrollable regions stay consistent by default.
*/
:where(.app-root, .app-root *) {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

:where(.app-root, .app-root *)::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

:where(.app-root, .app-root *)::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: var(--scrollbar-radius);
}

:where(.app-root, .app-root *)::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--scrollbar-radius);
  border: 2px solid var(--scrollbar-track);
}

:where(.app-root, .app-root *)::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

#app-root {
  height: 100%;
  display: block;
}

.landing-root {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.landing-shell {
  width: min(520px, 100%);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 12px 26px rgba(2, 6, 23, 0.35);
  padding: 20px;
}

.landing-title {
  margin: 0 0 8px;
  color: var(--ink);
}

.landing-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
}

.landing-form {
  display: grid;
  gap: 10px;
}

.landing-input {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.95);
  color: var(--ink);
  font-family: "Source Sans 3", sans-serif;
  padding: 10px 12px;
}

.landing-button {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-family: "Source Sans 3", sans-serif;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.landing-button:hover {
  background: var(--primary-hover);
}

.landing-message {
  margin: 10px 0 0;
  min-height: 20px;
  color: var(--muted);
}

.app-root {
  height: 100vh;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(20, 30, 52, 0.92), rgba(11, 18, 32, 0.9));
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 48px rgba(2, 6, 23, 0.35);
}

.app-header {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #101a2e;
  font-family: "Source Code Pro", monospace;
  margin-bottom: 14px;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.35);
}

.header-label {
  font-weight: 700;
}

.header-spacer {
  flex: 1;
}

.header-logout {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--ink);
  font-family: "Source Sans 3", sans-serif;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
}

.header-logout:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary);
  color: #ffffff;
}

.header-logout:disabled {
  opacity: 0.7;
  cursor: wait;
}

.app-grid {
  display: grid;
  grid-template-columns:
    minmax(200px, var(--col-left))
    2px
    minmax(280px, var(--col-mid))
    2px
    minmax(240px, var(--col-right));
  gap: 6px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.resize-handle {
  width: 2px;
  height: 100%;
  align-self: stretch;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  cursor: col-resize;
  position: relative;
  z-index: 1;
}

.resize-handle::before {
  content: "";
  position: absolute;
  inset: 0 -6px;
  background: transparent;
}

.resize-handle.vertical {
  width: 100%;
  height: 2px;
  align-self: stretch;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  cursor: row-resize;
}

.resize-handle.vertical::before {
  content: "";
  position: absolute;
  inset: -6px 0;
  background: transparent;
}

.resize-handle.vertical::after {
  inset: 1px 6px;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 6px 3px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.35);
  opacity: 0.2;
}

.resize-handle:hover::after {
  opacity: 0.6;
}

.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(2, 6, 23, 0.35);
  height: 100%;
}

.panel-title {
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--panel-border);
  background: #101a2e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
}

.panel-body {
  padding: 10px;
  flex: 1;
  display: flex;
  align-items: stretch;
  background: transparent;
  min-height: 0;
}

.template-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "Source Code Pro", monospace;
}

.template-item {
  width: 100%;
  list-style: none;
}

.template-item .thaw-button {
  width: 100%;
  justify-content: flex-start;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--panel-border);
  padding: 6px 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  border-radius: 10px;
}

.template-item.is-active .thaw-button {
  border-color: var(--primary-hover);
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.35);
}

.template-accordion {
  width: 100%;
  font-family: "Source Code Pro", monospace;
}

.template-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  padding-right: 2px;
}

/* Give the header more height so template images read well */
.template-accordion .thaw-accordion-header__button {
  min-height: 132px;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Hide default accordion chevron for the templates panel */
.template-accordion .thaw-accordion-header__expand-icon {
  display: none;
}

.template-accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-accordion-icon-box {
  width: 260px;
  height: 120px;
  flex: 0 0 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.template-accordion-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: none !important;
  transition: none !important;
  animation: none !important;
}


.template-accordion-title {
  font-weight: 700;
}

.template-accordion .thaw-accordion-panel {
  margin: 0;
  padding: 0 4px 10px 4px;
}

.template-yaml {
  padding: 10px;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--panel-border);
}

.template-yaml-block {
  position: relative;
}

.template-yaml-code {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.7);
  color: var(--ink);
  overflow: auto;
  white-space: pre;
  --scrollbar-track: rgba(8, 12, 24, 0.55);
}

.template-copy-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.template-copy-icon:hover {
  border-color: var(--primary-hover);
}

.template-copy-icon.is-copied {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.12);
}

.template-copy-icon.is-failed {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.16);
}

.config-panel {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

.config-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Scrollbar styling for CodeMirror editor (Configuration panel) */
.config-editor .cm-scroller {
  /* Inherits centralized scrollbar theme */
}

.config-validation {
  min-height: 22px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.7);
  padding: 6px 10px;
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
  color: var(--muted);
}

.config-ok {
  margin: 0;
  color: var(--accent);
}

.config-errors {
  margin: 0;
  padding-left: 16px;
  color: var(--accent-strong);
}

.config-errors li {
  margin: 0 0 3px 0;
}

.right-stack {
  --row-top: 320px;
  --row-bottom: 240px;
  display: grid;
  grid-template-rows: minmax(200px, var(--row-top)) 2px minmax(180px, calc(100% - var(--row-top) - 14px));
  gap: 6px;
  height: 100%;
  min-height: 0;
}

.mid-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  min-height: 0;
}

.render-panel {
  width: 100%;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.render-canvas {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(9, 14, 26, 0.95);
  overflow: hidden;
}

.render-carousel {
  flex: 1 1 auto;
  width: 100%;
  position: relative;
  display: flex;
  min-height: 0;
}

.render-carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--ink);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  width: 40px;
  height: 74px;
  cursor: pointer;
}

.render-carousel-nav:hover {
  border-color: var(--primary-hover);
  background: var(--primary);
  color: #ffffff;
}

.render-carousel-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.render-carousel-nav:hover:disabled {
  border-color: var(--panel-border);
  background: rgba(15, 23, 42, 0.82);
  color: var(--ink);
}

.render-carousel-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.8);
  display: block;
  overflow: hidden;
}

.render-carousel-empty {
  position: absolute;
  inset: 8px 58px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
}

.render-carousel-nav.is-prev {
  left: 10px;
}

.render-carousel-nav.is-next {
  right: 10px;
}

.render-carousel-slide {
  position: absolute;
  inset: 8px 58px;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  gap: 0;
  padding: 0;
}

.render-carousel-image-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.render-carousel-image {
  position: absolute !important;
  inset: 0 !important;
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
  min-height: 0;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center;
  border-radius: 8px;
}

.render-stl-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border: 0;
  border-radius: 0;
  background: rgba(10, 16, 30, 0.9);
}

.render-carousel-canvas-wrap {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.render-placeholder {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 18px 22px;
  color: var(--muted);
  font-family: "Source Code Pro", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 12px;
}

.action-bar {
  display: flex;
  gap: 12px;
}

.console-panel {
  width: 100%;
  display: flex;
}

.console-lines {
  width: 100%;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(8, 12, 24, 0.95);
  color: #e2e8f0;
  font-family: "Source Code Pro", monospace;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: auto;
  --scrollbar-track: rgba(8, 12, 24, 0.55);
}

.console-lines p {
  margin: 0 0 6px 0;
}

.action-bar .thaw-button,
.action-bar button {
  flex: 1;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  font-weight: 700;
  background: var(--primary);
  color: #ffffff;
  padding: 8px 12px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.action-bar .thaw-button:hover:not(:disabled),
.action-bar button:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.35);
}

.action-bar .thaw-button:disabled,
.action-bar button:disabled {
  background: rgba(30, 64, 175, 0.35);
  color: rgba(226, 232, 240, 0.55);
  border-color: rgba(35, 50, 77, 0.75);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.8;
}

@media (max-width: 720px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .render-canvas {
    height: 240px;
  }

  body {
    overflow: auto;
  }
}
