:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-strong: #fffdf8;
  --border: rgba(79, 73, 55, 0.16);
  --text: #2b2519;
  --muted: #6e6553;
  --accent: #145b73;
  --accent-soft: rgba(20, 91, 115, 0.12);
  --highlight: #bf5f2d;
  --highlight-soft: rgba(191, 95, 45, 0.14);
  --shadow: 0 24px 60px rgba(67, 45, 16, 0.12);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 198, 127, 0.34), transparent 28%),
    radial-gradient(circle at bottom right, rgba(20, 91, 115, 0.18), transparent 30%),
    linear-gradient(145deg, #f8f3ea 0%, #eee5d6 100%);
  color: var(--text);
  font-family: "Avenir Next", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.page-glow {
  position: fixed;
  inset: auto;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  filter: blur(28px);
  pointer-events: none;
  opacity: 0.42;
}

.glow-left {
  top: -5rem;
  left: -6rem;
  background: rgba(191, 95, 45, 0.35);
}

.glow-right {
  right: -7rem;
  bottom: -7rem;
  background: rgba(20, 91, 115, 0.28);
}

.app-shell {
  position: relative;
  width: min(1200px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

.hero-panel,
.control-panel,
.document-panel,
.result-block,
.status-box {
  position: relative;
  margin-bottom: 1.25rem;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-panel::before,
.result-block::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), transparent 45%),
    linear-gradient(320deg, rgba(255, 255, 255, 0.4), transparent 55%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
summary {
  font-family: "Iowan Old Style", "Times New Roman", "Nanum Myeongjo", serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 1.7rem;
}

.hero-copy,
.panel-header p,
.muted-copy {
  color: var(--muted);
}

.hero-copy {
  max-width: 60rem;
  margin-top: 0.75rem;
  font-size: 1.06rem;
}

.formula-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.4rem;
}

.formula-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(79, 73, 55, 0.08);
}

.formula-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.formula-label {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

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

.panel-header p {
  margin: 0.2rem 0 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #145b73, #1d7b84);
  box-shadow: 0 10px 24px rgba(20, 91, 115, 0.28);
}

.secondary-button {
  color: var(--accent);
  background: rgba(20, 91, 115, 0.1);
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(79, 73, 55, 0.08);
}

.danger-button {
  color: #8b2b2b;
  background: rgba(177, 69, 69, 0.11);
}

.settings-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.field > span,
.field label > span {
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(79, 73, 55, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  outline: none;
}

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: rgba(20, 91, 115, 0.46);
  box-shadow: 0 0 0 4px rgba(20, 91, 115, 0.08);
}

.compact-group {
  display: grid;
  gap: 0.9rem;
}

.choice-group {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(79, 73, 55, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
}

.choice-group legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.choice-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.choice-option + .choice-option {
  margin-top: 0.85rem;
}

.choice-option input[type="radio"] {
  margin-top: 0.2rem;
}

.choice-option span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.choice-option small {
  color: var(--muted);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 73, 55, 0.12);
  background: rgba(255, 255, 255, 0.58);
}

.help-box {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.52);
}

.help-box summary {
  cursor: pointer;
  font-size: 1.08rem;
}

.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.document-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.15rem;
}

.document-actions .primary-button {
  min-width: min(100%, 280px);
}

.document-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(79, 73, 55, 0.1);
}

.document-card textarea {
  min-height: 210px;
  resize: vertical;
}

.document-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.document-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--highlight-soft);
  color: var(--highlight);
  font-weight: 700;
}

.status-box {
  min-height: 56px;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.status-box.success {
  color: #0a6840;
  border-color: rgba(10, 104, 64, 0.18);
  background: rgba(225, 249, 237, 0.82);
}

.status-box.warning {
  color: #8d5624;
  border-color: rgba(141, 86, 36, 0.16);
  background: rgba(255, 244, 227, 0.82);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.summary-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(248, 242, 233, 0.78));
  border: 1px solid rgba(79, 73, 55, 0.12);
}

.summary-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.3rem;
}

.summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.summary-pill,
.keyword-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
}

.summary-pill {
  background: rgba(20, 91, 115, 0.08);
  color: var(--accent);
  font-weight: 700;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.keyword-chip {
  background: rgba(191, 95, 45, 0.1);
  color: #8f451c;
}

.keyword-chip em {
  margin-right: 0.35rem;
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.keyword-chip.is-top3 {
  background: linear-gradient(135deg, rgba(191, 95, 45, 0.2), rgba(255, 225, 170, 0.68));
  box-shadow: inset 0 0 0 1px rgba(191, 95, 45, 0.16);
}

.keyword-chip strong {
  margin-left: 0.35rem;
}

.highlight-preview {
  margin-top: 0.95rem;
  padding: 0.9rem 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 252, 242, 0.9);
  border: 1px solid rgba(191, 95, 45, 0.16);
}

.highlight-preview-label {
  margin: 0 0 0.45rem;
  color: var(--highlight);
  font-weight: 800;
}

.highlight-preview-text {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
}

.term-highlight {
  padding: 0.06rem 0.18rem;
  border-radius: 0.3rem;
  background: rgba(255, 214, 109, 0.88);
  color: #5a3200;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.table-shell {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(79, 73, 55, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.85rem;
  border-bottom: 1px solid rgba(79, 73, 55, 0.08);
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fcfaf5;
  font-weight: 800;
}

tbody tr:hover {
  background: rgba(20, 91, 115, 0.04);
}

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

.metric-main {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.metric-sub {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

.site-footer {
  padding: 0.6rem 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

@media (max-width: 900px) {
  .formula-strip,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 1rem, 1200px);
    margin-top: 1rem;
  }

  .hero-panel,
  .control-panel,
  .document-panel,
  .result-block,
  .status-box {
    padding: 1rem;
    border-radius: 22px;
  }

  .document-actions .primary-button {
    width: 100%;
  }
}
