:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e1e8;
  --paper: #f7f9fb;
  --surface: #ffffff;
  --nav: #20313f;
  --nav-soft: #2c4354;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --amber: #c77916;
  --red: #b42318;
  --blue: #2563eb;
  --green-soft: #e8f5f1;
  --amber-soft: #fff3dc;
  --red-soft: #fde8e7;
  --shadow: 0 18px 42px rgba(25, 39, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, Pretendard, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body::before {
  content: "PC / CAD 작업 환경 권장";
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 20;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(980px, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  min-height: 100vh;
  padding: 24px 18px;
  background: var(--nav);
  color: #f5fbff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #d6f3eb;
  color: #0a554f;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #adc2ce;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e8ee;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #9fd8cf;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-soft);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  margin-top: 8px;
  color: #c7d6de;
  font-size: 13px;
  line-height: 1.55;
}

.main {
  min-width: 0;
  max-width: 1680px;
  padding: 26px 30px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.topbar-actions,
.form-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.small-button {
  min-width: 0;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.small-button {
  background: white;
  color: var(--ink);
}

.ghost-button:hover,
.small-button:hover {
  border-color: #aab8c4;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.hero-strip {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf0f4;
  overflow: hidden;
}

.topbar > *,
.hero-strip > *,
.workspace-grid > *,
.question-layout > * {
  min-width: 0;
}

.hero-copy strong,
.hero-copy span {
  display: block;
}

.hero-copy strong {
  font-size: 21px;
}

.hero-copy span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

#partCanvas {
  display: block;
  width: 100%;
  max-width: 560px;
  min-width: 0;
  height: auto;
  margin-left: auto;
  border-radius: 8px;
  background: #f8fafc;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.86fr) minmax(560px, 1.14fr);
  gap: 20px;
  align-items: start;
}

.result-surface {
  position: sticky;
  top: 24px;
}

.input-surface,
.result-surface,
.answer-surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-surface,
.result-surface {
  padding: 20px;
}

.section-heading {
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.wide-label {
  margin-top: 14px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.risk-summary {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(var(--red) 0 78%, #edf1f4 78% 100%);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: white;
}

.score-ring span,
.score-ring small {
  position: relative;
  z-index: 1;
}

.score-ring span {
  font-size: 30px;
  font-weight: 900;
}

.score-ring small {
  margin-top: 34px;
  margin-left: 4px;
  color: var(--muted);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 10px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.status-pill.low {
  background: var(--green-soft);
  color: var(--accent-strong);
}

.status-pill.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.high {
  background: var(--red-soft);
  color: var(--red);
}

.risk-summary p,
.analysis-card p,
.consult-box p,
.answer-surface p {
  color: var(--muted);
  line-height: 1.6;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-row div {
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.metric-row span,
.metric-row strong {
  display: block;
}

.metric-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-row strong {
  margin-top: 9px;
  font-size: 18px;
}

.analysis-list {
  display: grid;
  gap: 10px;
}

.analysis-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: white;
}

.analysis-card strong {
  display: block;
  margin-bottom: 6px;
}

.analysis-card p {
  margin-bottom: 0;
}

.consult-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: 8px;
  background: #f2f7f5;
}

.consult-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.consult-box p {
  margin-bottom: 0;
}

.result-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

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

.sample-card,
.history-item,
.question-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.sample-card {
  min-height: 210px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.sample-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.sample-card p {
  color: var(--muted);
  line-height: 1.55;
}

.sample-card button {
  margin-top: 10px;
}

.question-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(360px, 1.3fr);
  gap: 18px;
}

.question-bank {
  display: grid;
  gap: 10px;
}

.question-button {
  min-height: 52px;
  padding: 0 14px;
  text-align: left;
  font-weight: 800;
}

.question-button.active,
.question-button:hover {
  border-color: var(--accent);
  background: #eef8f5;
}

.answer-surface {
  min-height: 270px;
  padding: 22px;
}

.answer-surface strong {
  display: block;
  margin-bottom: 14px;
  font-size: 22px;
  line-height: 1.35;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.history-item strong {
  display: block;
  margin-bottom: 5px;
}

.history-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  border: 1px dashed #b8c3cc;
  border-radius: 8px;
  background: white;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(760px, 1fr);
  }

  .sidebar {
    min-height: 100vh;
    padding: 18px 14px;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .sidebar-note {
    display: block;
  }

  .workspace-grid {
    grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr);
  }

  .hero-strip {
    grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  }

  .question-layout {
    grid-template-columns: minmax(240px, 0.7fr) minmax(420px, 1.3fr);
  }

  #partCanvas {
    margin-left: auto;
  }
}

@media (max-width: 760px) {
  body::before {
    content: "PC 화면 권장";
  }

  .app-shell,
  .sidebar,
  .main {
    max-width: none;
  }

  .app-shell {
    grid-template-columns: 220px 980px;
  }

  .main {
    width: 100%;
    max-width: 100vw;
    padding: 18px;
  }

  h1 {
    max-width: 320px;
    font-size: 24px;
    line-height: 1.18;
  }

  .hero-strip {
    padding: 14px;
  }

  .hero-copy span {
    max-width: 300px;
  }

  #partCanvas {
    width: min(100%, 296px);
    margin-right: auto;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar-actions button,
  .form-actions button,
  .result-actions button {
    width: 100%;
  }

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

  .form-grid,
  .metric-row,
  .sample-grid,
  .risk-summary,
  .history-item {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 96px;
    height: 96px;
  }

  .sample-card {
    min-height: auto;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .hero-strip,
  .form-actions,
  .result-actions,
  .nav-list,
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace-grid {
    display: block;
  }

  .main {
    padding: 0;
  }

  .input-surface {
    display: none;
  }

  .result-surface {
    box-shadow: none;
    border: none;
  }
}
