:root {
  --bg: #f5f8fd;
  --surface: #ffffff;
  --surface-alt: #eef4fb;
  --text: #272829;
  --text-muted: #6c7a89;
  --heading: #173b6c;
  --accent: #149ddd;
  --accent-hover: #37b3ed;
  --accent-soft: #e4f3fb;
  --border: #dde6f0;
  --shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
  --success: #2e9e5b;
  --success-soft: #e3f5ea;
  --danger: #d64545;
  --gold: #e0a100;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1320;
  --surface: #101b2c;
  --surface-alt: #16263d;
  --text: #c9d1d9;
  --text-muted: #8b98a8;
  --heading: #e6edf3;
  --accent: #37b3ed;
  --accent-hover: #6cc8f2;
  --accent-soft: #16263d;
  --border: #1f3350;
  --shadow: 0 2px 15px rgba(0, 0, 0, 0.4);
  --success: #4cc685;
  --success-soft: #143424;
  --danger: #f07070;
  --gold: #f2c94c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Open Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #040b14;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  color: #fff;
}

.back-link:hover {
  color: #37b3ed;
}

.theme-toggle {
  border: 0;
  font-size: 18px;
  background-color: #149ddd;
  color: #fff;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.theme-toggle:hover {
  background-color: #2eafec;
}

.theme-toggle .bi-sun,
[data-theme="dark"] .theme-toggle .bi-moon-stars {
  display: none;
}

[data-theme="dark"] .theme-toggle .bi-sun {
  display: inline;
}

/* Title */
.page-title {
  text-align: center;
  padding: 36px 16px 24px;
}

.page-title h1 {
  font-family: "Raleway", sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--heading);
  margin: 0 0 20px;
  padding-bottom: 20px;
  position: relative;
}

.page-title h1::after {
  content: "";
  position: absolute;
  width: 50px;
  height: 3px;
  background: var(--accent);
  bottom: 0;
  left: calc(50% - 25px);
}

.page-title p {
  margin: 0;
  color: var(--text-muted);
}

/* Layout: menu + current tool */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.tool-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: start;
  position: sticky;
  top: 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.tool-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text);
  font-family: "Poppins", sans-serif;
  font-size: 15px;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s;
}

.tool-menu a i {
  font-size: 18px;
  color: var(--accent);
}

.tool-menu a:hover {
  background: var(--surface-alt);
}

.tool-menu a[aria-current="page"] {
  background: #149ddd;
  color: #fff;
}

.tool-menu a[aria-current="page"] i {
  color: #fff;
}

.tool h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--heading);
  margin: 0 0 6px;
}

.tool h2 i {
  color: var(--accent);
}

.tool-desc {
  margin: 0 0 20px;
  color: var(--text-muted);
}

/* Cards and forms */
.card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--heading);
  margin: 0 0 12px;
}

.card.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.field-label,
.fields label,
.range-label {
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--heading);
}

.field-label {
  display: block;
  margin-bottom: 8px;
}

textarea,
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: "Open Sans", sans-serif;
  font-size: 15px;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 157, 221, 0.2);
}

.list-info {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 140px;
  text-align: left;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
}

.check input {
  width: 17px;
  height: 17px;
  accent-color: #149ddd;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 50px;
  padding: 9px 22px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

.btn-lg {
  padding: 12px 36px;
  font-size: 17px;
}

.btn-primary {
  background: #149ddd;
  color: #fff;
}

.btn-primary:hover {
  background: #2eafec;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--border);
}

[data-theme="dark"] .btn-secondary {
  background: #1f3350;
  color: #e6edf3;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #2a4468;
}

.btn.copied,
.icon-btn.copied {
  color: var(--success);
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--accent-soft);
}

/* Results */
.result:empty {
  display: none;
}

