:root {
  --brand: #0165b4;
  --brand-rgb: 1, 101, 180;
  --brand-dark: #014f8d;
  --brand-soft: #e7f2fb;
  --ink: #12212f;
  --muted: #647384;
  --line: #dbe4eb;
  --paper: #f4f7f9;
  --white: #fff;
  --success: #168451;
  --danger: #bd3348;
  --shadow: 0 22px 60px rgba(16, 43, 66, .10);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 0, rgba(var(--brand-rgb), .09), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.utility-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 58px 0 72px;
}

.utility-header {
  max-width: 720px;
  margin-bottom: 30px;
}

.utility-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 15px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .11em;
}

.utility-kicker::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  content: "";
  box-shadow: 0 0 0 5px rgba(var(--brand-rgb), .10);
}

.utility-header h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1;
  letter-spacing: -.055em;
}

.utility-header > p:last-child {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.utility-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}

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

.utility-pane { min-width: 0; padding: 28px; }
.utility-pane + .utility-pane { border-left: 1px solid var(--line); }

.pane-heading,
.action-row,
.metric-row,
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pane-heading { margin-bottom: 18px; }
.pane-heading h2, .preview-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }

.hint, .status, .field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field { display: grid; gap: 8px; margin-bottom: 17px; }
.field > span { font-size: 12px; font-weight: 750; }

.control,
.field input,
.field select,
.field textarea,
.code-area {
  width: 100%;
  border: 1px solid #cbd8e2;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input, .field select { min-height: 46px; padding: 0 13px; }
.field textarea, .code-area { min-height: 330px; resize: vertical; padding: 15px; line-height: 1.65; }
.code-area { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; tab-size: 2; }
.compact-area { min-height: 235px; }
.hash-output { min-height: 210px; overflow-wrap: anywhere; }

.field input:focus,
.field select:focus,
.field textarea:focus,
.code-area:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .10);
  outline: none;
}

.two-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 11px;
  background: var(--brand);
  color: white;
  font-size: 13px;
  font-weight: 780;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease;
}

.button:hover { border-color: var(--brand-dark); background: var(--brand-dark); transform: translateY(-1px); }
.button.secondary { border-color: var(--line); background: white; color: var(--ink); }
.button.secondary:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.button.danger { border-color: #f2d5da; background: #fff5f6; color: var(--danger); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button:focus-visible { outline: 3px solid rgba(var(--brand-rgb), .2); outline-offset: 2px; }

.button-row { display: flex; flex-wrap: wrap; gap: 9px; }

.drop-zone {
  min-height: 230px;
  display: grid;
  place-items: center;
  padding: 28px;
  border: 1.5px dashed #a8bfd0;
  border-radius: 18px;
  background: #f8fbfd;
  text-align: center;
  transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.drop-zone.is-dragging { border-color: var(--brand); background: var(--brand-soft); transform: scale(.995); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); font-size: 24px; font-weight: 850; }
.drop-zone strong { display: block; font-size: 16px; }
.drop-zone p { margin: 8px 0 17px; color: var(--muted); font-size: 12px; }

.preview-box {
  min-height: 330px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background-image: linear-gradient(45deg, #edf1f4 25%, transparent 25%), linear-gradient(-45deg, #edf1f4 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #edf1f4 75%), linear-gradient(-45deg, transparent 75%, #edf1f4 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.preview-box img { display: block; width: 100%; max-height: 500px; object-fit: contain; }
.empty-preview { padding: 30px; color: var(--muted); font-size: 13px; text-align: center; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 16px 0; }
.metric { padding: 12px; border-radius: 12px; background: #f4f7f9; }
.metric span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.metric strong { font-size: 13px; }

.range-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 13px; }
.range-line input { accent-color: var(--brand); }
.range-value { min-width: 48px; color: var(--brand); font-size: 13px; font-weight: 800; text-align: right; }

.result-banner {
  min-height: 48px;
  display: flex;
  align-items: center;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  line-height: 1.5;
}
.result-banner.error { background: #fff0f2; color: var(--danger); }
.result-banner.success { background: #eaf8f1; color: var(--success); }

.password-output {
  min-height: 82px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f8fafb;
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(17px, 3vw, 24px);
  font-weight: 800;
  line-height: 1.5;
}

.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 14px 0 20px; }
.check-option { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; font-size: 12px; }
.check-option input { accent-color: var(--brand); }
.standalone-check { margin: 14px 0 18px; }

.color-input-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: end;
  gap: 14px;
}

.color-input-row > input[type="color"] {
  width: 76px;
  height: 72px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  cursor: pointer;
}

.color-input-row .field { margin-bottom: 0; }

.color-swatch {
  min-height: 170px;
  margin-top: 20px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 18px;
  background: #0165b4;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
  transition: background-color .2s ease;
}

.strength-track { height: 8px; overflow: hidden; margin: 15px 0 8px; border-radius: 999px; background: #e6ecf0; }
.strength-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .25s ease, background-color .25s ease; }

.timestamp-result { display: grid; gap: 10px; }
.result-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafcfd; }
.result-item span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; }
.result-item code { overflow-wrap: anywhere; color: var(--ink); font-size: 13px; }
.copyable-result > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.copyable-result button { flex: 0 0 auto; min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--brand); font-size: 10px; font-weight: 800; }
.copyable-result button:hover, .copyable-result button:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }

