:root {
  --ink: #1a1c1e;
  --surface: #ffffff;
  --line: #cfd7df;
  --brand: #0f766e;
  --brand-deep: #134e4a;
  --bg: linear-gradient(145deg, #f5fbff 0%, #eefcf7 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

.site-header {
  height: 58px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1100px;
  height: 100%;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.brand span {
  color: var(--brand);
}

.crumbs {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.app-shell {
  max-width: 1100px;
  height: calc(100vh - 58px);
  margin: 0 auto;
  padding: 10px 14px 12px;
  display: grid;
  grid-template-rows: 42px 1fr;
  gap: 8px;
}

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

.step {
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f3f7fa;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.step.active {
  background: linear-gradient(120deg, var(--brand), var(--brand-deep));
  color: #ffffff;
  border-color: transparent;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  height: 100%;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
}

.sub {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

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

.intro-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fbfd;
}

.intro-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.intro-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px 10px;
}

.row {
  margin: 0;
}

.row-span-2 {
  grid-row: span 2;
}

label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

select,
input,
textarea,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
}

select,
input,
button {
  height: 40px;
  padding: 0 10px;
  background: #ffffff;
}

#profileSelect {
  height: 100%;
  min-height: 120px;
  padding: 6px;
}

textarea {
  padding: 9px 10px;
  line-height: 1.45;
  resize: none;
}

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

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

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

button {
  background: linear-gradient(120deg, var(--brand), var(--brand-deep));
  color: #ffffff;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #e7edf3;
  color: var(--ink);
}

.meta {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

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

.io-grid textarea {
  height: calc(100vh - 280px);
  min-height: 220px;
}

#connStatus.conn-info {
  color: var(--ink);
}

#connStatus.conn-ok {
  color: #166534;
}

#connStatus.conn-err {
  color: #b42318;
}

.llm-only.hidden,
.hidden {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .site-header {
    height: auto;
    padding: 8px 0;
  }

  .header-inner {
    display: block;
    height: auto;
    padding: 0 10px;
  }

  .brand {
    font-size: 22px;
  }

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

  .app-shell {
    height: auto;
    padding: 8px 10px 12px;
    grid-template-rows: auto auto;
  }

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

  .card {
    height: auto;
  }

  .intro-grid,
  .settings-grid,
  .io-grid,
  .actions.two,
  .actions.three {
    grid-template-columns: 1fr;
  }

  .row-span-2 {
    grid-row: auto;
  }

  #profileSelect {
    min-height: 150px;
  }

  .io-grid textarea {
    height: 220px;
  }
}
