:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ec;
  --border-strong: #d9dde4;
  --text: #111318;
  --muted: #6b7280;
  --primary: #111827;
  --primary-soft: #f0f2f6;
  --success: #0a7a44;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.03), 0 10px 24px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1100px 600px at 120% -5%, #e9eef9 0%, #f6f7f9 55%) no-repeat, var(--bg);
  color: var(--text);
  font-family: "Sohne", "Geist", "SF Pro Text", "PingFang SC", sans-serif;
  letter-spacing: 0.01em;
}

.bg-orb { display: none; }

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -20px -20px 18px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: color-mix(in srgb, #ffffff 80%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: 0;
}

.title p {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a {
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  border: 1px solid transparent;
  padding: 7px 12px;
  border-radius: 9px;
  transition: all .15s ease;
}

.nav a:hover {
  color: #111827;
  background: var(--surface-2);
  border-color: var(--border);
}

.nav a.active {
  color: #0f172a;
  background: var(--primary-soft);
  border-color: var(--border-strong);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.card {
  grid-column: span 12;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.card h3 {
  margin: 10px 0 8px;
  font-size: 13px;
  font-weight: 650;
}

.card p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

label {
  display: block;
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 8px;
  font-weight: 550;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #b9c2cf;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.12);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
}

button:hover {
  border-color: #c6ceda;
  background: #f6f8fc;
}

button.primary {
  background: linear-gradient(180deg, #181c23 0%, #111827 100%);
  border-color: #111827;
  color: #fff;
}

button.primary:hover {
  background: linear-gradient(180deg, #202632 0%, #171f2d 100%);
}

button.success {
  background: linear-gradient(180deg, #0f8c4f 0%, #0a7a44 100%);
  border-color: #0a7a44;
  color: #fff;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.path-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.path-input button {
  width: auto;
  padding: 8px 12px;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-grid a {
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all .15s ease;
}

.btn-grid a:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-grid strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.btn-grid span {
  font-size: 12px;
  color: var(--muted);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  width: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 4px 10px;
  font-size: 11px;
  color: #374151;
}

.note {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.log {
  background: #0f172a;
  color: #d9fbe4;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 10px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.split-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px;
}

.panel-left {
  position: sticky;
  top: 86px;
  height: calc(100vh - 110px);
  overflow: auto;
}

.panel-right {
  display: grid;
  gap: 12px;
}

.tree-pane {
  max-height: calc(100vh - 250px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.tree-list button {
  margin-bottom: 5px;
  text-align: left;
}

.tree-ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

.tree-li { margin: 2px 0; }

.tree-node {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  font-size: 12px;
}

.tree-node.root {
  margin-bottom: 8px;
  padding: 8px 9px;
  font-weight: 650;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.visual-window {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  overflow: hidden;
}

.visual-window img {
  width: 100%;
  display: block;
}

.visual-window svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.visual-window.small {
  max-width: 360px;
}

.compare {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.compare-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1220;
}

.compare-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-frame .overlay { clip-path: inset(0 0 0 50%); }

#splitLine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #f59e0b;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.triple figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.triple img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.triple figcaption {
  margin-top: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

#chart {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.hidden { display: none !important; }

.pp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 20px;
}

.pp-modal {
  width: min(860px, 96vw);
  height: min(78vh, 760px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 0;
}

.pp-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pp-head strong {
  font-size: 14px;
}

.pp-head button {
  width: auto;
  min-width: 64px;
}

.pp-toolbar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.pp-toolbar button {
  width: auto;
}

.pp-list {
  margin: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
}

.pp-row {
  text-align: left;
}

.pp-actions {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pp-actions button {
  width: auto;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.hero .kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hero .kpi div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
}

.hero .kpi strong {
  display: block;
  font-size: 18px;
  margin-bottom: 3px;
}

.hero .kpi span {
  font-size: 11px;
  color: var(--muted);
}

.home-main {
  display: grid;
  gap: 14px;
}

.home-entry-wrap {
  padding: 18px;
}

.home-entry-head {
  margin-bottom: 14px;
}

.home-entry-head h2 {
  margin: 0;
  font-size: 18px;
}

.home-entry-head p {
  margin: 6px 0 0;
  font-size: 13px;
}

.home-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-entry {
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  min-height: 102px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.home-entry:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 18px rgba(16, 24, 40, 0.06);
}

.home-entry strong {
  font-size: 15px;
  line-height: 1.25;
}

.home-entry span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 980px) {
  .col-4,
  .col-6,
  .col-8 {
    grid-column: span 12;
  }

  .row,
  .btn-grid,
  .triple,
  .visual-grid,
  .hero,
  .hero .kpi {
    grid-template-columns: 1fr;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .panel-left {
    position: static;
    height: auto;
  }

  .home-entry-grid {
    grid-template-columns: 1fr;
  }
}

.prep-page .prep-grid {
  gap: 10px;
}

.prep-page .card {
  padding: 13px;
}

.prep-page .card h2 {
  margin-bottom: 9px;
}

.prep-page label {
  margin-bottom: 6px;
}

.prep-page .row {
  gap: 8px;
  margin-bottom: 2px;
}

.prep-page .path-input {
  --prep-side-w: 112px;
  grid-template-columns: minmax(0, 1fr) var(--prep-side-w);
  gap: 6px;
  margin-bottom: 6px;
}

.prep-page .path-input button {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
}

.prep-page .path-input.path-input-ghost .path-ghost {
  display: block;
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  visibility: hidden;
}

.prep-page input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
}

.prep-page .card > button.primary {
  margin-top: 2px;
  min-height: 34px;
}

.prep-page .prep-task-card h2 {
  min-height: 38px;
  line-height: 1.35;
  display: flex;
  align-items: center;
}

.prep-page .prep-task-card .inline-check {
  min-height: 30px;
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.prep-page .prep-task-card .task-run {
  margin-top: auto;
}

.prep-page #pythonHint {
  display: flex;
  align-items: center;
  min-height: 34px;
}

.prep-page #jobChips {
  margin: 6px 0 8px;
  max-height: 94px;
  overflow: auto;
}

.prep-page #jobLog {
  min-height: 132px;
  max-height: 220px;
}

.prep-page #status {
  margin-top: 6px;
}

.prep-page .tr-job-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.prep-page .tr-job-row label {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .prep-page .card {
    padding: 14px;
  }

  .prep-page .path-input {
    --prep-side-w: 96px;
  }
}
