:root {
  --bg: #03101d;
  --bg-deep: #020c16;
  --panel: rgba(11, 23, 39, 0.88);
  --panel-2: rgba(17, 31, 53, 0.92);
  --panel-3: rgba(8, 18, 31, 0.96);
  --line: rgba(110, 170, 255, 0.15);
  --line-strong: rgba(118, 182, 255, 0.22);
  --text: #ebf4ff;
  --muted: #8ea6c4;
  --muted-2: #6d81a0;
  --blue: #4ba3ff;
  --blue-2: #7ec0ff;
  --teal: #67d9ff;
  --gold: #d4a43f;
  --gold-soft: rgba(212, 164, 63, 0.16);
  --green-soft: rgba(102, 220, 185, 0.16);
  --chip: rgba(18, 34, 57, 0.95);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(24, 79, 164, 0.22), transparent 34%),
    radial-gradient(circle at top right, rgba(14, 118, 153, 0.16), transparent 28%),
    linear-gradient(180deg, #03101d 0%, #020a13 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: 100%;
  min-height: 100vh;
}

.pm-topbar {
  width: min(1520px, calc(100% - 28px));
  margin: 14px auto 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(6, 16, 28, 0.96), rgba(4, 13, 24, 0.92));
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 320px 1fr auto;
  gap: 18px;
  align-items: center;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(15, 33, 58, 0.9);
  color: #d8ecff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand-subtitle {
  max-width: 260px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.pm-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.pm-nav a {
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.pm-nav a:hover {
  color: var(--text);
  background: rgba(28, 48, 78, 0.62);
  border-color: var(--line);
}

.pm-nav a.active {
  color: var(--text);
  background: rgba(28, 48, 78, 0.85);
  border-color: rgba(137, 195, 255, 0.26);
  box-shadow: inset 0 0 0 1px rgba(126, 192, 255, 0.08);
}

.topbar-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-pill {
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(12, 27, 46, 0.86);
  border: 1px solid var(--line);
  color: #bfd8f4;
  font-size: 11px;
  letter-spacing: 0.01em;
}

.lorecore-shell {
  width: min(1520px, calc(100% - 28px));
  margin: 12px auto 26px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(16, 28, 46, 0.9), rgba(7, 16, 29, 0.94));
  box-shadow: var(--shadow);
}

.surface-intro {
  padding: 14px 18px 16px;
  margin-bottom: 12px;
}

.surface-label,
.chat-kicker,
.studio-kicker,
.rail-kicker,
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 9px;
  color: #79a0cc;
  margin-bottom: 6px;
}

.surface-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}

.surface-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  max-width: 980px;
}

.chat-selection-bar {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 12px;
  margin-bottom: 12px;
  align-items: end;
}

.selection-group {
  min-width: 0;
}

.selection-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7f98b8;
  margin-bottom: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(8, 17, 30, 0.92);
  border: 1px solid var(--line);
}

.segmented-btn {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #99b1cc;
  font-size: 12px;
  font-weight: 600;
  transition: 0.18s ease;
}

.segmented-btn:hover {
  background: rgba(22, 39, 63, 0.9);
  color: var(--text);
}

.segmented-btn.is-active {
  background: linear-gradient(180deg, rgba(39, 74, 118, 0.98), rgba(22, 47, 80, 0.98));
  color: #f3f9ff;
  box-shadow: inset 0 0 0 1px rgba(138, 196, 255, 0.16);
}

.select-like,
.field-input,
.composer-input,
.studio-editor,
.field-textarea {
  width: 100%;
  border: 1px solid rgba(118, 182, 255, 0.16);
  background: linear-gradient(180deg, rgba(15, 25, 41, 0.96), rgba(12, 20, 35, 0.96));
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.select-like {
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.field-input:focus,
.composer-input:focus,
.studio-editor:focus,
.field-textarea:focus,
.select-like:focus {
  border-color: rgba(126, 192, 255, 0.34);
  box-shadow: 0 0 0 4px rgba(75, 163, 255, 0.08);
}

.selection-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: end;
}

.ghost-btn,
.primary-btn,
.primary-outline-btn,
.small-btn,
.small-accent-btn,
.tiny-ghost,
.mini-chip,
.accent-chip {
  border-radius: 12px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: rgba(14, 28, 47, 0.92);
  color: var(--text);
  padding: 0 14px;
  transition: 0.18s ease;
}

.ghost-btn:hover,
.primary-outline-btn:hover,
.small-btn:hover,
.tiny-ghost:hover,
.mini-chip:hover,
.select-like:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 192, 255, 0.3);
  background: rgba(20, 36, 60, 0.96);
}

