:root {
  --bg: #0f1117;
  --surface: #171a23;
  --border: #2a2e3a;
  --text: #e5e7eb;
  --muted: #9096a8;
  --accent: #5eead4;
  --accent-dim: #2dd4bf;
  --error: #f87171;
  --warn: #fbbf24;
  --special: #c084fc;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  text-align: center;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--muted);
}

.not-found {
  padding: 2rem 0 3rem;
}

.not-found-code {
  margin: 0;
  font-size: 5rem;
  font-weight: 700;
  font-family: "SFMono-Regular", Consolas, monospace;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.not-found .back-link {
  margin-top: 1rem;
  font-size: 1rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.tool-icon {
  font-size: 1.75rem;
}

.tool-card h2 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.1rem;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.tool-description {
  color: var(--muted);
  margin-top: -0.5rem;
}

.tool-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.tool-form label {
  width: 100%;
  font-size: 0.85rem;
  color: var(--muted);
}

.tool-form input {
  flex: 1;
  min-width: 220px;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.tool-form input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.tool-form button {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #0b1013;
  font-weight: 600;
  cursor: pointer;
}

.tool-form button:hover {
  background: var(--accent-dim);
}

.tool-form-stack {
  flex-direction: column;
  align-items: stretch;
}

.tool-form textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: "SFMono-Regular", Consolas, monospace;
  resize: vertical;
}

.tool-form textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.tool-form-stack button {
  align-self: flex-start;
}

.tool-form-actions {
  display: flex;
  gap: 0.75rem;
  align-self: flex-start;
}

.button-secondary {
  padding: 0.6rem 1.25rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.button-secondary:hover {
  border-color: var(--accent-dim);
  color: var(--accent-dim);
}

.button-secondary.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: var(--muted);
}

.button-secondary.is-disabled:hover {
  border-color: var(--border);
  color: var(--muted);
}

.error {
  color: var(--error);
  font-weight: 500;
}

.tool-form textarea.error {
  border-color: var(--error);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.result-table th,
.result-table td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.result-table tr:last-child th,
.result-table tr:last-child td {
  border-bottom: none;
}

.result-table th {
  color: var(--muted);
  font-weight: 500;
  width: 45%;
}

.result-table td {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.site-footer a {
  color: var(--muted);
}

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

.about-section {
  margin-bottom: 2.5rem;
}

.about-section h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.about-section a {
  color: var(--accent);
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.faq-item summary {
  cursor: pointer;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
}

.faq-item summary:hover {
  color: var(--accent);
}

.faq-item p {
  margin: 0;
  padding: 0 1.25rem 1rem;
  color: var(--muted);
}

.psk-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

.psk-controls label {
  color: var(--muted);
  font-size: 0.9rem;
}

.psk-controls input[type="number"] {
  width: 4.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
}

.psk-controls input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.psk-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.psk-shortcuts label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.char-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}

.char-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.char-row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: 6.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.char-cell {
  min-width: 1.9rem;
  padding: 0.3rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  cursor: pointer;
}

.char-cell:hover {
  border-color: var(--accent-dim);
}

.char-cell.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1013;
  font-weight: 600;
}

.psk-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
}

.psk-result label {
  color: var(--muted);
  font-size: 0.9rem;
}

.psk-result input#psk {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.psk-controls .generate-btn,
.psk-result button {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #0b1013;
  font-weight: 600;
  cursor: pointer;
}

.psk-controls .generate-btn:hover,
.psk-result button:hover {
  background: var(--accent-dim);
}

.psk-table-wrap {
  overflow-x: auto;
}

table.psk-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 1rem 0 2rem;
}

table.psk-table th,
table.psk-table td {
  text-align: left;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

table.psk-table th {
  color: var(--muted);
  font-weight: 500;
  background: var(--bg);
}

table.psk-table td:first-child {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 600;
  text-align: center;
}

table.psk-table tr:last-child td {
  border-bottom: none;
}

table.psk-table td span {
  color: var(--accent);
  font-weight: 700;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.mac-table-wrap {
  overflow-x: auto;
}

table.mac-table {
  /* Without this, table-layout: auto treats column widths below as
     hints only and redistributes leftover space (the table is
     width: 100%) across columns instead of giving it all to Vendor. */
  table-layout: fixed;
}

table.mac-table td {
   vertical-align: top;
}

table.mac-table th:first-child,
table.mac-table td:first-child {
  width: 2.5rem;
  color: var(--muted);
}

/* OUI column is max 6 characters */
table.mac-table th:nth-child(2),
table.mac-table td:nth-child(2) {
  width: 8ch;
  white-space: nowrap;
}

/* Input column is max 12 characters and 5 separators (e.g., : or -) */
table.mac-table th:nth-child(3),
table.mac-table td:nth-child(3) {
  width: 17ch;
  white-space: nowrap;
}

/* Vendor gets whatever's left. Without this, .result-table th's
   width: 45% (meant for the 2-column subnet-calculator table) still
   applies to this header, and its mismatch against the fixed-width
   columns above makes table-layout: fixed scale all of them back up. */
table.mac-table th:nth-child(4),
table.mac-table td:nth-child(4) {
  width: auto;
}

/*
.mac-vendor {
  white-space: nowrap;
}
*/

.mac-vendor.mac-found {
  color: var(--text);
}

.mac-vendor.mac-unknown,
.mac-vendor.mac-invalid {
  color: var(--error);
}

.mac-vendor.mac-special {
  color: var(--special);
}

.mac-vendor.mac-local {
  color: var(--warn);
}

.note-marker {
  color: var(--muted);
  text-decoration: underline dotted;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  /* Superscript look via a relative offset rather than <sup> or
     vertical-align: super, neither of which keeps the line's height
     from growing to fit the raised box. */
  position: relative;
  top: -0.5em;
  margin-left: 0.15em;
}

.note-marker:hover {
  color: var(--accent-dim);
}

/* Calix Operation Condition Checker */

.tool-form label.cond-strict {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Undo .tool-form input's text-field sizing for the checkbox. */
.tool-form label.cond-strict input {
  flex: none;
  min-width: 0;
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.cond-verdict {
  font-weight: 700;
  font-size: 1.1rem;
}

.cond-verdict.cond-ok {
  color: var(--accent);
}

.cond-verdict.cond-bad {
  color: var(--error);
}

.cond-warning {
  color: var(--warn);
}

/* Caret rows line up under the expression by character column, so this
   must stay monospace and never wrap; long conditions scroll instead. */
.cond-report {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.4;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  color: var(--muted);
}

.cond-report .cond-caret {
  font-weight: 700;
}

.cond-report .cond-error {
  color: var(--error);
}

.cond-report .cond-warning {
  color: var(--warn);
}

.cond-report .cond-note {
  color: var(--accent-dim);
}

.cond-report .cond-op {
  color: var(--special);
  font-weight: 700;
}

.cond-report .cond-bool-true {
  color: var(--accent);
  font-weight: 700;
}

.cond-report .cond-bool-false {
  color: var(--error);
  font-weight: 700;
}

.my-ip-table {
  margin-bottom: 1rem;
}

.my-ip-table th {
  width: 9rem;
  vertical-align: top;
}

.my-ip-tag {
  display: block;
  font-size: 0.75rem;
  color: var(--accent-dim);
}

.my-ip-table td > * {
  display: block;
}

.my-ip-table td > [hidden],
.my-ip-hostname:empty {
  display: none;
}

.my-ip-address {
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.my-ip-found .my-ip-address {
  color: var(--accent);
}

.my-ip-pending .my-ip-address,
.my-ip-missing .my-ip-address {
  color: var(--muted);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.my-ip-hostname {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.my-ip-whois {
  color: var(--accent);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
}
