:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --soft: #f8fbff;
  --text: #172033;
  --muted: #66748a;
  --line: #dbe4ef;
  --line-strong: #c5d3e3;
  --accent: #1f73b7;
  --accent-strong: #125a93;
  --green: #138a61;
  --ok: #0f7b50;
  --warn: #a86300;
  --bad: #b42318;
  --shadow: 0 24px 60px rgba(30, 49, 77, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #edf5ff 0, rgba(237, 245, 255, 0) 340px),
    radial-gradient(circle at top right, rgba(31, 115, 183, .12), transparent 360px),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-copy {
  min-width: 0;
}

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

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.sub {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 620px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.safe-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #b7e0ce;
  border-radius: 999px;
  background: #edf9f3;
  color: var(--green);
  font-weight: 750;
  padding: 0 12px;
  white-space: nowrap;
}

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

.step-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(30, 49, 77, .07);
}

.step-number {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eaf4ff;
  color: var(--accent-strong);
  font-weight: 850;
}

.step-card strong {
  display: block;
  margin-bottom: 2px;
}

.step-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.session-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 0 14px;
  white-space: nowrap;
  background: var(--accent);
}

.session-link:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

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

.panel-title {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
}

.panel-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.panel-body { padding: 16px; }

label {
  display: block;
  font-weight: 650;
  margin-bottom: 8px;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  font: inherit;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 115, 183, .12);
}

textarea {
  min-height: 510px;
  resize: vertical;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

input {
  height: 40px;
  padding: 0 11px;
}

.filename-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

button,
.link-btn {
  height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

button:hover,
.link-btn:hover {
  border-color: var(--line-strong);
  color: var(--accent);
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.wide-action {
  min-width: 132px;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.summary { display: grid; gap: 10px; }

.kv {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f6;
}

.kv:last-child { border-bottom: 0; }
.k { color: var(--muted); }

.v {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
  font-size: 12px;
  background: #eef5fb;
  border: 1px solid #d4e5f5;
  color: var(--accent-strong);
}

.pill.ok { background: #e9f7ef; border-color: #c8ead7; color: var(--ok); }
.pill.warn { background: #fff6df; border-color: #f1d8a0; color: var(--warn); }
.pill.bad { background: #fff0ee; border-color: #f0c1bd; color: var(--bad); }

.preview {
  max-height: 220px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: #26354a;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.warning {
  border: 1px solid #f3d08a;
  background: #fff9eb;
  color: #673c00;
  border-radius: 6px;
  padding: 9px 10px;
}

.error {
  border: 1px solid #f4b3ad;
  background: #fff1f0;
  color: var(--bad);
  border-radius: 6px;
  padding: 10px;
  margin-top: 12px;
  white-space: pre-wrap;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.empty-cursor {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
}

.hidden { display: none !important; }

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding-top: 16px;
  }

  .hero,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .steps { grid-template-columns: 1fr; }
  .hero-actions { justify-content: flex-start; }

  .panel-actions {
    width: 100%;
    justify-content: stretch;
  }

  .panel-actions button { flex: 1; }
  .grid { grid-template-columns: 1fr; }
  .filename-row { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr; }
  textarea { min-height: 360px; }
  .session-link { white-space: normal; overflow-wrap: anywhere; }
}