.primary-btn {
  background: linear-gradient(180deg, rgba(21, 72, 118, 0.98), rgba(16, 53, 89, 0.98));
  border-color: rgba(126, 192, 255, 0.24);
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.primary-outline-btn {
  background: rgba(12, 25, 43, 0.96);
  color: #d7ecff;
}

.small-btn,
.small-accent-btn,
.tiny-ghost,
.mini-chip,
.accent-chip {
  min-height: 32px;
  font-size: 11px;
  padding: 0 10px;
  border-radius: 10px;
}

.small-accent-btn,
.accent-chip {
  border-color: rgba(212, 164, 63, 0.34);
  background: var(--gold-soft);
  color: #f0cf83;
}

.accent-chip {
  border-radius: 999px;
}

.mini-chip {
  border-radius: 999px;
}

.main-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.left-rail,
.right-rail {
  min-width: 0;
}

.left-rail {
  padding: 16px;
}

.rail-topline,
.section-row,
.rail-mini-row,
.rail-card-top,
.setup-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.left-rail h2,
.right-rail h2,
.chat-header h1,
.studio-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.rail-section {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #89a3c3;
  font-size: 11px;
}

.dense-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dense-list.compact .dense-item {
  min-height: 56px;
}

.dense-item {
  width: 100%;
  text-align: left;
  padding: 12px;
  min-height: 64px;
  border-radius: 14px;
  border: 1px solid rgba(118, 182, 255, 0.11);
  background: linear-gradient(180deg, rgba(14, 24, 41, 0.95), rgba(9, 18, 31, 0.95));
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: 0.18s ease;
}

.dense-item:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 192, 255, 0.24);
  background: linear-gradient(180deg, rgba(17, 30, 49, 0.96), rgba(10, 20, 35, 0.96));
}

.dense-item.is-selected {
  border-color: rgba(126, 192, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(126, 192, 255, 0.06);
}

.dense-title {
  font-size: 13px;
  font-weight: 700;
}

.dense-meta {
  font-size: 11px;
  color: var(--muted);
}

.section-title-small {
  font-size: 13px;
  color: #dbeafe;
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.split-stack {
  display: grid;
  gap: 14px;
}

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

.mini-note {
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(13, 26, 44, 0.92);
  color: #bdd6f3;
  padding: 0 10px;
}

.center-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.chat-panel {
  padding: 16px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 14px;
}

.chat-header p,
.studio-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  max-width: 660px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-thread {
  min-height: 430px;
  max-height: 620px;
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(118, 182, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(2, 10, 19, 0.98), rgba(4, 13, 24, 0.98));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 88%;
  padding: 12px 13px;
  border-radius: 16px;
  border: 1px solid rgba(118, 182, 255, 0.1);
  background: rgba(11, 22, 37, 0.96);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(22, 50, 84, 0.94), rgba(14, 34, 58, 0.96));
  border-color: rgba(126, 192, 255, 0.18);
}

.chat-bubble.assistant {
  align-self: flex-start;
}

.chat-bubble.assistant.alt {
  border-style: dashed;
  background: rgba(17, 25, 39, 0.96);
}

.chat-bubble.system {
  align-self: stretch;
  max-width: 100%;
  background: rgba(12, 23, 39, 0.98);
  border-color: rgba(126, 192, 255, 0.14);
}

.bubble-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
  font-size: 11px;
}

.bubble-role {
  color: #d6ebff;
  font-weight: 700;
}

.bubble-time {
  color: var(--muted-2);
}

.bubble-body {
  color: #e8f2ff;
  font-size: 13px;
  line-height: 1.62;
}

.chat-footer {
  padding-top: 14px;
  display: grid;
  gap: 12px;
}

.footer-row {
  display: flex;
  gap: 12px;
}

.field-pair {
  min-width: 0;
}

.field-pair.grow {
  flex: 1 1 auto;
}

.field-pair.fixed {
  width: 240px;
}

.chat-guidance {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid rgba(126, 192, 255, 0.14);
  background: linear-gradient(180deg, rgba(10, 22, 37, 0.95), rgba(9, 18, 31, 0.95));
  font-size: 12px;
  color: var(--muted);
}

.chat-guidance strong {
  color: var(--text);
  font-size: 12px;
}

.composer-wrap {
  display: grid;
  gap: 8px;
}

