/*
 * Shattershard — styles for the /tools page only (tabs, tool cards, inputs, results).
 * Loaded after site.css, on /tools alone.
 */

body:has([data-tools]) .radio {
  display: none;
}

body:has([data-tools]) .radio-mini.is-on {
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

body:has([data-tools]) .radio-mini-wrap:hover .radio-mini.is-on + .radio-pop,
body:has([data-tools]) .radio-mini-wrap:focus-within .radio-mini.is-on + .radio-pop {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.tool-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto 8px;
  padding: 8px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: 999px;
}

.tool-nav .chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.tool-nav .chip svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--accent);
  transition: transform 0.2s var(--ease);
}

.tool-nav .chip:hover svg {
  transform: scale(1.12);
}

@media (max-width: 700px) {
  .tool-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    max-width: none;
    padding: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-radius: 0;
  }

  .tool-nav .chip {
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    padding: 10px 4px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    line-height: 1.15;
    text-align: center;
  }

  .tool-nav .chip span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tool-nav .chip svg {
    width: 18px;
    height: 18px;
  }

  .tool-nav .chip:last-child:nth-child(4n + 1) {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 8px;
    padding-block: 9px;
  }
}

:not(.is-tabbed) > .tool:target {
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

.tool-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.tool > :where(.field, .tool-row, .tool-split, .code-edit, .calc) + :where(.field, .tool-row, .tool-split, .tool-actions, .calc) {
  margin-top: var(--s4);
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border: 1px dashed var(--accent);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 11px;
}

.tool-icon svg {
  width: 22px;
  height: 22px;
}

.tool-head h2 {
  margin-bottom: 4px;
  font-size: 1.3rem;
}

.tool-head p {
  color: var(--muted);
  font-size: 0.88rem;
}

.tool-head a {
  color: var(--fg);
}

.field {
  display: grid;
  gap: var(--s2);
  min-width: 0;
}

.field > span {
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--well);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.field textarea {
  display: block;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--fg);
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background: var(--well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23b8bac1'%3E%3Cpath d='M4.5 6 8 9.5 11.5 6'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
}

.mono-input,
.field textarea {
  font-family: ui-monospace, "SF Mono", Menlo, monospace !important;
  font-size: 0.88rem !important;
}

.mono-input.is-invalid {
  border-color: var(--accent) !important;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
}

.field-grow {
  flex: 1 1 260px;
}

.tool-row .btn {
  min-height: 44px;
}

.tool-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

@media (max-width: 700px) {
  .tool-split {
    grid-template-columns: 1fr;
  }
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin-top: var(--s4);
}

.file-chip {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  color: var(--text);
  font-family: var(--font-text);
  font-size: 0.85rem;
  line-height: 1.2;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, transform 0.2s var(--ease);
}

.tbtn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--accent);
}

