:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #f2f5f9;
  --text: #182235;
  --muted: #68758a;
  --line: #dbe2ec;
  --blue: #175ddc;
  --blue-soft: #eaf1ff;
  --green: #188a55;
  --green-soft: #e8f6ef;
  --amber: #9d6a00;
  --amber-soft: #fff3d7;
  --red: #b33939;
  --red-soft: #fdeaea;
  --shadow: 0 12px 28px rgba(24, 34, 53, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

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

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle,
.status-note {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 650;
}

.nav-link.active,
.nav-link:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-panel {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.status-label {
  font-weight: 700;
}

.main {
  padding: 28px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.workflow-step {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.workflow-step.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #9ebcff;
}

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

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.muted {
  color: var(--blue);
  background: var(--blue-soft);
}

.form-panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

.mode-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mode-group legend {
  font-weight: 800;
  padding: 0 6px;
}

.mode-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--surface-strong);
  border-radius: 8px;
}

.mode-group input {
  width: auto;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.tiny-button {
  border-radius: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  font-weight: 800;
  padding: 10px 14px;
}

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

.secondary-button {
  background: #fff;
  color: var(--blue);
  border-color: #9ebcff;
}

.ghost-button {
  color: var(--muted);
  background: var(--surface-strong);
  border-color: var(--line);
}

.tiny-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--surface-strong);
  border-color: var(--line);
}

.tiny-button.accepted {
  color: var(--green);
  background: var(--green-soft);
  border-color: #9cd9ba;
}

.tiny-button.held {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f2cf7c;
}

.tiny-button.rejected {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f0b2b2;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.note-panel ul {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.question-list {
  display: grid;
  gap: 12px;
}

.project-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.project-row-title {
  font-weight: 800;
}

.project-row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.share-output {
  flex: 1 1 320px;
  min-width: 240px;
}

.question-card,
.candidate-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.candidate-card.is-accepted {
  border-color: #9cd9ba;
  box-shadow: inset 4px 0 0 var(--green);
}

.question-title,
.candidate-title {
  font-weight: 850;
  margin-bottom: 6px;
}

.question-reason,
.candidate-meta,
.candidate-source,
.candidate-body {
  color: var(--muted);
  line-height: 1.55;
}

.candidate-source {
  font-size: 12px;
  margin-top: 2px;
}

.question-actions,
.candidate-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.candidate-facts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.candidate-facts div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.candidate-facts strong {
  min-width: 74px;
  font-size: 12px;
}

.candidate-facts span {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-size: 12px;
}

.change-history-list {
  display: grid;
  gap: 10px;
}

.history-entry {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-entry time {
  color: var(--blue);
  font-weight: 850;
  font-size: 13px;
}

.history-entry p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.interpretation-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.interpretation-box p {
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.6;
}

.studio-layout {
  display: grid;
  grid-template-columns: 240px minmax(340px, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.modeling-summary-panel,
.change-history-panel {
  grid-column: 1 / -1;
}

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

.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  padding: 14px;
  min-height: 132px;
}

.insight-label {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.insight-card strong {
  display: block;
  font-size: 20px;
}

.insight-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.conversation-log {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.log-entry {
  border-left: 3px solid var(--blue);
  background: var(--surface-strong);
  padding: 10px;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}

.graph-canvas {
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  overflow: hidden;
}

#relationGraph {
  width: 100%;
  height: 380px;
  display: block;
}

.candidate-list {
  display: grid;
  gap: 12px;
}

.candidate-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.priority {
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.packet-panel textarea {
  min-height: 340px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  overflow: auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.api-key-guide {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #9ebcff;
  border-radius: 8px;
  background: var(--blue-soft);
}

.api-key-guide p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.guide-link {
  justify-self: start;
  text-decoration: none;
}

.guide-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
  line-height: 1.7;
}

.guide-steps li + li {
  margin-top: 4px;
}

.turnstile-box {
  margin: 14px 0;
  min-height: 72px;
}

.turnstile-widget {
  display: inline-flex;
  align-items: center;
  min-height: 68px;
  min-width: min(100%, 300px);
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px dashed #c7d2e3;
  border-radius: 8px;
  padding: 12px;
}

.security-note {
  color: var(--muted);
  line-height: 1.7;
  margin: 14px 0 0;
}

.runtime-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.runtime-status.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: #9cd9ba;
}

.runtime-status.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f2cf7c;
}

.empty-state {
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px dashed #c7d2e3;
  border-radius: 8px;
  padding: 18px;
}

.studio-commandbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.studio-commandbar strong {
  margin-right: 10px;
  font-size: 18px;
}

.commandbar-meta {
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.commandbar-actions,
.graph-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-composer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
}

.graph-canvas {
  position: relative;
}

.graph-toolbox,
.graph-zoom,
.mini-map {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 22px rgba(24, 34, 53, 0.08);
}

.graph-toolbox {
  top: 14px;
  left: 14px;
  display: grid;
  gap: 4px;
  padding: 6px;
}

.graph-toolbox span,
.graph-zoom span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--blue);
  font-weight: 850;
}

.graph-toolbox span:first-child,
.graph-toolbox span:hover,
.graph-zoom span:hover {
  background: var(--blue-soft);
}

.graph-zoom {
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 4px;
  padding: 6px;
}

.mini-map {
  right: 18px;
  bottom: 18px;
  width: 120px;
  height: 86px;
  background: #f8fbff;
}

.mini-map span {
  position: absolute;
  display: block;
  width: 28px;
  height: 18px;
  border: 1px solid #9ebcff;
  border-radius: 4px;
  background: #fff;
}

.mini-map span:nth-child(1) {
  top: 16px;
  left: 46px;
}

.mini-map span:nth-child(2) {
  top: 48px;
  left: 28px;
}

.mini-map span:nth-child(3) {
  top: 48px;
  right: 28px;
  border-color: #b8a4ff;
}

.candidate-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.candidate-toolbar span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 750;
}

.candidate-decision-row {
  display: grid;
  gap: 12px;
  border-radius: 14px;
}

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

.candidate-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 900;
}

