:root {
  --bg: #f4f7ff;
  --bg-strong: #eef2ff;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #dfe7ff;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #0a9d6d;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 20px 45px rgba(79, 70, 229, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(180deg, #f7f9ff 0%, #eef3ff 100%);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.page-shell {
  padding-bottom: 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid rgba(214, 218, 255, 0.9);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.25);
}

.brand-text {
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}

.hero {
  padding: 52px 0 30px;
}

.hero-copy {
  max-width: 760px;
  padding: 20px 0;
}

.eyebrow,
.kicker {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
}

.hero p {
  max-width: 700px;
  margin-top: 16px;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--muted);
}

.trust-line {
  display: inline-flex;
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.scanner-panel,
.results-panel,
.info-card,
.score-methodology,
.dictionary-controls,
.dictionary-list-wrap,
.faq-item {
  background: var(--panel);
  border: 1px solid rgba(214, 218, 255, 0.8);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.scanner-panel {
  padding: 24px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2,
.section-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.input-card {
  padding: 18px;
  border: 1px solid rgba(214, 218, 255, 0.9);
  background: rgba(248, 250, 255, 0.65);
  border-radius: 18px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field-header label {
  font-weight: 700;
}

.counter-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 14px;
  background: white;
  overflow: hidden;
}

.input-shell:focus-within,
.toolbar input:focus,
.custom-form input:focus,
.custom-form textarea:focus,
.custom-form select:focus {
  border-color: rgba(79, 70, 229, 0.6);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

#subjectInput,
#bodyInput,
.toolbar input,
.custom-form input,
.custom-form textarea,
.custom-form select {
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 12px;
  background: white;
  color: var(--text);
}

#subjectInput,
#bodyInput {
  width: 100%;
  border: none;
  padding: 15px 16px;
  resize: vertical;
  background: transparent;
  color: var(--text);
}

#subjectInput {
  min-height: 54px;
}

#bodyInput {
  min-height: 270px;
}

.clear-field {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 0 14px 0 0;
}

.textarea-shell {
  display: block;
  padding: 0;
}

.textarea-shell textarea {
  display: block;
  width: 100%;
  border: none;
  padding: 15px 16px;
  resize: vertical;
  min-height: 270px;
  background: transparent;
}

.textarea-shell .clear-field {
  display: inline-block;
  margin: 0 14px 12px auto;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #4f46e5, #5b51e5);
  color: white;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
}

.secondary-btn {
  color: var(--text);
  background: rgba(79, 70, 229, 0.06);
  border-color: rgba(79, 70, 229, 0.12);
}

.ghost-btn {
  background: rgba(29, 78, 216, 0.04);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.2);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.results-panel {
  min-height: 420px;
  padding: 24px;
  min-width: 0;
}

.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 380px;
  color: var(--muted);
}

.placeholder-icon {
  font-size: 2.3rem;
  margin-bottom: 10px;
}

.results-placeholder h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: var(--text);
}

.results-content {
  display: block;
}

.overall-card,
.subject-card,
.body-card,
.summary-card {
  background: rgba(248, 250, 255, 0.7);
  border: 1px solid rgba(214, 218, 255, 0.9);
  border-radius: 18px;
  padding: 16px;
}

.overall-card {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.risk-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--primary) 0deg 200deg, rgba(148, 163, 184, 0.18) 200deg 360deg);
  position: relative;
}

.risk-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: white;
}

.risk-ring-value {
  position: relative;
  z-index: 1;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
}