.tbtn:hover {
  color: var(--fg);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.tbtn:active {
  transform: none;
}

.tbtn[aria-pressed="true"] {
  color: var(--fg);
  border-color: var(--accent);
}

.tbtn-accent {
  color: var(--fg);
  background: rgba(208, 52, 63, 0.14);
  border-color: rgba(208, 52, 63, 0.45);
}

.tbtn-accent:hover {
  background: rgba(208, 52, 63, 0.24);
  border-color: var(--accent);
}

.tool-actions .tbtn-accent {
  margin-left: auto;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.seg-btn {
  min-height: 30px;
  padding: 5px 14px;
  color: var(--dim);
  font-family: var(--font-text);
  font-size: 0.85rem;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.seg-btn:hover {
  color: var(--fg);
}

.seg-btn[aria-pressed="true"] {
  color: var(--fg);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 -2px 0 var(--accent);
}

.seg-btn:focus-visible,
.tbtn:focus-visible {
  outline: 1px dashed var(--fg);
  outline-offset: 2px;
}

.tool-status {
  margin-top: 10px;
  color: var(--dim);
  font-size: 0.85rem;
}

.tool-output:empty {
  display: none;
}

.tool-output {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s5);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge-plain { color: var(--muted); border: 1px solid var(--line); }

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kv .dim {
  color: var(--dim);
}

.badge-ok { color: var(--ok-fg); background: rgba(45, 197, 94, 0.12); border: 1px solid rgba(45, 197, 94, 0.35); }

.badge-warn { color: var(--warn-fg); background: rgba(227, 195, 67, 0.12); border: 1px solid rgba(227, 195, 67, 0.35); }

.badge-err { color: var(--err-fg); background: rgba(208, 52, 63, 0.14); border: 1px solid rgba(208, 52, 63, 0.45); }

.note {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
}

.note-warn { color: var(--warn-fg); background: rgba(227, 195, 67, 0.08); border: 1px solid rgba(227, 195, 67, 0.4); }

.note-err { color: var(--err-fg); background: rgba(208, 52, 63, 0.08); border: 1px solid rgba(208, 52, 63, 0.5); }

.calc-input,
.calc-output {
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.95rem;
  line-height: var(--calc-line);
  white-space: pre;
}

.calc-input {
  width: 100%;
  height: 100%;
  resize: none;
  overflow: auto;
  background: transparent;
  color: var(--fg);
  border: 0;
  outline: none;
  caret-color: var(--accent);
}

.calc-output {
  overflow: hidden;
  padding-bottom: 50vh;
  border-left: 1px solid var(--line);
  color: var(--green);
  text-align: right;
  user-select: none;
}

.calc-res {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  border-radius: 4px;
  cursor: copy;
  transition: background-color 0.2s, color 0.2s;
}

.calc-res:hover {
  background: var(--surface-2);
}

.calc-res.is-copied {
  color: var(--bg);
  background: var(--green);
}

.calc-res.is-muted {
  color: var(--dim);
  cursor: default;
}

.calc-meta {
  margin: 0 0 0 auto;
}

@media (max-width: 600px) {
  #calc .tool-head {
    padding-inline: var(--gutter);
    margin-bottom: var(--s3);
  }

  #calc .tool-head .tool-icon,
  #calc .calc-hints {
    display: none;
  }

  #calc .tool-actions {
    padding-inline: var(--gutter);
  }

  .calc-input,
  .calc-output {
    padding: 12px var(--gutter);
    font-size: 0.875rem;
  }

  .calc-output {
    padding-left: 12px;
    padding-bottom: 50vh;
  }
}

.calc-keys {
  display: none;
}

@media (pointer: coarse) {
  .calc-keys.is-open {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 4px;
    padding: 6px max(6px, env(safe-area-inset-left)) 6px max(6px, env(safe-area-inset-right));
    background: var(--glass);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-strong);
  }

  .calc-keys button {
    min-width: 0;
    height: 38px;
    padding: 0;
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 500 1.05rem/1 ui-monospace, "SF Mono", Menlo, monospace;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .calc-keys button:active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .calc-keys button[data-key=" in "] {
    color: var(--accent);
    font-size: 0.9rem;
  }
}

.tool.is-dragover {
  border-color: var(--accent);
  border-style: dashed;
}

.tool.is-dragover::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: grid;
  place-items: center;
  background: var(--glass-strong);
  border: 2px dashed var(--accent);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 1.3rem;
  pointer-events: none;
}

.dig-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  font-size: 0.95rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.dig-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
}

.dig-table th,
.dig-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.dig-table th {
  color: var(--dim);
  font-weight: 400;
  background: var(--well);
}

.dig-table tr:last-child td {
  border-bottom: 0;
}

.dig-table td:last-child {
  color: var(--fg);
  word-break: break-all;
}

.rr {
  color: var(--accent);
}

.cron-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cron-fields:empty {
  display: none;
}

.cron-fields span {
  display: grid;
  justify-items: center;
  min-width: 72px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--dim);
  font-size: 0.7rem;
}

.cron-fields b {
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 500;
}

.cron-examples {
  margin-top: 12px;
}

.cron-human {
  color: var(--fg);
  font-size: 1.05rem;
}

.cron-runs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: run;
}

.cron-runs li {
  padding: 8px 12px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  counter-increment: run;
}

.cron-runs li::before {
  content: counter(run) ". ";
  color: var(--dim);
}

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

