:root {
  color-scheme: light;
  --bg: #f1f4f7;
  --panel: #ffffff;
  --ink: #152230;
  --muted: #4d6176;
  --line: #d7e0ea;
  --line-strong: #adbdcf;
  --primary: #0b7bd7;
  --primary-soft: #d5ecff;
  --accent: #00a08b;
  --danger-soft: #fff2eb;
  --danger-ink: #8b4020;
  --radius: 16px;
  --shadow: 0 16px 32px rgba(15, 28, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", "Tahoma", sans-serif;
  color: var(--ink);
  background: linear-gradient(175deg, #eef4fb 0%, #f7fafc 35%, #eff6f5 100%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(10, 40, 68, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 40, 68, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 20px auto 28px;
  position: relative;
  z-index: 1;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 24px 22px;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  backdrop-filter: blur(8px);
  position: relative;
}

.topbar-copy {
  padding-top: 10px;
}

.topbar-copy h1 {
  margin: 10px 0 8px;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
}

.topbar-copy p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e6fff9;
  color: #025146;
  border: 1px solid #95dbca;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ghost-btn,
.primary-btn,
.secondary-btn {
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  padding: 12px 14px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.gallery-link {
  position: absolute;
  top: 16px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1f6fd8;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

.gallery-link::before {
  content: "";
  width: 18px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 3px;
}

.ghost-btn {
  background: #ffffff;
  border-color: var(--line);
  color: #2e4c67;
}

.ghost-btn:hover {
  border-color: #a3b7cc;
  background: #f8fbfe;
}

.primary-btn {
  background: var(--primary);
  color: #ffffff;
}

.primary-btn:hover:not(:disabled) {
  background: #086cbf;
}

.secondary-btn {
  background: #ecf6ef;
  color: #1d5c3e;
  border-color: #b6d8c4;
}

.secondary-btn:hover {
  background: #e1f0e5;
}

.flow-rail {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.flow-step {
  background: #f8fbff;
  border: 1px solid #d9e6f4;
  color: #53718e;
  border-radius: 12px;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-weight: 600;
}

.flow-step span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8f1fb;
  color: #2f5d87;
  font-size: 0.85rem;
}

.flow-step.is-active {
  border-color: #9bc5eb;
  background: #eaf5ff;
  color: #1e4468;
}

.workspace {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.scenario-switcher {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scenario-chip {
  border-radius: 999px;
  border: 1px solid #cfe0f1;
  background: #f4f9ff;
  color: #305779;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.scenario-chip.is-active {
  border-color: #4d9ad7;
  background: #dff0ff;
  color: #00437c;
}

.input-label {
  display: block;
  margin-top: 15px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #2a465f;
}

textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fdfefe;
  color: #10202f;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  padding: 12px;
}

textarea:focus {
  outline: 2px solid #8ec5ef;
  border-color: #65a4d4;
}

textarea[readonly] {
  resize: none;
  background: #f7fbff;
  cursor: default;
}

.attachments-wrap {
  margin-top: 6px;
}

.attachments-list {
  margin: 0;
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
}

.attachments-list li {
  border-radius: 10px;
  border: 1px solid #d7e7f5;
  background: #f7fbff;
  color: #3d5f7f;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.panel-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-actions p {
  margin: 0;
  color: #405a72;
  font-size: 0.9rem;
}

.result-grid {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.result-block {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fcfeff;
  padding: 12px;
}

.result-block h3,
.routing-block h3,
.draft-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.fact-list,
.missing-list {
  margin: 0;
  list-style: none;
  padding: 0;
  display: grid;
  gap: 9px;
}

.fact-list li {
  border-radius: 10px;
  border: 1px solid #dbe8f7;
  background: #f6fbff;
  padding: 8px 10px;
}

.fact-list li p,
.missing-list li p {
  margin: 0;
  color: #3e5f7f;
  font-size: 0.82rem;
}

.fact-list li strong {
  display: block;
  margin-top: 4px;
}

.fact-list li span {
  display: inline-flex;
  margin-top: 6px;
  border-radius: 999px;
  font-size: 0.74rem;
  padding: 4px 8px;
  background: #e8f4ff;
  color: #225886;
}

.missing-list li {
  border-radius: 10px;
  border: 1px solid #f6cfbe;
  background: var(--danger-soft);
  padding: 8px 10px;
}

.missing-list li span {
  display: block;
  margin-top: 4px;
  font-size: 0.84rem;
  color: var(--danger-ink);
}

.placeholder {
  color: #5f7890;
  font-style: italic;
  background: #f4f8fc;
  border: 1px dashed #c7d8ea;
  border-radius: 10px;
  padding: 8px 10px;
}

.success-state {
  color: #176147;
  border: 1px solid #a6d4bf;
  background: #effaf4;
  border-radius: 10px;
  padding: 8px 10px;
}

.routing-block {
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid #d9e6f3;
  background: #f8fcff;
  padding: 12px;
}

.routing-card {
  border-radius: 10px;
  border: 1px solid #bfd6ea;
  background: #f0f8ff;
  padding: 10px 12px;
}

.routing-label {
  margin: 0 0 4px;
  color: #58738c;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.routing-queue {
  margin: 0 0 8px;
  font-weight: 800;
  color: #0f4d85;
}

.routing-card p {
  margin: 0;
}

.routing-card ul {
  margin: 8px 0;
  padding-left: 18px;
  color: #314c67;
}

.routing-card .risk {
  color: #1e5f41;
  font-weight: 700;
}

.draft-block {
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 12px;
}

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

.draft-head .ghost-btn {
  padding: 10px 12px;
}

#tourOverlay {
  position: fixed;
  inset: 0;
  z-index: 40;
}

#tourSpotlight {
  position: fixed;
  border-radius: 14px;
  border: 2px solid #7ec7ff;
  box-shadow: 0 0 0 9999px rgba(6, 14, 24, 0.76), 0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  transition: 0.2s ease;
}

.tour-popover {
  width: 320px;
  position: fixed;
  border-radius: 14px;
  border: 1px solid #9ec6e6;
  background: #f8fcff;
  color: #17334d;
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.23);
  padding: 14px;
}

.tour-step-label {
  margin: 0 0 8px;
  color: #0e4f85;
  font-size: 0.82rem;
  font-weight: 800;
}

.tour-popover p {
  margin: 0;
}

.tour-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.tour-controls button {
  flex: 1;
  justify-content: center;
}

.tour-controls button[hidden] {
  display: none;
}

.tour-controls .ghost-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

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

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

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .flow-rail {
    grid-template-columns: repeat(2, 1fr);
  }

  .tour-popover {
    width: min(320px, calc(100vw - 24px));
  }
}