.copy-result-list { display: grid; gap: 10px; }
.copy-result { width: 100%; min-height: 82px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 14px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fafcfd; color: var(--ink); text-align: left; }
.copy-result > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.copy-result code { grid-column: 1; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; }
.copy-result i { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--brand); font-size: 11px; font-style: normal; font-weight: 800; }
.copy-result:hover, .copy-result:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }

.choice-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.choice-cards label { cursor: pointer; }
.choice-cards input { position: absolute; opacity: 0; pointer-events: none; }
.choice-cards label > span { min-height: 94px; display: grid; align-content: center; gap: 7px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fafcfd; }
.choice-cards strong { font-size: 17px; }
.choice-cards small { color: var(--muted); }
.choice-cards input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.lottery-results { display: grid; gap: 11px; }
.lottery-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fafcfd; }
.lottery-index { width: 26px; color: var(--muted); font-size: 10px; font-weight: 800; }
.lottery-ball { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #d84252; color: #fff; font-size: 12px; font-weight: 850; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
.lottery-ball.blue { margin-left: 5px; background: var(--brand); }
.lottery-note { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 16px; }
.stat { padding: 13px; border-radius: 12px; background: #f3f7fa; text-align: center; }
.stat strong { display: block; color: var(--brand); font-size: 20px; }
.stat span { color: var(--muted); font-size: 10px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .16);
  font-size: 12px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 780px) {
  .utility-shell { width: min(100% - 24px, 1120px); padding-top: 34px; }
  .utility-header { padding-right: 70px; }
  .utility-grid { grid-template-columns: 1fr; }
  .utility-pane { padding: 20px; }
  .utility-pane + .utility-pane { border-top: 1px solid var(--line); border-left: 0; }
  .two-fields, .check-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .field textarea, .code-area { min-height: 250px; }
}

@media (max-width: 520px) {
  .utility-shell { padding-top: 74px; padding-bottom: 48px; }
  .utility-header { padding-right: 0; margin-bottom: 22px; }
  .utility-header h1 { font-size: clamp(31px, 10vw, 42px); }
  .utility-header > p:last-child { margin-top: 13px; font-size: 14px; line-height: 1.65; }
  .utility-card { border-radius: 20px; }
  .utility-pane { padding: 16px; }
  .pane-heading, .action-row, .metric-row, .preview-heading { align-items: flex-start; flex-wrap: wrap; }
  .field input, .field select, .field textarea, .code-area { font-size: 16px; }
  .button-row .button { flex: 1 1 132px; }
  .metrics { grid-template-columns: 1fr; }
  .choice-cards { grid-template-columns: 1fr; }
  .color-input-row { grid-template-columns: 64px minmax(0, 1fr); }
  .color-input-row > input[type="color"] { width: 64px; height: 64px; }
  .copyable-result > div { align-items: flex-start; flex-direction: column; }
  .copy-result { grid-template-columns: minmax(0, 1fr) auto; padding: 13px; }
  .lottery-row { padding: 12px 9px; gap: 6px; }
  .lottery-index { width: 100%; }
  .lottery-ball { width: 34px; height: 34px; }
  .toast { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
