:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #1565d8;
  --accent-dark: #0f4fa8;
  --danger: #c62828;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.brand {
  color: var(--text);
  font-weight: 800;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 32px;
  align-items: center;
  min-height: 520px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 1.04;
}

h2 {
  margin: 0 0 12px;
  font-size: 21px;
}

p {
  line-height: 1.7;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.actions.compact {
  margin-top: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

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

.button.small {
  min-height: 36px;
  padding: 0 12px;
}

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

.hero-panel,
.auth-box,
.form-section,
.table-wrap,
.empty,
.preview-data,
.not-found {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-panel {
  padding: 24px;
}

.chat-line {
  max-width: 88%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.5;
}

.chat-line.ai {
  background: #eef4ff;
}

.chat-line.user {
  margin-left: auto;
  background: #172033;
  color: #fff;
}

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

.feature-grid article {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-box {
  max-width: 440px;
  margin: 64px auto;
  padding: 28px;
}

.stack,
.hearing-form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 36px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.narrow {
  max-width: 760px;
}

.wide {
  max-width: 760px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 36px;
  text-align: center;
}

.form-section {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.hearing-form {
  max-width: 760px;
}

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

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

.check-row input {
  width: auto;
}

.preview-data {
  margin-top: 18px;
  padding: 24px;
}

pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: 8px;
  background: #101828;
  color: #f2f4f7;
}

.inline {
  display: inline;
}

.link-button {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.danger-text {
  color: var(--danger);
}

.section-title {
  margin-top: 32px;
}

.muted-text {
  color: var(--muted);
}

.builder-shell {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(460px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.builder-chat,
.builder-preview {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.builder-chat {
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
  overflow: hidden;
}

.builder-messages {
  height: 390px;
  overflow-y: auto;
  padding: 18px;
  background: #f8fafc;
}

.builder-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.builder-preview iframe {
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  background: #fff;
}

.save-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.save-panel p {
  grid-column: 1 / -1;
  margin: 0;
}

.error {
  padding: 12px 14px;
  border: 1px solid #ffc9c9;
  border-radius: 8px;
  background: #fff2f2;
  color: #a31313;
}

.not-found {
  margin-top: 80px;
  padding: 36px;
  text-align: center;
}

@media (max-width: 820px) {
  .app-header,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    flex-wrap: wrap;
  }

  .hero,
  .feature-grid,
  .settings-grid,
  .builder-shell,
  .save-panel {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding: 24px 0;
  }
}