.cert-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--well);
  border-bottom: 1px solid var(--line);
}

.cert-card h3 {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.cert-pos {
  color: var(--dim);
  font-size: 0.75rem;
}

.kv {
  display: grid;
  margin: 0;
}

.kv div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}

.kv div:last-child {
  border-bottom: 0;
}

.kv dt {
  color: var(--dim);
  font-size: 0.8rem;
}

.kv dd {
  margin: 0;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .kv div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

.code-edit {
  display: flex;
  overflow: hidden;
  background: var(--well);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.code-edit:focus-within {
  border-color: var(--fg);
}

.code-gutter {
  flex-shrink: 0;
  margin: 0;
  padding: 10px 8px 10px 12px;
  overflow: hidden;
  color: var(--gutter-fg);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--line);
}

.code-gutter .g-err { color: var(--err-fg); font-weight: 700; }

.code-gutter .g-warn { color: var(--warn-fg); }

.field .code-edit textarea {
  border: 0;
  border-radius: 0;
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
}

.lint-ok {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.lint-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.lint-item:hover {
  border-color: var(--line-strong);
}

.json-out {
  max-height: 360px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
}

.kv-copy {
  cursor: copy;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.kv-copy:hover {
  background: var(--surface-2);
}

.gen-list {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.gen-list li {
  padding: 9px 14px;
  overflow-wrap: anywhere;
  background: var(--well);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: copy;
  transition: border-color 0.2s, background-color 0.2s;
}

.gen-list li:hover {
  border-color: var(--fg);
  background: var(--surface-2);
}

.gen-list code {
  font-size: 0.92rem;
  color: var(--fg);
  background: none;
  padding: 0;
}

.gen-row input[type="range"],
.qr-look input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

#gen.is-uuid .gen-row,
#gen.is-uuid .gen-sets {
  opacity: 0.4;
  pointer-events: none;
}

.cidr-split .gen-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}

.jwt-parts {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 760px) {
  .jwt-parts {
    grid-template-columns: 1fr 1fr;
  }
}

.json-view {
  margin: 6px 0 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.j-key { color: var(--fg); }

.j-str { color: var(--green); }

.j-num { color: var(--warn-fg); }

.j-lit { color: var(--accent); }

.is-tabbed .tool {
  margin-top: var(--s4);
}

.tool-nav .chip[aria-current="page"] {
  color: var(--fg);
  background: var(--surface-2);
  border-color: var(--accent);
}

.diff-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s3);
}

.diff-pane {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.diff-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.diff-pane-label {
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.diff-pane-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-pane-file b {
  color: var(--fg);
  font-weight: 500;
}

.diff-pane .tbtn {
  min-height: 30px;
  padding-block: 4px;
}

.diff-pane textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  color: var(--fg);
  background: var(--well);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  resize: vertical;
  tab-size: 4;
}

.diff-pane textarea:focus {
  border-color: var(--fg);
  outline: none;
}

.diff-pane textarea[readonly] {
  color: var(--dim);
}

.diff-drop {
  position: absolute;
  left: clamp(var(--s4), 3vw, 28px);
  right: clamp(var(--s4), 3vw, 28px);
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  pointer-events: none;
}

.diff-drop[hidden] {
  display: none;
}

.diff-drop.is-stacked {
  grid-template-columns: 1fr;
}

.diff-drop > div {
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  background: var(--glass-strong);
  border: 2px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}

.diff-drop b {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
}

.diff-drop span {
  font-size: 0.8rem;
}

.diff-drop > .is-target {
  color: var(--fg);
  border-color: var(--accent);
}

.diff-bar .seg {
  margin-right: var(--s2);
}

.diff-summary:empty {
  display: none;
}

.diff-summary {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s4);
}

.diff-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.diff-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.diff-nav,
.diff-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.diff-nav {
  margin-left: auto;
}

.diff-nav .tbtn {
  min-width: 34px;
  justify-content: center;
  padding-inline: 8px;
}

.diff-pos {
  min-width: 52px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.diff-view:empty {
  display: none;
}

.diff-view {
  margin-top: var(--s3);
}

.diff-scroll {
  max-height: 72vh;
  max-height: 72svh;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  tab-size: 4;
}

.diff-table .d-lnc { width: 4.2em; }

.diff-table .d-signc { width: 1.6em; }

.diff-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-text);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-split thead th + th {
  border-left: 1px solid var(--line);
}

.diff-table td {
  padding: 0 10px;
  vertical-align: top;
}

.diff-table .d-ln {
  padding: 0 8px 0 4px;
  color: var(--gutter-fg);
  text-align: right;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.diff-split .d-ln:nth-child(3) {
  border-left: 1px solid var(--line);
}

.diff-table .d-tx {
  padding-left: calc(10px + 2ch);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-indent: -2ch;
}

.diff-table .d-sign {
  padding: 0;
  text-align: center;
  user-select: none;
}

.diff-table mark {
  color: inherit;
  border-radius: 3px;
}

.diff-split .d-chg .d-tx:nth-child(2) { background: var(--d-del); }

.diff-split .d-chg .d-tx:nth-child(4) { background: var(--d-add); }

.diff-split .d-chg .d-ln:nth-child(1) { background: var(--d-del); }

.diff-split .d-chg .d-ln:nth-child(3) { background: var(--d-add); }

.diff-split .d-tx:nth-child(2) mark { background: var(--d-del-mark); }

.diff-split .d-tx:nth-child(4) mark { background: var(--d-add-mark); }

.diff-split tr.d-chg.d-add td:nth-child(-n + 2),
.diff-split tr.d-chg.d-del td:nth-child(n + 3) {
  background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--line) 5px 6px);
}

