:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef3f7;
  --ink: #18212f;
  --muted: #657386;
  --line: #d9e0e8;
  --accent: #146c5f;
  --accent-strong: #0d5148;
  --accent-soft: #dff2ee;
  --blue: #2563eb;
  --green: #16803f;
  --danger: #b42318;
  --warn: #9a5b12;
  --warn-soft: #fff2d8;
  --code: #111827;
  --shadow: 0 18px 55px rgba(28, 42, 61, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 247, 249, 0.96)),
    radial-gradient(circle at top left, rgba(20, 108, 95, 0.12), transparent 28rem);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(14px);
  transition: padding 180ms ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.menu-lines {
  width: 18px;
  display: grid;
  gap: 4px;
}

.menu-lines span {
  height: 2px;
  border-radius: 999px;
  background: var(--accent-strong);
}

.sidebar-title {
  display: grid;
  gap: 2px;
  min-width: 0;
  transition: opacity 150ms ease, width 150ms ease;
}

.brand-title {
  display: block;
  font-weight: 800;
  font-size: 1rem;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.nav-item span:not(.nav-icon) {
  transition: opacity 150ms ease, width 150ms ease;
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: #b8ded6;
  color: var(--accent-strong);
  font-weight: 750;
}

.nav-icon {
  width: 22px;
  text-align: center;
  font-weight: 800;
}

body.nav-collapsed .shell {
  grid-template-columns: 82px minmax(0, 1fr);
}

body.nav-collapsed .sidebar {
  padding-inline: 16px;
}

body.nav-collapsed .sidebar-title,
body.nav-collapsed .nav-item span:not(.nav-icon) {
  width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
}

body.nav-collapsed .nav-item {
  justify-content: center;
  gap: 0;
  padding-inline: 10px;
}

body.nav-collapsed .nav-icon {
  width: auto;
}

.main {
  padding: 34px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lead {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  font-size: 1rem;
  line-height: 1.55;
}

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

.status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(28, 42, 61, 0.08);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.status-value {
  font-weight: 800;
  font-size: 1.15rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 560px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

label,
.group-label {
  font-weight: 750;
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

textarea,
input[type="text"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 108, 95, 0.14);
  background: #fff;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-soft);
}

.segmented label {
  position: relative;
  padding: 10px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.template-grid,
.controller-grid {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 12px;
}

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

.controller-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.controller-card.full {
  grid-column: 1 / -1;
}

.controller-card-title {
  font-weight: 800;
  font-size: 0.9rem;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  width: fit-content;
  font-weight: 750;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.actions,
.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 750;
}

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

.button.danger {
  border-color: #f3b5af;
  color: var(--danger);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 340px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td input {
  min-width: 0;
  width: 100%;
}

th:last-child,
td:last-child {
  width: 82px;
  text-align: center;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  line-height: 1.45;
}

tr:last-child td {
  border-bottom: 0;
}

.row-button {
  width: 36px;
  height: 36px;
  border: 1px solid #f3b5af;
  background: #fff;
  color: var(--danger);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
}

.preview-wrap {
  display: grid;
  min-height: 680px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #2d374a;
  background: #171f2c;
  color: #d8dee9;
  border-radius: var(--radius) var(--radius) 0 0;
}

.preview-title {
  font-weight: 800;
  font-size: 0.9rem;
}

.action-button {
  min-width: 96px;
  height: 38px;
  border: 1px solid transparent;
  color: #fff;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.action-button.copy {
  background: var(--blue);
  border-color: #1d4ed8;
}

.action-button.download {
  background: var(--green);
  border-color: #116530;
}

.action-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

pre {
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: var(--code);
  color: #dbeafe;
  min-height: 620px;
  border-radius: 0 0 var(--radius) var(--radius);
  line-height: 1.55;
  font-size: 0.88rem;
  white-space: pre;
  word-break: normal;
}

.empty {
  color: #91a0b8;
}

.notice {
  display: none;
  border: 1px solid #f0cf8a;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-size: 0.86rem;
  line-height: 1.4;
}

.notice.visible {
  display: block;
}

.home-layout {
  display: grid;
  gap: 22px;
  max-width: 1180px;
}

.intro-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 16px;
}

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

.intro-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 16px;
  display: grid;
  gap: 6px;
}

.intro-item strong {
  font-size: 0.95rem;
}

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

.tool-card {
  color: inherit;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 36px rgba(28, 42, 61, 0.09);
  padding: 18px;
  display: grid;
  gap: 12px;
  min-height: 190px;
}

.tool-card.available {
  border-color: #b8ded6;
}

.tool-card.paused {
  background: #f8fafc;
  box-shadow: none;
}

.tool-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.tool-title {
  margin: 0;
  font-size: 1.08rem;
}

.tool-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.available {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.paused {
  background: #e8edf3;
  color: var(--muted);
}

.tool-action {
  color: var(--accent-strong);
  font-weight: 850;
  align-self: end;
}

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

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.nav-collapsed .shell {
    grid-template-columns: 1fr;
  }

  body.nav-collapsed .nav {
    display: none;
  }

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

@media (max-width: 680px) {
  .main {
    padding: 22px 16px;
  }

  .topbar,
  .status-grid {
    display: grid;
  }

  .nav,
  .segmented,
  .template-grid,
  .controller-grid,
  .intro-grid,
  .tool-grid {
    grid-template-columns: 1fr;
  }
}