.risk-meta h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.risk-label {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.risk-label.low { background: rgba(10, 157, 109, 0.1); color: var(--success); }
.risk-label.moderate { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.risk-label.high { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.risk-label.very-high { background: rgba(127, 29, 29, 0.12); color: #991b1b; }

.risk-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-tag {
  border-radius: 14px;
  border: 1px solid rgba(214, 218, 255, 0.8);
  background: white;
  padding: 10px 12px;
}

.metric-tag strong {
  display: block;
  margin-bottom: 2px;
  font-size: 1rem;
}

.metric-tag span {
  color: var(--muted);
  font-size: 0.82rem;
}

.analysis-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.analysis-card:nth-child(1),
.analysis-card:nth-child(2),
.analysis-card:nth-child(3),
.analysis-card:nth-child(4) {
  grid-column: 1 / -1;
}

.analysis-card {
  background: rgba(248, 250, 255, 0.7);
  border: 1px solid rgba(214, 218, 255, 0.9);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
}

.analysis-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  padding: 0 0 12px;
}

.analysis-card summary::-webkit-details-marker {
  display: none;
}

.issue-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.issue-columns h4 {
  margin: 0 0 10px;
}

.analysis-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 14px;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.highlight-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid rgba(203, 213, 225, 0.8);
  line-height: 1.7;
  word-break: break-word;
}

.highlight-box .token {
  display: inline;
  padding: 2px 6px;
  border-radius: 6px;
  color: #111827;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.highlight-box .high { background: rgba(220, 38, 38, 0.12); }
.highlight-box .medium { background: rgba(217, 119, 6, 0.12); }
.highlight-box .low { background: rgba(79, 70, 229, 0.12); }

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  min-width: 0;
}

.trigger-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.trigger-table th,
.trigger-table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(203, 213, 225, 0.8);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.trigger-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.severity-badge.high { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.severity-badge.medium { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.severity-badge.low { background: rgba(79, 70, 229, 0.08); color: var(--primary); }

.issue-list,
.recommendation-list,
.positive-list,
.methodology-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.issue-list li,
.recommendation-list li,
.positive-list li,
.methodology-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid rgba(203, 213, 225, 0.8);
  color: var(--text);
}

.issue-list li::before,
.recommendation-list li::before,
.positive-list li::before,
.methodology-list li::before {
  content: '•';
  color: var(--primary);
  font-size: 1.3rem;
  line-height: 1;
}

.recommendation-list li::before { color: var(--warning); }
.positive-list li::before { color: var(--success); }

.section-block {
  padding-top: 28px;
}

.section-header {
  margin-bottom: 18px;
}

.info-grid,
.faq-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.info-card,
.faq-item {
  padding: 20px;
}

.info-card h3,
.faq-item h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.info-card p,
.faq-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.score-methodology {
  margin-top: 22px;
  padding: 18px 20px;
}

.score-methodology h3 {
  margin: 0 0 12px;
}

.score-methodology ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
  color: var(--muted);
}

.dictionary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.dictionary-controls,
.dictionary-list-wrap {
  padding: 20px;
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar input,
.custom-form input,
.custom-form textarea,
.custom-form select {
  width: 100%;
  padding: 12px 14px;
  margin-top: 8px;
}

.custom-form {
  display: grid;
  gap: 14px;
}

.custom-form h3,
.dictionary-list h3 {
  margin: 0;
}

.custom-form label {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.dictionary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.dictionary-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dictionary-list > .empty-state {
  grid-column: 1 / -1;
}

.dict-item {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(248, 250, 255, 0.7);
  border: 1px solid rgba(214, 218, 255, 0.8);
}

.dict-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dict-item strong {
  font-size: 1rem;
}

.dict-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.dict-item-actions {
  display: flex;
  gap: 8px;
}

.action-mini {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: white;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
}

.empty-state {
  padding: 22px 18px;
  border: 1px dashed rgba(148, 163, 184, 0.8);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(248, 250, 255, 0.6);
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 50;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #111827;
  color: white;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
  font-size: 0.92rem;
}

.toast.error {
  background: #991b1b;
}

.toast.success {
  background: #0a9d6d;
}

@media (max-width: 980px) {
  .app-shell,
  .dictionary-layout,
  .info-grid,
  .faq-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 760px) {
  .analysis-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .dictionary-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .issue-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .analysis-card:nth-child(3),
  .analysis-card:nth-child(4) {
    grid-column: auto;
  }

  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    position: static;
  }

  .nav-wrap {
    min-height: 72px;
  }

  .brand-text {
    font-size: 0.92rem;
  }

  .dictionary-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero {
    padding-top: 36px;
  }

  .scanner-panel,
  .results-panel,
  .dictionary-controls,
  .dictionary-list-wrap {
    padding: 16px;
  }

  .overall-card {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 14px;
  }

  .risk-ring {
    width: 90px;
    height: 90px;
  }

  .risk-ring::before {
    inset: 10px;
  }

  .action-row {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }
}