.priority {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.priority-high {
  color: var(--red);
  border-color: #f4b5b5;
  background: var(--red-soft);
}

.priority-middle {
  color: var(--amber);
  border-color: #f2cf7c;
  background: var(--amber-soft);
}

.priority-low {
  color: var(--blue);
  border-color: #9ebcff;
  background: var(--blue-soft);
}

.candidate-review-points {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.candidate-review-points span::before {
  content: "✓";
  margin-right: 6px;
  color: var(--green);
  font-weight: 900;
}

.candidate-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.status-accepted {
  color: var(--green);
  background: var(--green-soft);
  border-color: #9cd9ba;
}

.status-held {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f2cf7c;
}

.status-rejected {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f4b5b5;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

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

  .section-grid,
  .studio-layout,
  .modeling-summary-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .main {
    padding: 18px;
  }

  .sidebar {
    padding: 14px;
    gap: 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .status-panel {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .workflow,
  .mode-group {
    grid-template-columns: 1fr;
  }

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

  .nav-link {
    padding: 9px;
    font-size: 13px;
  }
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin: -28px -28px 0;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.search-field {
  width: min(480px, 100%);
  position: relative;
}

.search-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 16px;
  background: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.connection-pill,
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.connection-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 82% 22%, rgba(23, 93, 220, 0.12), transparent 32%),
    linear-gradient(135deg, #fff 0%, #f8fbff 100%);
  box-shadow: var(--shadow);
}

.hero-panel h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.12;
  letter-spacing: -0.04em;
  color: #071a44;
}

.hero-panel p,
.section-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.hero-preview {
  position: relative;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.hero-preview::before,
.hero-preview::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 16%;
  width: 68%;
  border-top: 2px dashed #8fa8d7;
}

.hero-preview::after {
  transform: rotate(90deg);
}

.preview-node {
  position: absolute;
  min-width: 118px;
  text-align: center;
  border: 2px solid #9ebcff;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  color: #10244a;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(24, 34, 53, 0.08);
}

.preview-node.user {
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  border-color: #87d8a0;
  background: #f0fff5;
}

.preview-node.system {
  left: 36px;
  bottom: 42px;
}

.preview-node.output {
  right: 36px;
  bottom: 42px;
  border-color: #b8a4ff;
  background: #fbf9ff;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-summary article,
.hint-card,
.template-card,
.progress-card,
.provider-card,
.memo-outline,
.memo-export {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #fbfdff;
}

.dashboard-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  color: #071a44;
}

.project-list {
  border-radius: 12px;
  overflow: hidden;
}

.hint-card,
.template-card,
.progress-card {
  margin-top: 14px;
}

.template-card p,
.progress-card p {
  color: var(--muted);
}

.question-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.question-main-panel {
  min-height: 360px;
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-card,
.candidate-card {
  border-radius: 14px;
}

.question-side-panel {
  align-self: start;
  display: grid;
  gap: 14px;
}

.mini-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
}

.mini-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.studio-layout {
  grid-template-columns: 240px minmax(340px, 1fr) 300px;
  align-items: start;
}

.modeling-summary-panel {
  grid-column: 1 / -1;
}

.memo-workspace {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 220px;
  gap: 14px;
}

.memo-outline,
.memo-export {
  align-content: start;
  display: grid;
  gap: 10px;
}

.memo-outline a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 700;
}

.memo-outline a:first-of-type,
.memo-outline a:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.memo-export .tiny-button {
  justify-content: flex-start;
  width: 100%;
}

.memo-workspace textarea {
  min-height: 460px;
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.settings-panel > .section-heading {
  grid-column: 1 / -1;
}

.provider-card {
  grid-column: 1;
}

.api-key-guide {
  grid-column: 2;
  grid-row: 2 / span 4;
}

.settings-grid,
.turnstile-box,
.settings-panel > .button-row,
.security-note {
  grid-column: 1;
}

.storage-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.storage-options label {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

@media (max-width: 1100px) {
  .hero-panel,
  .question-screen,
  .studio-layout,
  .memo-workspace,
  .settings-panel {
    grid-template-columns: 1fr;
  }

  .api-key-guide,
  .provider-card,
  .settings-grid,
  .turnstile-box,
  .settings-panel > .button-row,
  .security-note {
    grid-column: auto;
    grid-row: auto;
  }

  .dashboard-summary,
  .storage-options {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .sidebar {
    padding: 16px 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-subtitle,
  .status-note {
    font-size: 11px;
  }

  .nav-link {
    padding: 9px 10px;
    font-size: 13px;
  }

  .status-panel {
    padding: 10px;
  }

  .main {
    min-width: 0;
    padding: 18px;
  }

  .app-topbar {
    margin: -18px -18px 0;
    padding: 14px 18px;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .studio-commandbar {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-panel,
  .section-grid,
  .question-screen,
  .studio-layout,
  .memo-workspace,
  .settings-panel,
  .dashboard-summary,
  .modeling-summary-grid,
  .candidate-toolbar {
    grid-template-columns: 1fr;
  }

  .hero-preview {
    min-height: 180px;
  }

  .commandbar-meta {
    display: block;
    margin: 8px 0 0;
  }

  .mini-map {
    display: none;
  }
}

@media (max-width: 520px) {
  .app-topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-summary,
  .storage-options {
    grid-template-columns: 1fr;
  }
}
