:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --line: #d6dde5;
  --ink: #15202b;
  --muted: #627386;
  --accent: #137c72;
  --accent-2: #b3442b;
  --focus: #e2f3f1;
  --shadow: 0 10px 28px rgba(19, 32, 43, 0.1);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 58px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.1;
}

.brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

#fileInput {
  display: none;
}

.tool-button,
.icon-button,
.multiwfn-box button,
.inspector-tabs button,
.panel-popout,
.chart-window-tools button,
.measure-actions button,
.trend-actions button,
.segmented button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.tool-button {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
}

.language-control {
  height: 34px;
  display: inline-flex;
  align-items: center;
}

.language-control select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 9px;
}

.language-control select:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.icon-button {
  width: 36px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
}

.tool-button:hover,
.icon-button:hover,
.multiwfn-box button:hover,
.inspector-tabs button:hover,
.panel-popout:hover,
.chart-window-tools button:hover,
.measure-actions button:hover,
.trend-actions button:hover,
.segmented button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.tool-button:disabled,
.icon-button:disabled,
.inspector-tabs button:disabled,
.measure-actions button:disabled,
.trend-actions button:disabled,
.segmented button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-button:disabled:hover,
.icon-button:disabled:hover,
.measure-actions button:disabled:hover,
.trend-actions button:disabled:hover {
  border-color: var(--line);
  background: var(--surface);
}

.workspace {
  --sidebar-width: 280px;
  --inspector-width: 340px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--sidebar-width) 12px minmax(360px, 1fr) 12px var(--inspector-width);
  gap: 0;
  padding: 12px;
}

.layout-splitter {
  position: relative;
  min-width: 12px;
  cursor: col-resize;
  touch-action: none;
}

.layout-splitter::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.layout-splitter:hover::before,
.layout-splitter.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(19, 124, 114, 0.12);
}

body.layout-resizing {
  cursor: col-resize;
  user-select: none;
}

.sidebar,
.inspector,
.viewer-column {
  min-height: 0;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  min-width: 0;
}

.panel-head {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.panel-popout {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  font-size: 15px;
}

.inspector-tabs {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.inspector-tabs button {
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.inspector-tabs button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.inspector-page {
  display: none;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
}

.inspector-page.active {
  display: flex;
}

body.panel-expanded-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(21, 32, 43, 0.36);
}

.inspector-page.panel-expanded {
  position: fixed;
  inset: 72px 18px 18px;
  z-index: 19;
  display: flex;
  overflow: hidden;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.panel-head span {
  min-width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.project-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.file-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.file-list.empty,
.input-tree,
.analysis-view {
  color: var(--muted);
  font-size: 13px;
}

.file-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 6px 6px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  user-select: none;
}

.file-item:hover,
.file-item.active {
  border-color: var(--accent);
  background: var(--focus);
}

.file-item-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.file-item-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.file-item-info span {
  color: var(--muted);
  font-size: 12px;
}

.file-item-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.file-item-del:hover {
  background: rgba(220, 38, 38, 0.10);
  color: #dc2626;
}

.file-item-del:active {
  background: rgba(220, 38, 38, 0.18);
}

.viewer-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
}

.viewer-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  box-shadow: var(--shadow);
}

#structureCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-hud {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(16, 22, 29, 0.72);
  color: #edf4f8;
  font-size: 13px;
  pointer-events: none;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(135, 216, 204, 0.78);
  border-radius: 8px;
  background: rgba(16, 22, 29, 0.72);
  color: #f7fbfc;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.985);
  transition: opacity 120ms ease, transform 120ms ease;
}

.drag-active .drop-overlay {
  opacity: 1;
  transform: scale(1);
}

.framebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.framebar .icon-button {
  flex: 0 0 36px;
}

#frameSlider {
  flex: 1 1 180px;
  min-width: 110px;
  accent-color: var(--accent);
}

