:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef4f0;
  --ink: #17201b;
  --muted: #66736c;
  --line: #dbe2dd;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --plum: #7c3aed;
  --rose: #be123c;
  --amber: #b45309;
  --shadow: 0 18px 50px rgba(27, 39, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: #111c18;
  color: #f8fbf9;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d7f2e7;
  color: #0b4f4a;
  font-weight: 800;
  font-size: 22px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.pane-header h2 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.source-box p {
  color: #bdd0c7;
  font-size: 13px;
  line-height: 1.5;
}

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

.nav-button,
.ghost-button,
.search-row button,
.small-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  background: #e8f4ef;
  color: var(--teal-dark);
  font-weight: 700;
}

.nav-button {
  justify-content: flex-start;
  text-align: left;
  color: #d8e6df;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-button.active,
.nav-button:hover {
  background: #d7f2e7;
  color: #0b4f4a;
}

.source-box {
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  padding-top: 18px;
}

.source-box h2 {
  margin: 0 0 6px;
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.15;
}

.ghost-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

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

.search-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fbfcfb;
  color: var(--ink);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 92px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric b {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  gap: 18px;
  min-height: 680px;
}

.result-pane,
.detail-pane,
.prompt-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-pane {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.pane-header {
  min-height: 56px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.pane-header h2 {
  font-size: 16px;
}

.pane-header span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.result-list {
  overflow: auto;
  padding: 8px;
}

.result-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.result-item:hover,
.result-item.active {
  background: var(--panel-2);
  border-color: #c8d8cf;
}

.result-item strong {
  font-size: 15px;
  line-height: 1.35;
}

.result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #e7ece9;
  color: #40534a;
  font-size: 12px;
  font-weight: 700;
}

.chip.topic {
  background: #d7f2e7;
  color: var(--teal-dark);
}

.chip.card {
  background: #ede9fe;
  color: #5b21b6;
}

.chip.review,
.chip.weak {
  background: #fff1e6;
  color: var(--amber);
}

.chip.danger {
  background: #ffe4e6;
  color: var(--rose);
}

.detail-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.detail-view {
  overflow: auto;
  padding: 20px;
}

.detail-title {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.detail-title h2 {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.2;
}

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

.info-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.info-section.full {
  grid-column: 1 / -1;
}

.info-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.info-section ul {
  margin: 0;
  padding-left: 18px;
}

.info-section li,
.body-text {
  color: #29352f;
  font-size: 14px;
  line-height: 1.65;
}

.body-text {
  white-space: pre-wrap;
}

.prompt-panel {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  box-shadow: none;
}

.prompt-panel textarea {
  width: calc(100% - 32px);
  margin: 16px 16px 10px;
  resize: vertical;
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.prompt-preview {
  max-height: 190px;
  overflow: auto;
  margin: 0 16px 16px;
  padding: 12px;
  background: #101915;
  color: #eef8f2;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111c18;
  color: #f8fbf9;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-button {
    text-align: center;
    justify-content: center;
    padding: 0 8px;
  }

  .dashboard {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

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

  .result-pane {
    min-height: 360px;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .search-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .top-actions,
  .search-row button {
    width: 100%;
  }

  .ghost-button,
  .search-row button {
    width: 100%;
  }

  .dashboard,
  .section-grid {
    grid-template-columns: 1fr;
  }

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