:root {
  --bg: #f2f9f3;
  --surface: #ffffff;
  --tint: #e6f5ea;
  --tint-strong: #cdebd5;
  --flash: #a6e2b6;
  --border: #d2e9d8;
  --accent: #237a45;
  --accent-hover: #1b6538;
  --accent-soft: #4caf6e;
  --text: #1c3324;
  --muted: #4d6956;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 51, 36, .05), 0 6px 24px rgba(28, 51, 36, .06);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial,
        "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Malgun Gothic", "Noto Sans Arabic", sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

[dir="ltr"] { unicode-bidi: isolate; }

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

/* ---------- header ---------- */

.site-header { padding: 18px 0; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em;
}
.brand img { width: 40px; height: 40px; display: block; }
.brand b { color: var(--accent); font-weight: inherit; }
.brand:hover { color: var(--text); }

.langs { position: relative; }
.langs summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: .95rem; color: var(--text);
}
.langs summary::-webkit-details-marker { display: none; }
.langs summary svg { width: 18px; height: 18px; color: var(--accent); }
.langs[open] summary { border-color: var(--accent-soft); }
.langs ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 10;
  margin: 0; padding: 6px; list-style: none; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
}
.langs a {
  display: block; padding: 6px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .95rem; white-space: nowrap;
}
.langs a:hover { background: var(--tint); }
.langs a[aria-current="page"] { background: var(--tint-strong); font-weight: 600; }

/* ---------- hero ---------- */

.hero { padding-block: 18px 8px; text-align: center; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2; letter-spacing: -.02em; }
.hero p { margin: 0 auto; max-width: 560px; color: var(--muted); font-size: 1.05rem; }

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 20px 0;
}
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }

/* ---------- settings ---------- */

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; margin: 0; }

.setting { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
fieldset.setting { border: 0; padding: 0; margin: 0; }
fieldset.setting legend { padding: 0; margin-bottom: 6px; }
.setting-title { font-weight: 600; font-size: .95rem; }
.hint { color: var(--muted); font-size: .85rem; }
.hint code, .setting code { font-family: var(--mono); background: var(--tint); padding: 1px 5px; border-radius: 5px; }

.setting.switch { flex-direction: row; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  flex: none; position: relative; width: 44px; height: 26px; border-radius: 999px;
  background: #c9d6cd; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .track { background: var(--accent-soft); }
.switch input:checked + .track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; align-self: flex-start; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 18px; font-weight: 600; transition: background .15s; }
.segmented label + label span { border-inline-start: 1px solid var(--border); }
.segmented input:checked + span { background: var(--accent-soft); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }

select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; max-width: 100%;
}

/* ---------- passwords ---------- */

.passwords { display: grid; gap: 10px; }

.pw {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--tint);
  padding-block: 4px; padding-inline: 0 4px; cursor: pointer; transition: border-color .15s;
}
.pw:hover { border-color: var(--accent-soft); }
.pw-value {
  flex: 1; min-width: 0; text-align: start;
  font: 600 clamp(1.05rem, 3.6vw, 1.3rem)/1.4 var(--mono); letter-spacing: .03em; color: var(--text);
  background: none; border: 0; padding: 10px 14px; cursor: pointer; overflow-wrap: anywhere;
}
.pw-copy {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 10px; background: var(--surface); color: var(--accent); cursor: pointer;
}
.pw-copy:hover { background: var(--tint-strong); }
.pw-copy svg { width: 20px; height: 20px; }

.pw.is-copied { animation: pw-blink 1.4s ease-in-out; }
.pw.is-copied .pw-value { font-family: inherit; letter-spacing: 0; color: var(--accent); }

@keyframes pw-blink {
  0%   { background: var(--tint); }
  20%  { background: var(--flash); }
  45%  { background: var(--tint); }
  70%  { background: var(--flash); }
  100% { background: var(--tint); }
}
@media (prefers-reduced-motion: reduce) {
  .pw.is-copied { animation: none; background: var(--flash); }
}

.generate {
  display: block; width: 100%; margin-top: 16px;
  font: inherit; font-size: 1.1rem; font-weight: 700; color: #fff;
  background: var(--accent); border: 0; border-radius: 12px; padding: 14px 20px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.generate:hover { background: var(--accent-hover); }
.generate:active { transform: translateY(1px); }

a.generate { text-align: center; text-decoration: none; margin-top: 24px; }
a.generate:hover { color: #fff; }

.noscript { margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; background: #fff6d9; border: 1px solid #ecd98a; }

.lang-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; list-style: none; padding: 0; margin: 28px 0 40px; }

/* ---------- text ---------- */

.content { padding-block: 8px 24px; }
.content h2 { font-size: 1.3rem; margin: 28px 0 10px; line-height: 1.3; }
.content h2:first-child { margin-top: 8px; }
.content p, .content li { color: #2c4434; }
.content ul { padding-inline-start: 22px; }
.content kbd {
  font-family: var(--mono); font-size: .9em; background: var(--surface);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px;
}

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--border); padding: 20px 0 28px; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }

@media (max-width: 600px) {
  .settings { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .brand { font-size: 1.05rem; }
  .brand img { width: 34px; height: 34px; }
}