.mini-control {
  flex: 0 1 150px;
  min-width: 128px;
  display: grid;
  grid-template-columns: auto minmax(54px, 1fr) 42px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.toggle-control {
  flex: 0 0 auto;
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.toggle-control input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.mini-control input {
  width: 100%;
  accent-color: var(--accent);
}

.mini-control output {
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.atom-status {
  flex: 1 1 210px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 13px;
}

#frameLabel {
  flex: 0 0 68px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px 10px;
  margin: 0;
  padding: 12px;
  font-size: 13px;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px;
}

.segmented button {
  height: 32px;
  padding: 0;
  font-size: 12px;
}

.segmented button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#measurePanel {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#measurePanel > .panel-head {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

#measurePanel > .measure-result,
#measurePanel > .measure-actions,
#measurePanel > .saved-measurements,
#measurePanel > .selection-list,
#measurePanel > .trend-panel {
  flex: 0 0 auto;
}

.selection-list,
.measure-result {
  margin: 0 10px 10px;
  min-width: 0;
  padding: 8px;
  min-height: 36px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.selection-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atom-chip {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.measure-result {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.measure-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: -2px 10px 10px;
  min-width: 0;
}

.measure-actions button {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.measure-actions button:disabled {
  cursor: default;
  opacity: 0.45;
}

.saved-measurements {
  margin: 0 10px 10px;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.saved-measurements-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.saved-measure-list {
  display: grid;
  gap: 6px;
}

.saved-measure-list.empty {
  padding: 8px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.saved-measure-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.saved-measure-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.saved-measure-title,
.saved-measure-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-measure-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.saved-measure-value {
  color: #137c72;
  font-size: 15px;
  font-weight: 800;
}

.saved-measure-meta {
  color: var(--muted);
  font-size: 11.5px;
}

.saved-measure-delete {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1;
}

.trend-panel {
  margin: 0 10px 10px;
  min-width: 0;
  max-width: calc(100% - 20px);
  display: grid;
  gap: 8px;
  overflow: hidden;
}

#trendCanvas {
  width: 100%;
  max-width: 100%;
  height: 190px;
  min-height: 190px;
  display: block;
  cursor: crosshair;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.trend-actions button:disabled {
  cursor: default;
  opacity: 0.45;
}

.trend-actions {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.trend-actions span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-actions button {
  justify-self: end;
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
  white-space: nowrap;
}

.panel-expanded #trendCanvas {
  height: min(52vh, 520px);
}

.opt-chart-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 8px;
  color: var(--muted);
  font-size: 12px;
}

.opt-chart-tools span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.opt-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(19, 124, 114, 0.06), rgba(19, 124, 114, 0.02));
  color: #137c72;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.opt-expand-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.opt-expand-btn:hover {
  background: linear-gradient(135deg, rgba(19, 124, 114, 0.12), rgba(19, 124, 114, 0.05));
  border-color: rgba(19, 124, 114, 0.45);
  box-shadow: 0 2px 10px rgba(19, 124, 114, 0.12);
  transform: translateY(-1px);
}

.opt-expand-btn:active {
  transform: scale(0.97) translateY(0);
  transition: transform 0.08s ease;
}

/* Inline chart label */
.opt-chart-label-inline {
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  user-select: none;
}

.opt-chart-stack {
  display: grid;
  gap: 0;
  padding: 0 6px;
}

.opt-chart-item {
  min-width: 0;
  border-top: 1px solid #aeb7c2;
}

.opt-chart-item:first-child {
  border-top: 2px solid #a60000;
}

.opt-chart-item.active {
  border-left: 3px solid #a60000;
  background: #fff8f6;
}

.opt-plot-canvas {
  width: 100%;
  height: 138px;
  display: block;
  cursor: crosshair;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  background: #fffdf4;
  touch-action: none;
}

.opt-plot-canvas.active {
  border-left-color: #a60000;
  border-right-color: #a60000;
}

.opt-chart-status {
  min-height: 30px;
  margin-top: 0;
  padding: 7px 10px 8px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  background: #f7f9fb;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.panel-expanded .analysis-view,
.panel-expanded .input-tree {
  font-size: 14px;
}

.panel-expanded .analysis-grid {
  grid-template-columns: 140px minmax(0, 1fr);
}

.panel-expanded .opt-plot-canvas {
  height: 210px;
}

.panel-expanded .opt-chart-stack {
  padding: 0 10px;
}

.chart-window {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 30;
  width: min(960px, calc(100vw - 48px));
  height: min(720px, calc(100vh - 80px));
  min-width: 500px;
  min-height: 400px;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) auto;
  overflow: hidden;
  resize: none;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  background: #fafaf9;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.06),
    0 16px 48px rgba(0, 0, 0, 0.10),
    0 0 0 0.5px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(20px);
}

.chart-window[hidden] {
  display: none;
}

.chart-resize-handle {
  position: absolute;
  z-index: 3;
  touch-action: none;
}

.chart-resize-n,
.chart-resize-s {
  left: 12px;
  right: 12px;
  height: 10px;
  cursor: ns-resize;
}

.chart-resize-n {
  top: -4px;
}

.chart-resize-s {
  bottom: -4px;
}

.chart-resize-e,
.chart-resize-w {
  top: 12px;
  bottom: 12px;
  width: 10px;
  cursor: ew-resize;
}

.chart-resize-e {
  right: -4px;
}

.chart-resize-w {
  left: -4px;
}

.chart-resize-ne,
.chart-resize-nw,
.chart-resize-se,
.chart-resize-sw {
  width: 18px;
  height: 18px;
}

.chart-resize-ne {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.chart-resize-nw {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.chart-resize-se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}

.chart-resize-sw {
  left: -5px;
  bottom: -5px;
  cursor: nesw-resize;
}

.chart-resize-se::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 9px;
  height: 9px;
  border-right: 2px solid rgba(90, 90, 110, 0.32);
  border-bottom: 2px solid rgba(90, 90, 110, 0.32);
  border-radius: 1px;
}

.chart-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  cursor: move;
  user-select: none;
  border-radius: 14px 14px 0 0;
}

.chart-window-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  color: #1a1a2e;
  letter-spacing: 0.01em;
}

.chart-window-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.premium-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: #4a4a5a;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.premium-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.14);
  color: #1a1a2e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.premium-btn:active {
  transform: scale(0.97);
  transition: transform 0.08s ease;
}