.diff-unified .d-del { background: var(--d-del); }

.diff-unified .d-add { background: var(--d-add); }

.diff-unified .d-del mark { background: var(--d-del-mark); }

.diff-unified .d-add mark { background: var(--d-add-mark); }

.diff-unified .d-del .d-sign { color: var(--err-fg); }

.diff-unified .d-add .d-sign { color: var(--ok-fg); }

.diff-table .d-chg {
  cursor: pointer;
}

.diff-table .d-first td {
  border-top: 1px solid transparent;
}

.diff-table .d-current td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.diff-table .d-fold td {
  padding: 0;
}

.diff-table .d-fold button {
  display: block;
  width: 100%;
  padding: 4px 12px;
  color: var(--dim);
  background: var(--surface);
  border: 0;
  border-block: 1px solid var(--line);
  font-family: var(--font-text);
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.diff-table .d-fold button:hover {
  color: var(--fg);
  background: var(--surface-2);
}

@media (max-width: 700px) {
  .diff-inputs {
    grid-template-columns: minmax(0, 1fr);
  }

  .diff-nav {
    margin-left: 0;
  }

  .diff-table {
    font-size: 0.72rem;
  }

  .diff-table .d-lnc {
    width: 3.2em;
  }
}

.rx-pattern {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: end;
}

.rx-input {
  display: flex;
  align-items: stretch;
  background: var(--well);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.rx-input:focus-within {
  border-color: var(--fg);
}

.rx-input i {
  display: grid;
  place-items: center;
  padding: 0 4px;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-style: normal;
}

.field .rx-input input {
  min-width: 0;
  padding-inline: 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.field .rx-input input:focus {
  outline: none;
}

.field .rx-input .rx-flags {
  flex: 0 0 5.5ch;
  color: var(--muted);
}

.rx-flag-row .check {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.rx-view {
  max-height: 340px;
  overflow: auto;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.rx-view pre {
  margin: 0;
  padding: 12px 14px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rx-view mark {
  color: var(--fg);
  border-radius: 3px;
  box-shadow: 0 0 0 1px currentColor inset;
}

.rx-view .rx-m0 {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  box-shadow: 0 -2px 0 var(--accent) inset;
}

.rx-view .rx-m1 {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: 0 -2px 0 color-mix(in srgb, var(--accent) 60%, transparent) inset;
}

.rx-empty {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin: 0 -1px;
  vertical-align: text-bottom;
  background: var(--accent);
}

.rx-table .rx-cell {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rx-table .dim,
.tool-output .dim {
  color: var(--dim);
}

@media (max-width: 560px) {
  .rx-pattern {
    grid-template-columns: minmax(0, 1fr);
  }
}

.qr-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--s5);
  align-items: start;
  margin-top: var(--s4);
}

.qr-form {
  display: grid;
  gap: var(--s4);
}

.qr-wifi {
  display: grid;
  gap: var(--s4);
}

.qr-wifi[hidden],
.qr-form > [hidden] {
  display: none;
}

.qr-look {
  align-items: end;
}

.qr-look input[type="range"] {
  min-height: 44px;
}

.qr-look .field-grow {
  flex-basis: 140px;
}

.qr-color input[type="color"]::-webkit-color-swatch {
  box-shadow: 0 0 0 1px var(--line-strong);
}

.qr-hidden-net {
  align-self: end;
  min-height: 44px;
}

.qr-color input[type="color"] {
  width: 64px;
  height: 44px;
  padding: 4px;
  cursor: pointer;
}

.qr-color input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.qr-color input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.qr-color input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}

.qr-preview {
  display: grid;
  gap: 10px;
  margin: 0;
}

.qr-canvas {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--well);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.qr-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-empty {
  padding: 16px;
  color: var(--dim);
  font-size: 0.85rem;
  text-align: center;
}

.qr-preview .tool-status {
  margin: 0;
  font-size: 0.75rem;
  text-align: center;
}

.qr-warn {
  color: var(--warn-fg);
}

@media (max-width: 700px) {
  .qr-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .qr-preview {
    order: -1;
    width: min(100%, 300px);
    justify-self: center;
  }
}

.color-row {
  align-items: end;
}

.color-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.color-swatch {
  border-right: 1px solid var(--line);
}

.color-swatch span {
  display: block;
  height: 100%;
  min-height: 140px;
  background:
    linear-gradient(var(--swatch), var(--swatch)),
    repeating-conic-gradient(#bbb 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}

.color-kv div {
  grid-template-columns: 120px 1fr;
}

.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.color-contrast {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.color-sample {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.85rem;
}

.color-sample b {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
}

.color-sample .badge {
  margin-left: auto;
}

@media (max-width: 600px) {
  .color-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .color-swatch {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .color-swatch span {
    min-height: 90px;
  }

  .color-contrast {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tool-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

.tool-share {
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 600px) {
  .tool-share {
    position: absolute;
    top: 18px;
    right: 16px;
    min-width: 36px;
    padding-inline: 10px;
  }

  .tool-share span {
    display: none;
  }

  .tool-head:has(.tool-share) h2 {
    padding-right: 44px;
  }
}

.color-pal {
  margin-top: var(--s5);
}

.color-pal[hidden] {
  display: none;
}

.color-pal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.color-pal-head > div {
  flex: 1 1 300px;
}

.color-pal-head h3 {
  font-size: 1rem;
}

.color-pal-head .tool-status {
  margin-top: 4px;
}

.color-pal-name {
  flex: 0 1 180px;
}

.color-shades {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.color-shade {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  min-height: 92px;
  padding: 8px 6px;
  color: #fff;
  font-family: var(--font-text);
  font-size: 0.68rem;
  text-align: left;
  border: 0;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.color-shade.is-light {
  color: #111;
}

.color-shade b {
  font-size: 0.8rem;
}

.color-shade span {
  overflow: hidden;
  opacity: 0.8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-shade.is-base::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.color-shade:hover {
  z-index: 1;
  box-shadow: 0 0 0 2px var(--fg);
}

.color-shade:focus-visible {
  z-index: 1;
  outline: 2px dashed var(--fg);
  outline-offset: -4px;
}

@media (max-width: 700px) {
  .color-shades {
    grid-template-columns: minmax(0, 1fr);
  }

  .color-shade {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 8px 14px 8px 28px;
    font-size: 0.78rem;
  }

  .color-shade.is-base::before {
    top: 50%;
    left: 12px;
    margin-top: -4px;
  }
}

.tool-sub,
.url-params h3 {
  margin: var(--s6) 0 var(--s3);
  font-size: 1rem;
}

.url-params h3 .dim {
  color: var(--dim);
  font-family: var(--font-text);
  font-size: 0.85rem;
}

.url-params[hidden] {
  display: none;
}

.url-rows {
  display: grid;
  gap: var(--s2);
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto;
  gap: var(--s2);
}

.url-row input {
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--fg);
  font-size: 0.85rem;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.url-row input:focus {
  border-color: var(--line-strong);
  outline: none;
}

.url-row.is-tracking input {
  color: var(--warn-fg);
  border-style: dashed;
}

.url-del {
  min-height: 40px;
  padding-inline: 11px;
}

.url-del svg {
  color: var(--dim);
}

@media (max-width: 600px) {
  .url-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .url-row [data-v] {
    grid-column: 1;
  }

  .url-row .url-del {
    grid-row: 1 / 3;
    grid-column: 2;
  }
}

.text-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s3);
}

.text-stats div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
}

.text-stats dt {
  color: var(--dim);
}

.text-stats dd {
  margin: 0;
  color: var(--fg);
}

.text-stats [title] {
  cursor: help;
}

.text-ops {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s4);
}

.text-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.text-group > span {
  width: 52px;
  color: var(--dim);
  font-size: 0.8rem;
}

.text-group .tbtn {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 0.8rem;
}

.tbtn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

@media (max-width: 600px) {
  .text-group > span {
    width: 100%;
  }
}

.img-drop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s5) var(--s4);
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  background: var(--well);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.img-drop:hover,
.img-drop:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.img-drop > svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.img-drop kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-text);
  font-size: 0.75rem;
}

@media (hover: none) {
  .img-paste {
    display: none;
  }
}

.has-image .img-drop {
  padding-block: var(--s3);
}

.tool > .img-drop + .img-controls {
  margin-top: var(--s4);
}

.img-controls .seg {
  width: max-content;
}

.img-controls .seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.img-controls input[type="range"] {
  min-height: 40px;
  padding: 0;
  background: none;
  border: 0;
  accent-color: var(--accent);
}

.img-controls input[type="range"]:disabled {
  opacity: 0.4;
}

.img-width {
  flex: 0 1 150px;
}

.img-view {
  margin-top: var(--s5);
}

.img-view[hidden] {
  display: none;
}

.img-view.is-actual {
  max-height: 75vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.img-stage {
  --split: 50%;
  position: relative;
  margin-inline: auto;
  overflow: hidden;
  background: repeating-conic-gradient(#bbb 0 25%, #fff 0 50%) 0 0 / 16px 16px padding-box;
  border: 1px solid var(--line);
  border-radius: 12px;
  user-select: none;
}

.img-view.is-actual .img-stage {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.img-stage img {
  display: block;
  width: 100%;
  height: 100%;
}

.img-stage [data-img-after] {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--split));
}

.img-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.img-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.img-split {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.img-split:focus-visible + .img-handle,
.img-stage:has(.img-split:focus-visible) .img-handle::after {
  outline: 2px dashed #fff;
}

.img-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  color: #fff;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 6px;
  pointer-events: none;
}

.img-tag-after {
  right: 10px;
  left: auto;
}

.img-tag-after:empty {
  display: none;
}

.img-actions {
  justify-content: flex-start;
}

.chmod-grid {
  display: grid;
  grid-template-columns: 110px repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 10px var(--s3);
  margin-top: var(--s4);
  padding: var(--s4);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chmod-col {
  color: var(--dim);
  font-size: 0.78rem;
}

.chmod-col i {
  font-style: normal;
}

.chmod-who {
  color: var(--fg);
  font-size: 0.88rem;
}

.chmod-who code,
.chmod-col code {
  color: var(--dim);
}

.chmod-notes {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.85rem;
}

.chmod-notes b {
  color: var(--fg);
}

@media (max-width: 600px) {
  .chmod-grid {
    grid-template-columns: 64px repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
    padding: 12px;
  }

  .chmod-who code,
  .chmod-col code {
    display: none;
  }

  .chmod-grid .chmod-name,
  .chmod-col i {
    display: none;
  }

  .chmod-col {
    font-size: 0.72rem;
  }

  .chmod-grid .check {
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 0.75rem;
  }
}