.composer-input {
  min-height: 112px;
  resize: vertical;
  padding: 14px;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.composer-hint {
  color: var(--muted-2);
  font-size: 11px;
}

.composer-buttons {
  display: flex;
  gap: 8px;
}

.studio-panel {
  padding: 16px;
}

.studio-header {
  margin-bottom: 14px;
}

.studio-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.studio-meta-grid .wide {
  grid-column: 1 / -1;
}

.field-textarea {
  min-height: 100px;
  resize: vertical;
}

.studio-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.studio-tab {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 28, 47, 0.92);
  color: #c0d8f4;
}

.studio-tab.is-active {
  background: linear-gradient(180deg, rgba(26, 66, 108, 0.96), rgba(15, 43, 73, 0.98));
  color: #f1f8ff;
  border-color: rgba(126, 192, 255, 0.24);
}

.studio-panes {
  border-radius: 16px;
}

.studio-pane {
  display: none;
}

.studio-pane.is-active {
  display: block;
}

.studio-editor {
  min-height: 320px;
  resize: vertical;
  padding: 14px;
}

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

.rail-card {
  padding: 14px;
}

.setup-card {
  margin-top: 12px;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid rgba(126, 192, 255, 0.11);
  background: linear-gradient(180deg, rgba(16, 28, 46, 0.9), rgba(10, 20, 34, 0.94));
}

.setup-title {
  font-size: 15px;
  font-weight: 700;
}

.metric-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-box {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(126, 192, 255, 0.1);
  background: rgba(9, 18, 31, 0.9);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.metric-label {
  font-size: 11px;
  color: var(--muted);
}

.metric-value {
  font-size: 11px;
  font-weight: 700;
  color: #dff0ff;
}

.setup-copy {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.mode-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.mode-card {
  width: 100%;
  border: 1px solid rgba(126, 192, 255, 0.11);
  background: linear-gradient(180deg, rgba(13, 25, 42, 0.96), rgba(9, 17, 30, 0.96));
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
}

.mode-card.is-selected {
  border-color: rgba(126, 192, 255, 0.26);
  box-shadow: inset 0 0 0 1px rgba(126, 192, 255, 0.05);
}

.mode-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: #7ea4d2;
  box-shadow: 0 0 0 4px rgba(126, 164, 210, 0.08);
}

.mode-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mode-copy strong {
  font-size: 13px;
}

.mode-copy span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.subrail-section {
  margin-top: 12px;
}

.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag-chip {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(126, 192, 255, 0.14);
  background: rgba(11, 24, 42, 0.95);
  color: #c4ddf7;
  font-size: 11px;
}

.stack-gap {
  display: grid;
  gap: 12px;
}

.output-actions {
  display: grid;
  gap: 8px;
}

.tiny-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--green-soft);
  border: 1px solid rgba(102, 220, 185, 0.18);
  color: #9be8cf;
  font-size: 11px;
  font-weight: 700;
  text-transform: lowercase;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-item {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(126, 192, 255, 0.1);
  background: rgba(9, 18, 31, 0.9);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

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

.status-item strong {
  color: #eaf5ff;
  font-size: 12px;
}

.recent-output-list {
  display: grid;
  gap: 8px;
}

.recent-output {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(126, 192, 255, 0.1);
  background: rgba(9, 18, 31, 0.9);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-output-title {
  font-size: 12px;
  font-weight: 700;
}

.recent-output-meta {
  font-size: 11px;
  color: var(--muted);
}

.activity-box {
  min-height: 98px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(126, 192, 255, 0.1);
  background: rgba(7, 15, 27, 0.96);
  display: grid;
  gap: 6px;
  align-content: start;
}

.activity-line {
  font-size: 11px;
  color: #b8d1ee;
  line-height: 1.5;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-thumb {
  background: rgba(88, 120, 170, 0.34);
  border-radius: 999px;
  border: 2px solid rgba(4, 13, 24, 0.92);
}

::-webkit-scrollbar-track {
  background: rgba(5, 12, 22, 0.5);
}

@media (max-width: 1380px) {
  .pm-topbar {
    grid-template-columns: 1fr;
  }

  .pm-nav,
  .topbar-pills {
    justify-content: flex-start;
  }

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

  .selection-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .main-grid {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .right-rail {
    grid-template-columns: 1fr;
  }

  .footer-row,
  .studio-meta-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .field-pair.fixed {
    width: 100%;
  }

  .chat-header {
    flex-direction: column;
  }

  .chat-header-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .brand-title {
    font-size: 25px;
  }

  .chat-selection-bar {
    grid-template-columns: 1fr;
  }

  .selection-actions {
    flex-wrap: wrap;
  }

  .composer-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .pm-topbar,
  .lorecore-shell {
    width: min(100% - 16px, 1520px);
  }
}
