:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e3e8ef;
  --panel: #ffffff;
  --canvas: #f4f6fa;
  --accent: #5b5ce2;
  --accent-dark: #4647c6;
  --green: #17a673;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #111827; color: white; padding: 26px 18px 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; font-weight: 800; font-size: 20px; background: linear-gradient(140deg, #8586ff, #4f46e5); box-shadow: 0 8px 22px rgba(91, 92, 226, .38); }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; }
.brand span { margin-top: 2px; font-size: 12px; color: #aeb7c6; }
.surface-nav { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 12px; border: 0; border-radius: 12px; color: #aeb7c6; background: transparent; text-align: left; transition: .2s ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(111, 112, 245, .22); box-shadow: inset 0 0 0 1px rgba(132, 133, 255, .25); }
.nav-item strong, .nav-item small { display: block; }
.nav-item strong { font-size: 13px; }
.nav-item small { margin-top: 3px; font-size: 11px; color: inherit; opacity: .66; }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 12px; font-weight: 700; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 16px; }
.mini-status { display: flex; align-items: center; gap: 8px; color: #aeb7c6; font-size: 11px; margin: 8px 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #697386; }
.dot.ok { background: #38d39f; box-shadow: 0 0 0 4px rgba(56,211,159,.1); }
.dot.warning { background: #f6b94a; }

.workspace { min-width: 0; padding: 28px clamp(20px, 3vw, 44px) 52px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 21px; }
.topbar h1 { margin: 5px 0 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
.eyebrow, .section-kicker { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.header-badges { display: flex; gap: 8px; }
.badge { padding: 7px 10px; border-radius: 999px; color: #586174; background: white; border: 1px solid var(--line); font-size: 11px; font-weight: 700; }
.badge.accent { color: #4c4dca; background: #eeeeff; border-color: #d9d9ff; }

.diagnostics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); box-shadow: var(--shadow); margin-bottom: 20px; }
.diagnostics div { background: white; padding: 12px 15px; }
.diagnostics span, .diagnostics strong { display: block; }
.diagnostics span { color: var(--muted); font-size: 10px; }
.diagnostics strong { margin-top: 4px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content-grid { display: grid; grid-template-columns: minmax(360px, .72fr) minmax(520px, 1.28fr); gap: 20px; align-items: start; }
.surface-panel { display: none; }
.surface-panel.active { display: block; animation: enter .25s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.hero-card { min-height: 196px; display: grid; grid-template-columns: 1fr 180px; align-items: center; gap: 18px; padding: 30px 34px; border-radius: 18px; background: radial-gradient(circle at 90% 20%, rgba(128,130,255,.28), transparent 28%), linear-gradient(135deg, #171c2d, #222945); color: white; box-shadow: 0 18px 40px rgba(17,24,39,.16); margin-bottom: 20px; overflow: hidden; }
.hero-card h2 { margin: 9px 0 10px; max-width: 560px; font-size: clamp(24px, 3vw, 34px); line-height: 1.12; letter-spacing: -.035em; }
.hero-card p { max-width: 650px; margin: 0; color: #bac3d5; line-height: 1.7; font-size: 13px; }
.hero-orbit { position: relative; width: 154px; height: 154px; margin: auto; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; }
.hero-orbit::before { content: ""; position: absolute; inset: 24px; border-radius: 50%; border: 1px dashed rgba(255,255,255,.18); }
.hero-orbit b { position: absolute; inset: 51px; display: grid; place-items: center; border-radius: 50%; background: #7172ef; box-shadow: 0 0 35px rgba(113,114,239,.55); }
.hero-orbit span { position: absolute; padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.1); font-size: 9px; color: #d9dded; }
.hero-orbit span:nth-child(1) { top: 6px; left: 57px; }
.hero-orbit span:nth-child(2) { bottom: 22px; left: -4px; }
.hero-orbit span:nth-child(3) { bottom: 22px; right: -8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.form-card { padding: 22px; }
.card-heading, .result-header, .surface-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading { margin-bottom: 18px; }
.card-heading > div { display: flex; align-items: center; gap: 9px; }
.card h3, .surface-intro h2 { margin: 0; }
.card h3 { font-size: 15px; }
.surface-intro { margin: 4px 2px 17px; }
.surface-intro h2 { margin-top: 6px; font-size: 25px; letter-spacing: -.025em; }
.step { width: 25px; height: 25px; display: grid; place-items: center; color: var(--accent); background: #eeeeff; border-radius: 8px; font-size: 9px; font-weight: 800; }
.muted { color: var(--muted); font-size: 10px; }
.flow-chip, .status-tag { padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.flow-chip { color: #445069; background: #e9edf4; }
.status-tag { color: #236b55; background: #e8f8f2; }
.status-tag.neutral { color: #5c6677; background: #edf0f5; }
.status-tag.running { color: #745300; background: #fff4d8; }
.status-tag.error { color: #a13939; background: #ffebeb; }

label { display: block; color: #596477; font-size: 11px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #d8dee8; border-radius: 10px; background: #fbfcfe; color: var(--ink); outline: none; transition: .18s ease; }
input, select { height: 40px; padding: 0 11px; }
textarea { resize: vertical; min-height: 112px; padding: 12px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: #8d8ef0; box-shadow: 0 0 0 3px rgba(91,92,226,.1); background: white; }
label > input, label > select { margin-top: 7px; }
.form-card > label + textarea, .form-card > label + .inline-action { margin: 7px 0 17px; }
.form-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 14px; align-items: end; margin-top: 16px; }
.inline-action { display: flex; gap: 8px; }
.inline-action input:first-child { flex: 1; }
.small-input { width: 130px; }
.range-input { width: 150px; }

.primary-button, .secondary-button, .ghost-button { border-radius: 10px; min-height: 40px; padding: 0 14px; font-size: 11px; font-weight: 800; border: 1px solid transparent; white-space: nowrap; }
.primary-button { color: white; background: var(--accent); box-shadow: 0 7px 16px rgba(91,92,226,.2); }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { color: #384258; background: white; border-color: #d7dde7; }
.ghost-button { color: #656f82; background: #f2f4f8; }
.full { width: 100%; }
.sidebar .secondary-button { margin-top: 13px; border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: white; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; margin-top: 16px; max-height: 280px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { position: sticky; top: 0; z-index: 1; color: #697386; background: #f5f7fa; text-align: left; font-weight: 800; }
th, td { padding: 10px 12px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { text-align: center; color: #8992a2; padding: 28px; }
td input[type="checkbox"], th input[type="checkbox"] { width: 14px; height: 14px; }

.result-column { position: sticky; top: 20px; display: grid; gap: 15px; }
.result-card { padding: 20px; }
.result-header { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.result-header h3 { margin-top: 6px; }
.result-empty { min-height: 310px; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-graphic { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 17px; background: #f0f1ff; color: var(--accent); font-size: 28px; margin-bottom: 15px; }
.result-empty p { max-width: 230px; margin: 7px 0; line-height: 1.6; font-size: 11px; }
.widget-card { min-height: 690px; }
.widget-host { height: 590px; margin: 14px -10px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #f7f8fb; }
.widget-host iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
.widget-prerequisite { margin-top: 16px; padding: 18px; border: 1px solid #eadcae; border-radius: 12px; background: #fffaf0; }
.widget-prerequisite strong { display: block; font-size: 13px; }
.widget-prerequisite p { margin: 8px 0 12px; color: #6f6551; font-size: 11px; line-height: 1.65; }
.widget-prerequisite a { color: var(--accent); font-size: 11px; font-weight: 800; text-decoration: none; }
.missing-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.missing-list span { padding: 5px 8px; border-radius: 999px; color: #8a5d16; background: #fff0c4; font: 9px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.widget-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding-top: 14px; color: var(--muted); font-size: 10px; }
.widget-footer .ghost-button { min-height: 34px; }
.result-content { padding-top: 16px; }
.hidden { display: none !important; }
.answer-block, .summary-block { margin-bottom: 16px; }
.answer-block span, .summary-block span, .result-label { display: block; color: var(--accent); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.answer-block p, .summary-block p { margin: 7px 0 0; color: #303a4e; line-height: 1.65; font-size: 12px; }
.patent-list { display: grid; gap: 7px; margin: 9px 0 15px; }
.patent-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 9px 10px; background: #f6f7fa; border-radius: 9px; }
.patent-item strong, .patent-item span { display: block; }
.patent-item strong { font-size: 10px; }
.patent-item span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.relevance { color: var(--green); font-size: 10px; font-weight: 800; }
.result-meta { display: flex; justify-content: space-between; gap: 8px; color: #8a93a3; font-size: 9px; margin: 13px 0; }
.bridge-card { padding: 17px; }
.bridge-card pre { max-height: 200px; overflow: auto; margin: 10px 0 0; padding: 12px; border-radius: 10px; background: #161d2d; color: #b8c7e8; font: 10px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(18px); opacity: 0; pointer-events: none; padding: 11px 15px; color: white; background: #20283a; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); font-size: 11px; transition: .2s ease; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: #9d3939; }

.resource-picker { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.resource-picker-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .46); backdrop-filter: blur(3px); }
.resource-picker-dialog { position: relative; width: min(760px, 96vw); max-height: min(720px, 88vh); display: grid; grid-template-rows: auto auto auto minmax(180px, 1fr); overflow: hidden; border: 1px solid rgba(255,255,255,.4); border-radius: 18px; background: white; box-shadow: 0 26px 70px rgba(15,23,42,.28); }
.resource-picker-dialog > header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.resource-picker-dialog h2 { margin: 5px 0 0; font-size: 21px; }
.picker-close { width: 34px; height: 34px; border: 0; border-radius: 10px; background: #f1f3f7; color: #596477; font-size: 22px; }
.picker-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.picker-toolbar span { color: var(--muted); font-size: 11px; }
.picker-status { padding: 11px 22px; color: #667085; background: #f7f8fb; font-size: 11px; }
.resource-list { min-height: 230px; overflow: auto; padding: 10px 12px 18px; }
.resource-item { width: 100%; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 11px; padding: 11px 12px; border: 0; border-bottom: 1px solid #eef1f5; background: white; color: var(--ink); text-align: left; }
.resource-item:hover { background: #f7f7ff; }
.resource-item-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: #eeeeff; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.resource-item strong, .resource-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-item strong { font-size: 12px; }
.resource-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.resource-item-action { color: var(--accent); font-size: 11px; font-weight: 800; }
.resource-list-empty { padding: 50px 20px; color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 1080px) {
  .content-grid { grid-template-columns: 1fr; }
  .result-column { position: static; grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 13px; }
  .surface-nav { grid-template-columns: repeat(4, 1fr); }
  .nav-item { justify-content: center; padding: 9px 5px; }
  .nav-item > span:last-child, .sidebar-footer { display: none; }
  .workspace { padding: 20px 14px 36px; }
  .diagnostics { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .result-column { display: block; }
  .result-column { margin-top: 16px; }
  .bridge-card { margin-top: 14px; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-orbit { display: none; }
  .inline-action, .form-row { display: grid; grid-template-columns: 1fr; }
  .small-input, .range-input { width: 100%; }
}