.result {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.stats {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.big-number span,
.big-word {
  display: block;
  text-align: center;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 56px;
  line-height: 1.2;
  color: var(--accent);
  word-break: break-word;
}

.big-word {
  font-size: 36px;
}

.winner-label {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.number-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.number-list span {
  min-width: 52px;
  padding: 6px 12px;
  border-radius: 6px;
  text-align: center;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--accent-soft);
  color: var(--accent);
}

.list-title {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 8px;
}

.list-title:not(:first-child) {
  margin-top: 16px;
}

.ranked {
  margin: 0;
  padding-left: 0;
  list-style: none;
  counter-reset: rank;
}

.ranked li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

.ranked li:last-child {
  border-bottom: 0;
}

.ranked li::before {
  content: counter(rank);
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.ranked.winners li {
  font-weight: 600;
  font-size: 17px;
}

.ranked.winners li::before {
  background: var(--gold);
  color: #3a2a00;
}

/* Ghost button (encoder "output to input") */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 9px 14px;
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Inline copy button next to a label */
.inline-copy {
  width: 28px;
  height: 28px;
  font-size: 15px;
  vertical-align: middle;
}

textarea[readonly],
textarea.has-error {
  background: var(--surface-alt);
}

textarea.has-error {
  color: var(--danger);
}

.hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Monospace outputs */
.mono,
pre.json,
.cipher-out,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

textarea#enc-input,
textarea#enc-output,
textarea#jwt-input,
#hashid-input,
#subnet-input,
#ts-unix {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Badges / status lines */
.badge {
  margin: 0 0 8px;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
}

.badge-danger {
  background: rgba(214, 69, 69, 0.12);
  color: var(--danger);
}

.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}

/* JSON block */
pre.json {
  margin: 0 0 8px;
  padding: 14px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.claim-times {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Hash identifier list */
.hashid-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hashid-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.hashid-list li:last-child {
  border-bottom: 0;
}

.hashid-name {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  color: var(--heading);
}

.hashid-mode {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 50px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Tabs (ciphers) */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.cipher-options {
  margin-top: 14px;
}

.cipher-out {
  padding: 14px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--heading);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Caesar ROT table */
.rot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rot-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
}

.rot-table .rot-n {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  width: 1%;
}

.rot-table .rot-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.rot-table tr.current {
  background: var(--accent-soft);
}

.rot-table tr.current .rot-n,
.rot-table tr.current .rot-text {
  color: var(--accent);
  font-weight: 600;
}

/* Info tables (subnet, timestamp) */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.info-table th {
  text-align: left;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px 8px 0;
  white-space: nowrap;
  vertical-align: top;
}

.info-table td {
  padding: 8px 0;
  color: var(--heading);
  word-break: break-all;
}

.info-table tr + tr th,
.info-table tr + tr td {
  border-top: 1px solid var(--border);
}

.result.inline {
  margin-top: 14px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.result.inline:empty {
  display: none;
}

/* Password strength */
.password-output input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--heading);
  font-size: 16px;
}

.password-output input:focus {
  outline: none;
  box-shadow: none;
}

.strength-bar {
  height: 8px;
  margin-top: 16px;
  border-radius: 50px;
  background: var(--surface-alt);
  overflow: hidden;
}

.strength-bar > div {
  height: 100%;
  width: 0;
  border-radius: 50px;
  transition: width 0.3s, background-color 0.3s;
}

.strength-bar > div.s0 { background: #d64545; }
.strength-bar > div.s1 { background: #e67e22; }
.strength-bar > div.s2 { background: #f2c94c; }
.strength-bar > div.s3 { background: #27ae60; }
.strength-bar > div.s4 { background: #149ddd; }

.strength-label {
  margin: 10px 0 0;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
}

.strength-label.s0 { color: #d64545; }
.strength-label.s1 { color: #e67e22; }
.strength-label.s2 { color: var(--gold); }
.strength-label.s3 { color: var(--success); }
.strength-label.s4 { color: var(--accent); }

.pw-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.pw-stat {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-alt);
}

.pw-stat-key {
  font-size: 12px;
  color: var(--text-muted);
}

.pw-stat-value {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  color: var(--heading);
}

.pw-warnings {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.pw-warnings li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  color: var(--danger);
  font-size: 14px;
}

.footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 16px 32px;
}

/* Small screens: the menu becomes a horizontal, scrollable bar */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .tool-menu {
    flex-direction: row;
    overflow-x: auto;
    position: static;
    scrollbar-width: thin;
  }

  .tool-menu a {
    padding: 8px 12px;
    font-size: 14px;
  }
}

/* Two columns (timestamp) */
.two-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.two-cols .card {
  margin-bottom: 0;
}
