:root {
  --bg: #f6efe5;
  --bg-deep: #162231;
  --panel: rgba(255, 250, 244, 0.92);
  --panel-strong: #fffaf4;
  --line: rgba(22, 34, 49, 0.12);
  --ink: #162231;
  --muted: #5b6473;
  --accent: #ef6c44;
  --accent-soft: rgba(239, 108, 68, 0.12);
  --teal: #0f8b8d;
  --blue-soft: rgba(22, 34, 49, 0.08);
  --shadow: 0 24px 64px rgba(22, 34, 49, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(239, 108, 68, 0.22), transparent 24rem),
    radial-gradient(circle at 85% 20%, rgba(15, 139, 141, 0.18), transparent 28rem),
    linear-gradient(180deg, #f2e7d8 0%, #f9f3ea 100%);
}

button,
a {
  font: inherit;
}

.analysis-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.25rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.45rem 1.6rem;
  border-radius: 1.8rem;
  background: rgba(22, 34, 49, 0.95);
  color: #f7f0e5;
  box-shadow: 0 28px 72px rgba(22, 34, 49, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-copy {
  display: grid;
  gap: 0.45rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(247, 240, 229, 0.68);
}

.hero h1,
.section-header h2,
.panel-title,
.loading-panel h2,
.error-panel h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Georgia", serif;
  letter-spacing: -0.02em;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
}

.hero-text {
  margin: 0;
  max-width: 52rem;
  line-height: 1.65;
  color: rgba(247, 240, 229, 0.8);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
}

.hero-link,
.hero-button,
.download-link,
.artifact-link {
  appearance: none;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.82rem 1rem;
  transition: transform 140ms ease, opacity 140ms ease, background-color 140ms ease;
}

.hero-link {
  background: rgba(255, 255, 255, 0.08);
  color: #f7f0e5;
}

.hero-button {
  background: rgba(239, 108, 68, 0.18);
  color: #fff2e9;
}

.hero-link:hover,
.hero-button:hover,
.category-tab:hover,
.download-link:hover,
.artifact-link:hover,
.table-link:hover {
  transform: translateY(-1px);
}

.category-nav {
  position: sticky;
  top: 0.85rem;
  z-index: 20;
  display: flex;
  gap: 0.55rem;
  margin: 1rem 0 0;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 250, 244, 0.86);
  box-shadow: 0 18px 46px rgba(22, 34, 49, 0.12);
  backdrop-filter: blur(16px);
  overflow-x: auto;
}

.category-tab {
  appearance: none;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: transparent;
  color: var(--muted);
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease;
}

.category-tab.is-active {
  background: var(--bg-deep);
  color: #fff7ec;
}

.dashboard-main {
  margin-top: 1.25rem;
}

.loading-panel,
.error-panel,
.section-block {
  border-radius: 1.7rem;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.loading-panel,
.error-panel {
  padding: 2rem;
}

.section-block {
  margin-top: 1rem;
  padding: 1.3rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.section-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.metric-grid,
.card-grid,
.cluster-grid,
.network-grid,
.download-grid,
.profile-grid {
  display: grid;
  gap: 0.9rem;
}

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

.metric-card,
.insight-card,
.profile-card,
.cluster-card,
.network-card,
.download-card,
.table-card,
.glossary-card,
.chart-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1rem;
}

.metric-card {
  display: grid;
  gap: 0.32rem;
}

.metric-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.metric-help {
  font-size: 0.82rem;
  color: var(--muted);
}

.card-grid {
  grid-template-columns: 1.3fr 0.9fr;
  align-items: start;
}

.insight-list,
.glossary-list,
.chip-list,
.download-list,
.example-list {
  display: grid;
  gap: 0.65rem;
}

.insight-item,
.glossary-item,
.download-item,
.example-item {
  border-radius: 1rem;
  background: rgba(22, 34, 49, 0.04);
  border: 1px solid rgba(22, 34, 49, 0.08);
  padding: 0.85rem;
  line-height: 1.6;
}

.glossary-term {
  display: block;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.basics-layout,
.activity-layout,
.styles-layout,
.similarity-layout,
.projection-layout,
.clusters-layout,
.network-layout,
.downloads-layout {
  display: grid;
  gap: 1rem;
}

.basics-layout {
  grid-template-columns: 1.1fr 0.9fr;
}

.activity-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.chart-grid {
  display: grid;
  gap: 1rem;
}

.chart-grid.three-up {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide-card {
  grid-column: 1 / -1;
}

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

.profile-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.profile-name {
  margin: 0;
  font-size: 1.2rem;
}

.profile-meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.chip-list {
  grid-template-columns: repeat(auto-fit, minmax(5rem, max-content));
  margin-top: 0.8rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.84rem;
}

.example-list {
  margin-top: 0.9rem;
}

.example-item time {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid rgba(22, 34, 49, 0.08);
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: #fff8f0;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: rgba(22, 34, 49, 0.03);
}

.similarity-layout {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.similarity-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1rem;
}

.similarity-card h3,
.chart-card h3,
.cluster-card h3,
.network-card h3,
.table-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.small-note {
  margin: 0 0 0.8rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.88rem;
}

.heatmap {
  display: grid;
  gap: 0.35rem;
}

.heatmap-row {
  display: grid;
  grid-template-columns: 5.5rem repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: stretch;
}

.heatmap-row.header {
  color: var(--muted);
  font-size: 0.78rem;
}

.heatmap-label,
.heatmap-cell {
  border-radius: 0.85rem;
  padding: 0.55rem 0.65rem;
  background: rgba(22, 34, 49, 0.05);
}

.heatmap-cell {
  text-align: center;
  font-weight: 700;
}

.projection-layout {
  grid-template-columns: 1.2fr 0.8fr;
  align-items: start;
}

.projection-frame {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(244, 238, 228, 0.92));
  border: 1px solid var(--line);
}

.word-network-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 0.9rem;
  border-radius: 1rem;
  background:
    radial-gradient(circle at 20% 18%, rgba(239, 108, 68, 0.14), transparent 18rem),
    radial-gradient(circle at 80% 28%, rgba(15, 139, 141, 0.12), transparent 18rem),
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(244, 238, 228, 0.96));
  border: 1px solid var(--line);
}

