:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --ink: #111827;
  --muted: #606b80;
  --line: #d9dee8;
  --accent: #2563eb;
  --accent-strong: #1744a7;
  --bad: #dc2626;
  --warn: #d97706;
  --good: #0f7b55;
  --shadow: 0 18px 44px rgba(20, 29, 46, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

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

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

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

.brand strong {
  font-size: 1.35rem;
  line-height: 1.1;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #050814;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 950;
}

.privacy {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.86fr);
  gap: 24px;
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compose,
.result {
  min-width: 0;
}

.compose {
  padding-right: 24px;
  border-right: 1px solid var(--line);
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.chips input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chips span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.chips input:checked + span {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent-strong);
}

.message-field {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

textarea {
  width: 100%;
  min-height: 292px;
  resize: vertical;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 20px;
  color: var(--ink);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.55;
}

textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  outline-offset: 1px;
}

.counter {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

#checkButton {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

#checkButton:hover {
  background: var(--accent-strong);
}

.verdict {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid #fecaca;
  border-radius: 8px 8px 0 0;
  background: #fff1f2;
}

.verdict-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 3px solid var(--bad);
  border-radius: 8px;
  color: var(--bad);
  font-size: 2rem;
  font-weight: 950;
}

.verdict strong {
  display: block;
  color: var(--bad);
  font-size: 1.8rem;
  line-height: 1;
}

.verdict p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
}

.verdict.safe {
  border-color: #b7e4ce;
  background: #effaf4;
}

.verdict.safe .verdict-icon,
.verdict.safe strong {
  border-color: var(--good);
  color: var(--good);
}

.verdict.caution {
  border-color: #fed7aa;
  background: #fff7ed;
}

.verdict.caution .verdict-icon,
.verdict.caution strong {
  border-color: var(--warn);
  color: var(--warn);
}

.risk-line {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #fff;
}

.risk-line > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 900;
}

.risk-line span {
  color: var(--muted);
}

.risk-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.risk-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--bad);
  transition: width 180ms ease;
}

.flags,
.steps {
  margin-top: 18px;
}

.flags h2,
.steps h2 {
  margin-bottom: 10px;
  font-size: 1.02rem;
}

#flagsList {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.flag {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.flag:last-child {
  border-bottom: 0;
}

.flag-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fee2e2;
  color: var(--bad);
  font-size: 0.9rem;
  font-weight: 950;
}

.flag strong,
.steps span {
  display: block;
  font-weight: 950;
}

.flag small,
.steps small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 650;
}

.empty-flags {
  padding: 14px;
  color: var(--muted);
  font-weight: 750;
}

.steps {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.steps h2 {
  padding: 14px 14px 0;
}

.steps a {
  display: block;
  padding: 13px 14px;
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.steps a:hover {
  background: var(--surface-soft);
}

.history {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  cursor: pointer;
  font-weight: 950;
}

.history summary::-webkit-details-marker {
  display: none;
}

.history small {
  color: var(--muted);
  font-weight: 650;
}

#clearHistory {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 850;
}

#historyList {
  display: grid;
  gap: 8px;
  padding: 0 18px 18px;
}

.history-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-score {
  color: var(--bad);
  font-weight: 950;
}

.history-row p {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row span:last-child {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.notes p {
  margin-bottom: 0;
}

.notes a {
  color: var(--accent-strong);
  font-weight: 900;
}

@media (max-width: 980px) {
  .tool,
  .notes {
    grid-template-columns: 1fr;
  }

  .compose {
    padding-right: 0;
    padding-bottom: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1320px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand strong {
    font-size: 1.14rem;
  }

  .brand small,
  .privacy {
    font-size: 0.86rem;
  }

  .tool {
    padding: 15px;
  }

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

  textarea {
    min-height: 248px;
    padding: 14px;
    font-size: 0.94rem;
  }

  .counter {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .history-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .history-row span:last-child {
    grid-column: 2;
  }
}
