/* utils.onapage.net — shared brand + layout */
:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-2: #1a2235;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --dim: #6b7280;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.15);
  --amber: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --mono: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); }

/* === Layout === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(17, 24, 39, 0.9);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}
.brand-mark {
  width: 28px; height: 28px;
  background: var(--cyan);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--bg);
  font-weight: 700;
  font-family: var(--mono);
}
.brand-text {
  font-size: 0.95em;
}
.brand-text .domain { color: var(--muted); font-weight: 400; }

.tool-nav {
  display: flex; align-items: center; gap: 16px;
  font-size: 0.85em;
  color: var(--muted);
}
.tool-nav .current { color: var(--text); font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 64px;
  text-align: center;
  font-size: 0.8em;
  color: var(--dim);
}
.site-footer a { color: var(--muted); }

/* === Index (tool list) === */
.hero {
  padding: 80px 0 48px;
  text-align: center;
}
.hero h1 {
  font-size: 2.4em;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--cyan) 0%, #67e8f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero .sub {
  color: var(--muted);
  font-size: 1.05em;
  max-width: 540px;
  margin: 0 auto 32px;
}
.hero .badges {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 16px;
}
.badge {
  font-size: 0.7em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.cyan { background: var(--cyan-glow); border-color: var(--cyan); color: var(--cyan); }
.badge.amber { background: rgba(245, 158, 11, 0.1); border-color: var(--amber); color: var(--amber); }
.badge.green { background: rgba(16, 185, 129, 0.1); border-color: var(--green); color: var(--green); }
.badge-pending { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.badge-valid { background: rgba(16, 185, 129, 0.15); border-color: var(--green); color: var(--green); }
.badge-invalid { background: rgba(239, 68, 68, 0.15); border-color: var(--red); color: var(--red); }
.badge-warn { background: rgba(245, 158, 11, 0.15); border-color: var(--amber); color: var(--amber); }
.pill-red { background: rgba(239, 68, 68, 0.2); color: var(--red); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 32px 0;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  display: block;
  color: var(--text);
  transition: all 0.15s ease;
}
.tool-card:hover {
  border-color: var(--cyan);
  background: var(--surface-2);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(6, 182, 212, 0.08);
}
.tool-card h2 {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tool-card .ico {
  font-size: 1.3em;
  line-height: 1;
}
.tool-card .desc {
  color: var(--muted);
  font-size: 0.88em;
  margin-top: 8px;
  line-height: 1.5;
}
.tool-card .meta {
  margin-top: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.coming-soon {
  opacity: 0.5;
  pointer-events: none;
}
.coming-soon::after {
  content: 'COMING SOON';
  display: block;
  font-size: 0.65em;
  letter-spacing: 0.1em;
  color: var(--amber);
  margin-top: 8px;
}

/* === Tool pages (2-pane) === */
.tool-page { padding: 24px 0; }
.tool-page h1 {
  font-size: 1.5em;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool-page .sub {
  color: var(--muted);
  font-size: 0.9em;
  margin-bottom: 20px;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 240px);
  min-height: 480px;
}
@media (max-width: 768px) {
  .editor-grid { grid-template-columns: 1fr; height: auto; }
}

.pane {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.8em;
  color: var(--muted);
  font-weight: 500;
}
.pane-header .label { display: flex; align-items: center; gap: 6px; }
.pane-header .actions { display: flex; gap: 6px; }

.pane-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane-body textarea {
  flex: 1;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 14px;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.55;
  resize: none;
  outline: none;
  min-height: 320px;
}
.pane-body .output {
  flex: 1;
  overflow: auto;
  padding: 14px;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.55;
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Buttons === */
button, .btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.8em;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 500;
  transition: all 0.12s;
}
button:hover, .btn:hover { border-color: var(--cyan); color: var(--cyan); }
button.primary, .btn.primary { background: var(--cyan); border-color: var(--cyan); color: var(--bg); }
button.primary:hover, .btn.primary:hover { background: #22d3ee; border-color: #22d3ee; color: var(--bg); }
button.danger, .btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.danger:hover, .btn.danger:hover { background: var(--red); color: var(--bg); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover, .btn.ghost:hover { color: var(--cyan); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* === Status / errors === */
.status {
  padding: 6px 14px;
  font-size: 0.72em;
  color: var(--muted);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}
.status.valid { color: var(--green); }
.status.error { color: var(--red); }
.status.warn { color: var(--amber); }
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.85em;
  font-family: var(--mono);
  white-space: pre-wrap;
}

/* === JSON tree view === */
.json-tree { font-family: var(--mono); font-size: 0.85em; line-height: 1.7; padding: 12px; }
.json-tree .json-root > .json-children {
  list-style: none;
  padding-left: 20px;
  border-left: 1px dashed var(--border);
  margin-left: 6px;
}
.json-tree .json-children {
  list-style: none;
  padding-left: 20px;
}
.json-tree .key { color: #93c5fd; }
.json-tree .string { color: #86efac; }
.json-tree .number { color: #fbbf24; }
.json-tree .boolean { color: #f0abfc; }
.json-tree .null { color: var(--dim); }
.json-tree .summary { color: var(--dim); font-size: 0.9em; font-style: italic; }
.json-tree .toggle {
  display: inline-block;
  width: 12px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  text-align: center;
  outline: none;
}
.json-tree .toggle:focus { color: var(--cyan); }
.json-tree .toggle::before { content: '▼'; }
.json-tree .toggle.collapsed::before { content: '▶'; }
.json-tree .json-row {
  padding: 2px 6px;
  border-radius: 3px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}
.json-tree .json-row:hover { background: var(--surface-2); }
.json-tree .json-li {
  padding: 1px 6px;
  border-radius: 3px;
}
.json-tree .json-li:hover { background: var(--surface-2); }
.json-tree .bracket { color: var(--muted); }

/* === CSV table === */
.csv-table-wrap { flex: 1; overflow: auto; background: var(--bg); }
.csv-table { border-collapse: collapse; font-size: 0.8em; width: 100%; }
.csv-table th, .csv-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csv-table th {
  background: var(--surface-2);
  color: var(--cyan);
  font-weight: 600;
  cursor: pointer;
  position: sticky; top: 0;
  user-select: none;
}
.csv-table th:hover { color: #67e8f9; }
.csv-table th .arrow { opacity: 0.4; margin-left: 4px; font-size: 0.7em; }
.csv-table th.sorted .arrow { opacity: 1; color: var(--amber); }
.csv-table td { color: var(--text); }
.csv-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
.csv-table tr:hover td { background: var(--cyan-glow); }
.csv-empty { color: var(--dim); padding: 20px; text-align: center; font-size: 0.85em; }
.csv-table mark {
  background: rgba(245, 158, 11, 0.35);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}
.csv-table .th-content { vertical-align: middle; }
.csv-table th.sorted { color: var(--amber); }
.csv-table th.sorted .arrow { color: var(--amber); opacity: 1; }

/* === Full-page modal === */
.fullpage-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.fullpage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}
.fullpage-title {
  font-size: 1em;
  font-weight: 600;
  color: var(--cyan);
}
.fullpage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fullpage-status {
  font-size: 0.8em;
  color: var(--muted);
  font-family: var(--mono);
  padding: 0 8px;
}
.fullpage-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 16px 24px;
}
.fullpage-table-wrap .csv-table {
  font-size: 0.95em;
}
.fullpage-table-wrap .csv-table th,
.fullpage-table-wrap .csv-table td {
  padding: 10px 14px;
  max-width: 480px;
}
.fullpage-table-wrap .csv-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.hint { color: var(--dim); font-size: 0.85em; font-style: italic; }

/* === JWT === */
.jwt-section {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.jwt-section:last-child { border-bottom: none; }
.jwt-section h3 {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.jwt-claims { font-family: var(--mono); font-size: 0.8em; }
.jwt-claim {
  display: flex;
  gap: 12px;
  padding: 3px 0;
  align-items: baseline;
}
.jwt-claim .name { color: #93c5fd; min-width: 100px; }
.jwt-claim .value { color: var(--text); word-break: break-all; }
.jwt-claim .desc { color: var(--dim); font-size: 0.9em; margin-left: auto; }
.jwt-claim.expired .value { color: var(--red); }
.jwt-claim .pill {
  display: inline-block;
  font-size: 0.7em;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--cyan-glow);
  color: var(--cyan);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.jwt-signature {
  font-family: var(--mono);
  font-size: 0.75em;
  color: var(--muted);
  padding: 12px;
  background: var(--bg);
  border-radius: 4px;
  word-break: break-all;
  margin-top: 8px;
  max-height: 100px;
  overflow: auto;
}
.jwt-raw { font-family: var(--mono); font-size: 0.75em; word-break: break-all; color: var(--muted); }

/* === Drop zone === */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85em;
  margin: 8px 14px;
  transition: all 0.15s;
}
.drop-zone.dragover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-glow); }

/* === Footer note === */
.note {
  background: var(--surface-2);
  border-left: 3px solid var(--cyan);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--muted);
  margin: 16px 0;
}
.note strong { color: var(--text); }

/* === Search box === */
.search-box {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 0.85em;
  border-radius: 5px;
  outline: none;
  margin-bottom: 8px;
}
.search-box:focus { border-color: var(--cyan); }
