:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #175ddc;
  --accent-text: #ffffff;
  --field: #f7f8fa;
  --num-color: #175ddc;
  --special-color: #d14;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --card: #1e2126;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2d3138;
    --accent: #6ea8fe;
    --accent-text: #0b0c0f;
    --field: #262a30;
    --num-color: #6ea8fe;
    --special-color: #ff7b86;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card__head { margin-bottom: 20px; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
.subtitle { margin: 0; color: var(--muted); font-size: .85rem; }

/* Segmented mode toggle */
.segmented {
  display: flex;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.segmented__btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented__btn.is-active {
  background: var(--card);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

/* Output */
.output {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.output__value {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  word-break: break-all;
  align-self: center;
  user-select: all;
}
.output__value .ch-num { color: var(--num-color); }
.output__value .ch-special { color: var(--special-color); }
.output__actions { display: flex; gap: 4px; align-items: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

.toast {
  height: 1.1em;
  margin: 8px 2px 0;
  font-size: .8rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* Options */
.options {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.options[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: .9rem; font-weight: 500; }

.field--stepper {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.slider-row { display: flex; align-items: center; gap: 14px; }
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}
.length-num {
  width: 64px;
  text-align: center;
}

input[type="number"], input[type="text"] {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: .95rem;
  font-family: inherit;
}
input[type="number"] { width: 64px; }
.sep-input { width: 80px; text-align: center; }
input:focus-visible, .segmented__btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Checkbox rows */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.check code, .field code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82em;
  color: var(--muted);
  background: var(--field);
  padding: 1px 5px;
  border-radius: 4px;
}

.page-foot {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}
.page-foot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
}
