/* === DevToolbox — Dark-mode-first design === */

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

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-input: #0d0d0d;
  --border: #222222;
  --border-focus: #0ea5e9;
  --text-primary: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-muted: #666666;
  --accent: #0ea5e9;
  --accent-hover: #38bdf8;
  --accent-dim: rgba(14, 165, 233, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #eab308;
  --warning-bg: rgba(234, 179, 8, 0.1);
  --radius: 8px;
  --radius-sm: 4px;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.5);
  --transition: 150ms ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === NAV === */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 1rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-links a.nav-coffee {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #FFDD00;
  color: #000;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition);
}

.nav-links a.nav-coffee:hover {
  background: #ffe84d;
  transform: translateY(-1px);
  color: #000;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* === MILESTONE BANNER === */
.milestone-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--success-bg);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.milestone-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* === MAIN CONTENT === */
.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* === LANDING PAGE === */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

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

.hero p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  max-width: 560px;
  margin: 0 auto;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-lg);
  transform: translateY(-2px);
}

.tool-card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.tool-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.tool-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* === TOOL PAGES === */
.tool-header {
  margin-bottom: 1.5rem;
}

.tool-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.tool-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

textarea,
input[type="text"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 1rem;
  resize: vertical;
  transition: border-color var(--transition);
  line-height: 1.6;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

textarea {
  min-height: 300px;
}

textarea.tall {
  min-height: 400px;
}

/* === BUTTONS === */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.325rem 0.625rem;
}

/* === OPTION CONTROLS === */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.control-group label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  padding: 0.325rem 0.5rem;
  cursor: pointer;
}

select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Checkbox styled as toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.toggle-wrap input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-wrap input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

.toggle-wrap input[type="checkbox"]:checked {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-wrap input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* === MESSAGES === */
.msg {
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  display: none;
}

.msg.show {
  display: block;
}

.msg-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.msg-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.msg-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

/* === STATUS BAR === */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding-top: 0.5rem;
}

/* === OUTPUT AREA === */
.output-area {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  min-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: var(--text-primary);
}

/* === JSON SYNTAX HIGHLIGHTING === */
.syn-key { color: #7dd3fc; }
.syn-str { color: #86efac; }
.syn-num { color: #fbbf24; }
.syn-bool { color: #c084fc; }
.syn-null { color: #f87171; }
.syn-brace { color: var(--text-muted); }

/* === JSON TREE VIEW === */
.tree-node {
  padding-left: 1.25rem;
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
  color: var(--accent);
}

.tree-toggle::before {
  content: "\25BC ";
  display: inline-block;
  font-size: 0.65rem;
  transition: transform var(--transition);
}

.tree-toggle.collapsed::before {
  transform: rotate(-90deg);
}

.tree-key { color: #7dd3fc; }
.tree-str { color: #86efac; }
.tree-num { color: #fbbf24; }
.tree-bool { color: #c084fc; }
.tree-null { color: #f87171; }

/* === JWT SECTIONS === */
.jwt-parts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.jwt-section {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.jwt-section-header {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.jwt-section-header.header-part { background: rgba(251, 191, 36, 0.08); color: #fbbf24; }
.jwt-section-header.payload-part { background: rgba(134, 239, 172, 0.08); color: #86efac; }
.jwt-section-header.signature-part { background: rgba(248, 113, 113, 0.08); color: #f87171; }

.jwt-section-body {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.jwt-colored {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-all;
  line-height: 1.8;
}

.jwt-colored .jwt-c-header { color: #fbbf24; }
.jwt-colored .jwt-c-payload { color: #86efac; }
.jwt-colored .jwt-c-sig { color: #f87171; }
.jwt-colored .jwt-c-dot { color: var(--text-muted); }

.jwt-claims {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.jwt-claim {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  padding: 0.325rem 0.625rem;
  border-radius: var(--radius-sm);
}

.jwt-claim.expired {
  background: var(--error-bg);
  color: var(--error);
}

.jwt-claim.valid {
  background: var(--success-bg);
  color: var(--success);
}

.jwt-claim.neutral {
  background: var(--accent-dim);
  color: var(--accent);
}

/* === REGEX === */
.regex-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.regex-input-row input[type="text"] {
  flex: 1;
}

.regex-flags {
  display: flex;
  gap: 0.25rem;
}

.flag-btn {
  width: 34px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.flag-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.regex-highlight mark {
  background: rgba(14, 165, 233, 0.3);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 1px;
}

.regex-highlight mark:nth-child(even) {
  background: rgba(168, 85, 247, 0.3);
}

.pattern-lib {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.pattern-btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition);
}

.pattern-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.match-results {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  max-height: 250px;
  overflow-y: auto;
}

.match-item {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.match-item:last-child {
  border-bottom: none;
}

.match-index {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.match-value {
  color: var(--accent);
}

.match-group {
  color: var(--text-secondary);
  padding-left: 1rem;
}

/* === DRAG & DROP ZONE === */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all var(--transition);
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-secondary);
}

.drop-zone input[type="file"] {
  display: none;
}

/* === FOOTER === */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* === KEYBOARD SHORTCUT HINT === */
.shortcut-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.25rem;
    display: none;
    z-index: 99;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    width: 100%;
    font-size: 1rem;
    border-radius: var(--radius);
    min-height: 48px;
  }

  .nav-links a:hover,
  .nav-links a:active {
    background: var(--bg-tertiary);
  }

  .nav-links a.nav-coffee {
    justify-content: center;
    margin-top: 0.25rem;
    font-size: 1rem;
    padding: 0.875rem 1rem;
    min-height: 48px;
  }

  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    border-radius: var(--radius-sm);
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 200px;
  }

  .regex-input-row {
    flex-direction: column;
  }

  .regex-flags {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 1rem;
  }

  .hero {
    padding: 2rem 0 1.5rem;
  }
}

/* === FULL-WIDTH SINGLE PANEL === */
.tool-full {
  max-width: 800px;
}

/* === SCROLLBAR STYLING === */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Tab controls */
.tab-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

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

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