.line-chart-frame {
  width: 100%;
  aspect-ratio: 16 / 6;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(244, 238, 228, 0.96));
  border: 1px solid var(--line);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.matrix-scroll {
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.matrix-heatmap {
  display: grid;
  gap: 0.3rem;
  min-width: max-content;
}

.matrix-axis-label,
.matrix-cell {
  border-radius: 0.8rem;
  min-height: 2.35rem;
  padding: 0.42rem 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.8rem;
}

.matrix-axis-label {
  background: rgba(22, 34, 49, 0.05);
  color: var(--muted);
  font-weight: 600;
}

.matrix-row-label {
  justify-content: flex-start;
  padding-left: 0.7rem;
}

.matrix-cell {
  font-weight: 700;
}

.matrix-cell-empty {
  background: rgba(22, 34, 49, 0.04);
  color: rgba(22, 34, 49, 0.4);
}

.bar-ranking {
  display: grid;
  gap: 0.75rem;
}

.bar-row {
  display: grid;
  gap: 0.35rem;
}

.bar-row-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.bar-track {
  height: 0.8rem;
  border-radius: 999px;
  background: rgba(22, 34, 49, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.bar-meta {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.projection-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
}

.legend-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
}

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

.cluster-meta,
.network-meta,
.download-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(22, 34, 49, 0.06);
  padding: 0.34rem 0.64rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.message-preview {
  margin: 0.4rem 0 0;
  padding: 0.68rem;
  border-radius: 0.9rem;
  background: rgba(22, 34, 49, 0.04);
  line-height: 1.55;
}

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

.network-card img {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid var(--line);
  margin-top: 0.8rem;
}

.artifact-actions,
.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.artifact-link,
.download-link {
  background: rgba(22, 34, 49, 0.08);
  color: var(--ink);
}

.downloads-layout {
  grid-template-columns: 1fr 1fr;
}

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

details {
  margin-top: 0.8rem;
  border-radius: 1rem;
  background: rgba(22, 34, 49, 0.04);
  border: 1px solid rgba(22, 34, 49, 0.08);
  overflow: hidden;
}

summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

details > *:not(summary) {
  margin: 0;
  padding: 0 1rem 1rem;
}

.table-link {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
}

.is-hidden {
  display: none;
}

@media (max-width: 1180px) {
  .metric-grid,
  .activity-layout,
  .chart-grid.three-up,
  .profile-grid,
  .similarity-layout,
  .cluster-grid,
  .downloads-layout,
  .card-grid,
  .basics-layout,
  .projection-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .analysis-shell {
    padding: 0.8rem;
  }

  .hero,
  .section-header {
    flex-direction: column;
    align-items: start;
  }

  .category-nav {
    border-radius: 1.1rem;
  }

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

  .heatmap-row {
    grid-template-columns: 4.2rem repeat(3, minmax(0, 1fr));
  }
}