.premium-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.premium-btn:hover svg {
  opacity: 1;
}

.chart-window-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px;
  display: grid;
  gap: 8px;
  align-content: start;
  background: #fafaf9;
}

.chart-window-body canvas {
  width: 100%;
  height: 160px;
  display: block;
  cursor: crosshair;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: #fffdf7;
  touch-action: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.chart-window-body canvas:hover {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.chart-window-body canvas.focus {
  border-color: #a3745b;
  box-shadow: 0 0 0 2px rgba(163, 116, 91, 0.15);
}

.cw-chart-wrap {
  position: relative;
}

.cw-chart-label {
  position: absolute;
  top: 1px;
  left: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 20px);
  padding: 2px 5px 2px 8px;
  border-radius: 0 0 6px 6px;
  background: rgba(47, 111, 115, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

.chart-window-info {
  min-height: 36px;
  padding: 8px 18px 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  color: #5a5a6e;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  border-radius: 0 0 14px 14px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

.analysis-panel,
.tree-panel {
  flex: 1;
  flex-direction: column;
}

.inspector-page:not(.active) {
  display: none;
}

.inspector-page.active {
  display: flex;
}

.analysis-view,
.input-tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

.analysis-report {
  display: grid;
  gap: 8px;
}

.analysis-section {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.analysis-section summary {
  min-height: 32px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 6px 8px;
  margin: 0;
  padding: 0 10px 10px;
}

.analysis-grid dt {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.analysis-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.locatable-grid dd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.locatable-grid dd span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.inline-locate-btn {
  flex: 0 0 auto;
  height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(19, 124, 114, 0.24);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.inline-locate-btn:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.inline-out-locator {
  padding-top: 2px;
}

.warning-groups {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.warning-group {
  border: 1px solid #e1e7ee;
  border-radius: 7px;
  background: #fff;
}

.warning-group summary {
  min-height: 30px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 9px;
  font-weight: 600;
}

.warning-group summary::marker {
  color: var(--muted);
}

.warning-summary-text {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-weight: 500;
}

.warning-lines {
  display: grid;
  gap: 4px;
  padding: 0 9px 9px;
}

.warning-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 4px 0;
  border-top: 1px solid #eef2f5;
  font-size: 12px;
}

.warning-line span:first-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.warning-line span:nth-child(2) {
  overflow-wrap: anywhere;
}

.analysis-empty {
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 13px;
}

.energy-block-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 8px;
  color: var(--muted);
  font-size: 12px;
}

.energy-block-tools span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.energy-locate-btn {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.28);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.energy-locate-btn:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.energy-breakdown-grid {
  grid-template-columns: minmax(145px, 1fr) minmax(0, auto);
}

.energy-breakdown-grid dd {
  font-family: "Cascadia Code", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.scf-section .energy-block-tools {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.scf-section .energy-block-tools span {
  flex: 1 1 100%;
}

.scf-chart-hint {
  line-height: 1.45;
}

.out-snippet {
  margin: 0 10px 10px;
  padding: 8px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #15202b;
  color: #e9f3f1;
  font-size: 12px;
}

.out-locator-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 8px;
  color: var(--muted);
  font-size: 12px;
}

.out-locator-tools span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.out-locator-close {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.out-locator-close:hover {
  border-color: var(--accent);
  background: var(--focus);
  color: var(--ink);
}

.out-line {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  padding: 2px 10px;
}

.out-line.target {
  background: rgba(19, 124, 114, 0.24);
}

.out-line.flash {
  background: rgba(179, 68, 43, 0.42);
}

.out-line-number {
  color: #9fb2c4;
  text-align: right;
  user-select: none;
}

.out-line code {
  min-width: 0;
  color: inherit;
  white-space: pre;
}

.input-tree-view {
  display: grid;
  gap: 4px;
}

.input-tree details {
  margin: 3px 0;
}

.input-tree-node {
  margin-left: calc(var(--depth, 0) * 14px);
  padding-left: 8px;
  border-left: 1px solid rgba(98, 115, 134, 0.18);
}

.input-tree-node[open] {
  border-left-color: rgba(19, 124, 114, 0.35);
}

.input-tree summary,
.inp-editor summary {
  cursor: pointer;
  font-weight: 700;
}

.input-tree code {
  display: block;
  margin: 3px 0 3px 18px;
  color: var(--muted);
  white-space: pre-wrap;
}

.input-param {
  padding-left: 8px;
  border-left: 2px solid rgba(214, 221, 229, 0.85);
}

.inp-editor {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.inp-editor summary {
  min-height: 32px;
  padding: 8px 10px;
}

.inp-editor-text {
  width: calc(100% - 20px);
  min-height: 260px;
  margin: 0 10px 8px;
  padding: 8px 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #15202b;
  color: #e9f3f1;
  font: 12px "Cascadia Code", Consolas, monospace;
  line-height: 1.45;
  tab-size: 2;
}

.inp-editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 12px;
}

.inp-editor-actions span {
  flex: 1 1 140px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inp-editor-actions button {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.inp-editor-actions button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.inp-snippet-tools {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 0 10px 8px;
}

.inp-snippet-tools select {
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.inp-snippet-tools button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.inp-snippet-tools button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.inp-snippet-status {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.inp-snippet-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 32, 43, 0.42);
}

.inp-snippet-dialog-panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(21, 32, 43, 0.24);
}

.inp-snippet-dialog-head,
.inp-snippet-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inp-snippet-dialog-head strong {
  font-size: 15px;
}

.inp-snippet-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inp-snippet-dialog input,
.inp-snippet-dialog textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 12px "Cascadia Code", Consolas, monospace;
}

.inp-snippet-dialog input {
  height: 34px;
  padding: 0 10px;
}

.inp-snippet-dialog textarea {
  min-height: 260px;
  max-height: min(52vh, 520px);
  padding: 10px;
  resize: vertical;
  background: #15202b;
  color: #e9f3f1;
  line-height: 1.45;
  tab-size: 2;
}

.inp-snippet-dialog button {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.inp-snippet-dialog button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.inp-snippet-dialog-actions span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .inp-snippet-tools {
    grid-template-columns: 1fr;
  }

  .inp-snippet-dialog {
    align-items: stretch;
    padding: 12px;
  }

  .inp-snippet-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.inp-compare {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.inp-compare summary {
  min-height: 32px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}

.inp-compare-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0 10px 10px;
}

.inp-compare-controls select {
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.inp-compare-controls button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.inp-compare-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 10px 10px;
}

.chart-window-body > .inp-compare-actions {
  padding: 0;
}

.inp-compare-actions button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(19, 124, 114, 0.25);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.inp-compare-actions button:hover,
.inp-compare-controls button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.inp-diff {
  margin: 0 10px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.chart-window-body > .inp-diff {
  margin: 0;
}

.chart-window-body > .inp-diff .inp-diff-rows {
  max-height: none;
  height: calc(100vh - 210px);
}

.chart-window-body > .inp-diff .inp-diff-header,
.chart-window-body > .inp-diff .inp-diff-row {
  grid-template-columns: minmax(0, 1fr) 168px minmax(0, 1fr);
}

.inp-diff-meta {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: #f6f8fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.inp-diff-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inp-diff-header span {
  min-width: 0;
  padding: 6px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inp-diff-header span:nth-child(2) {
  text-align: center;
}

.inp-diff-rows {
  max-height: 560px;
  overflow: auto;
  background: #fff;
}

.inp-diff-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px minmax(0, 1fr);
  gap: 0;
  border-bottom: 1px solid #edf1f5;
}

.inp-diff-row:last-child {
  border-bottom: none;
}

.inp-diff-cell {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  background: #fff;
}

.inp-diff-line {
  padding: 5px 6px;
  border-right: 1px solid #edf1f5;
  color: #8b98a8;
  background: #f8fafc;
  text-align: right;
  font: 12px "Cascadia Code", Consolas, monospace;
  user-select: none;
}

.inp-diff-cell code {
  min-width: 0;
  margin: 0;
  padding: 5px 8px;
  border-left: none;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px "Cascadia Code", Consolas, monospace;
}

.inp-diff-actions {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 4px;
  border-left: 1px solid #edf1f5;
  border-right: 1px solid #edf1f5;
  background: #f8fafc;
}

.inp-diff-actions button {
  width: 100%;
  min-width: 0;
  min-height: 24px;
  height: auto;
  padding: 0 5px;
  border: 1px solid rgba(19, 124, 114, 0.24);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
  white-space: normal;
}

.inp-diff-actions button:hover {
  border-color: var(--accent);
  background: var(--focus);
}

.diff-added .inp-diff-cell:last-child,
.diff-added .inp-diff-cell:last-child .inp-diff-line {
  background: rgba(19, 124, 114, 0.10);
}

.diff-removed .inp-diff-cell:first-child,
.diff-removed .inp-diff-cell:first-child .inp-diff-line {
  background: rgba(179, 68, 43, 0.10);
}

.diff-modified .inp-diff-cell,
.diff-modified .inp-diff-cell .inp-diff-line {
  background: rgba(228, 171, 74, 0.14);
}

.multiwfn-box {
  padding: 10px;
}

.multiwfn-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.multiwfn-box input {
  height: 34px;
  width: 100%;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.multiwfn-box button {
  width: 100%;
  margin-top: 8px;
}

.multiwfn-box pre {
  min-height: 54px;
  margin: 8px 0 0;
  padding: 8px;
  overflow: auto;
  border-radius: 7px;
  background: #15202b;
  color: #e9f3f1;
  font-size: 12px;
}

.ok {
  color: var(--accent);
  font-weight: 700;
}

.warn {
  color: var(--accent-2);
  font-weight: 700;
}

@media (max-width: 1180px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 12px;
    overflow: visible;
  }

  .layout-splitter {
    display: none;
  }

  .inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, auto);
  }

  #measurePanel {
    max-height: calc(100vh - 150px);
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    min-height: 58px;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
  }

  .inspector {
    display: grid;
    grid-template-rows: auto minmax(420px, auto);
  }

  #measurePanel {
    max-height: calc(100vh - 132px);
  }

  .viewer-column {
    min-height: 520px;
  }

  .atom-status {
    flex-basis: 100%;
  }

  .inspector-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}
