:root {
  color-scheme: light;
  --ink: #16171a;
  --muted: #6f747c;
  --line: #dfe3e8;
  --panel: #ffffff;
  --soft: #f4f6f8;
  --canvas: #0f1115;
  --accent: #ff6b2c;
  --accent-2: #14c8a8;
  --accent-3: #2f6df6;
  --danger: #ef3b5d;
  --shadow: 0 18px 54px rgba(22, 23, 26, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #eef1f4;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(420px, 680px) minmax(300px, 360px);
  gap: 24px;
  min-height: 100vh;
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px;
}

.side-nav {
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  padding: 12px 10px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  text-decoration: none;
  padding: 12px 10px 28px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.side-nav nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: #e2e7ec;
}

.lab-shell {
  display: grid;
  gap: 16px;
}

.preset-strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 0 2px;
}

.preset {
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 104px;
  border: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 8px;
  white-space: nowrap;
}

.preset-token {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.preset-token span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: var(--canvas);
  color: #fff;
  font-weight: 800;
}

.preset.active {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(255, 107, 44, 0.16);
}

.workbench-card,
.builder-panel,
.mini-feed {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.post-header {
  display: grid;
  grid-template-columns: 42px 1fr 38px;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 12px;
}

.post-header h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.post-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 20px;
}

.canvas-frame {
  position: relative;
  background: var(--canvas);
  aspect-ratio: 1 / 1;
}

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

.run-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.lab-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.action-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 750;
}

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

.lab-readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 14px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.lab-readout div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 11px;
  background: var(--soft);
}

.lab-readout span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lab-readout strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-action input {
  display: none;
}

.caption-block {
  padding: 0 14px 16px;
}

.caption-block p {
  margin: 0;
  line-height: 1.45;
}

.decision-log {
  min-height: 28px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.mini-feed {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

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

.grid-feed img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: cover;
  background: var(--canvas);
}

.builder-panel {
  position: sticky;
  top: 22px;
  align-self: start;
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 16px;
}

.panel-section {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.panel-section h2 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  padding: 10px 11px;
  resize: vertical;
}

textarea {
  line-height: 1.4;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

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

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

.swatch {
  width: 34px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--color);
}

.swatch.active {
  border-color: var(--ink);
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 750;
}

.chip.active {
  border-color: var(--accent);
  background: #fff0e9;
}

.code-preview pre {
  overflow: auto;
  min-height: 96px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #111318;
  color: #d9f2e9;
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 86px minmax(360px, 1fr);
  }

  .side-nav {
    padding: 10px 4px;
  }

  .brand span:last-child,
  .nav-item span {
    display: none;
  }

  .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .nav-item {
    justify-content: center;
  }

  .builder-panel {
    position: static;
    grid-column: 2;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
    padding: 0;
  }

  .side-nav {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(238, 241, 244, 0.96);
  }

  .side-nav nav {
    display: flex;
  }

  .brand {
    padding: 0;
  }

  .brand span:last-child {
    display: inline;
    font-size: 18px;
  }

  .nav-item {
    width: 42px;
    padding: 8px;
  }

  .lab-shell {
    gap: 10px;
    padding: 10px;
  }

  .builder-panel {
    margin: 10px;
  }

  .lab-actions {
    grid-template-columns: 1fr;
  }

  .lab-readout {
    grid-template-columns: 1fr;
  }
}
