:root {
  --bg: #eef1f4;
  --card: #fbfcfd;
  --ink: #141922;
  --steel: #5d6b7b;
  --line: #d5dce3;
  --line-strong: #b9c3cd;
  --wax: #b02e38;
  --wax-deep: #8c2129;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Тёмная тема: системная — по умолчанию, data-theme — явный выбор */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181f;
    --card: #1b212b;
    --ink: #e9edf1;
    --steel: #93a1b0;
    --line: #2b3440;
    --line-strong: #3d4855;
    --wax: #c2404b;
    --wax-deep: #d95a64;
  }
}

:root[data-theme="dark"] {
  --bg: #14181f;
  --card: #1b212b;
  --ink: #e9edf1;
  --steel: #93a1b0;
  --line: #2b3440;
  --line-strong: #3d4855;
  --wax: #c2404b;
  --wax-deep: #d95a64;
  color-scheme: dark;
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Шапка ─────────────────────────────────────────── */

.top {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 40px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.wordmark::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--wax);
  flex-shrink: 0;
}

.top-note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--steel);
}

.lang {
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
}

.lang button {
  background: none;
  border: 0;
  padding: 2px 1px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--steel);
  border-bottom: 2px solid transparent;
}

.lang button:hover { color: var(--ink); }

.lang button[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--wax);
}

.lang-sep {
  font-size: 11px;
  color: var(--line-strong);
}

.theme-btn {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  color: var(--steel);
  display: inline-flex;
  align-items: center;
  align-self: center;
}

.theme-btn:hover { color: var(--ink); }

.theme-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.theme-btn .icon-sun { display: none; }

:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }

:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }

/* ── Заголовки и текст ─────────────────────────────── */

h1 {
  font-family: var(--mono);
  font-size: clamp(1.55rem, 4.5vw, 2.35rem);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  text-wrap: balance;
}

.lede {
  color: var(--steel);
  max-width: 52ch;
  margin-bottom: 28px;
}

/* ── Карточка ──────────────────────────────────────── */

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

textarea {
  display: block;
  width: 100%;
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 18px;
  min-height: 130px;
}

textarea:focus { outline: none; }

textarea::placeholder { color: var(--steel); opacity: 0.75; }

.card:focus-within { border-color: var(--line-strong); }

/* Фирменная полоса: живой шифротекст */
.cipher-strip {
  border-top: 1px dashed var(--line);
  padding: 10px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cipher-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wax);
}

.cipher-text {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--steel);
  word-break: break-all;
  max-height: 3em;
  overflow: hidden;
}

/* Пароль на прочтение */
.card-pass {
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px dashed var(--line);
  padding: 10px 18px;
}

.pass-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--steel);
  white-space: nowrap;
}

.pass-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 4px 0;
}

.pass-input:focus { outline: none; }

.pass-input::placeholder { color: var(--steel); opacity: 0.6; }

.pass-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.pass-row .pass-input {
  flex: none;
  width: min(320px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 12px;
  text-align: center;
}

.pass-row .pass-input:focus {
  outline: 2px solid var(--wax);
  outline-offset: 2px;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding: 12px 18px;
}

.card-center {
  padding: 40px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── Элементы форм ─────────────────────────────────── */

.ttl-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--steel);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

select {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 8px;
}

.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.btn:hover { border-color: var(--steel); }

.btn-wax {
  background: var(--wax);
  border-color: var(--wax);
  color: #fff;
}

.btn-wax:hover {
  background: var(--wax-deep);
  border-color: var(--wax-deep);
}

.btn-ghost { color: var(--steel); }

.btn-big { font-size: 15px; padding: 14px 26px; }

.btn[disabled] { opacity: 0.55; cursor: default; }

:focus-visible {
  outline: 2px solid var(--wax);
  outline-offset: 2px;
}

/* ── Результат ─────────────────────────────────────── */

.linkbox {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 18px;
  word-break: break-all;
  user-select: all;
}

.plaintext {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint {
  font-size: 12.5px;
  color: var(--steel);
  max-width: 40ch;
}

.warn {
  font-size: 13px;
  color: var(--steel);
  border-left: 2px solid var(--wax);
  padding-left: 12px;
  margin: 20px 0;
  max-width: 56ch;
}

.error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--wax);
}

/* ── Факты ─────────────────────────────────────────── */

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.fact h3 {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fact h3::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--wax);
  flex-shrink: 0;
}

.fact p {
  font-size: 13px;
  color: var(--steel);
}

/* ── Подвал и статус ───────────────────────────────── */

.foot {
  margin-top: auto;
  padding-top: 48px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--steel);
}

.status {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.status.show { opacity: 1; }

/* ── Смена состояний ───────────────────────────────── */

main section {
  animation: enter 240ms ease-out;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  main section { animation: none; }
  .btn, .status { transition: none; }
}

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

@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; gap: 20px; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .card-foot .btn { width: 100%; text-align: center; }
}
