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

:root {
  --bg: #0f0f11;
  --surface: #1a1a1f;
  --surface2: #242429;
  --border: #2e2e36;
  --text: #e8e8f0;
  --muted: #888896;
  --accent: #7c6af7;
  --accent-h: #9080ff;
  --green: #4caf7d;
  --red: #e05c6e;
  --green-bg: #162a1f;
  --red-bg: #2a1219;
  --r: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  height: 54px;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.logo { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.logo span { color: var(--accent); }

nav { display: flex; gap: 2px; }

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.tab-btn:hover,
.tab-btn.active { color: var(--text); background: var(--surface2); }

/* ── Layout ── */
main { padding: 36px 28px; max-width: 1080px; margin: 0 auto; }
.tool { display: none; }
.tool.active { display: block; }

/* ── Shared: buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 11px 36px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  min-width: 110px;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 20px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { color: var(--text); border-color: #55556a; }

/* ── Shared: page heading ── */
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-sub   { font-size: 13.5px; color: var(--muted); margin-bottom: 28px; }

/* ── Shared: input group ── */
.input-group { display: flex; flex-direction: column; gap: 8px; }

.input-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  padding: 14px;
  resize: vertical;
  min-height: 190px;
  outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: #3e3e4a; }

/* ── Shared: toggle ── */
.toggle-row   { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toggle-label { font-size: 12px; color: var(--muted); }

.toggle {
  appearance: none;
  width: 32px; height: 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: all .2s;
}
.toggle:checked { background: var(--accent); border-color: var(--accent); }
.toggle:checked::after { left: 16px; background: #fff; }

/* ═══════════════════════════════════════
   POMODORO
═══════════════════════════════════════ */
.pomo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding-top: 12px;
}

.mode-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
  gap: 2px;
}

.mode-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 22px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--accent); color: #fff; }

.timer-ring { position: relative; width: 260px; height: 260px; }
.timer-ring svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }

.ring-bg    { fill: none; stroke: var(--surface2); stroke-width: 6; }
.ring-track {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.timer-display {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
}

.timer-time  { font-size: 58px; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.timer-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

.pomo-controls { display: flex; gap: 10px; }

.session-dots { display: flex; gap: 10px; }

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  transition: all .25s;
}
.dot.done    { background: var(--accent); border-color: var(--accent); }
.dot.current { border-color: var(--accent); }

.session-info { font-size: 13px; color: var(--muted); }

/* ═══════════════════════════════════════
   TEXT DIFF
═══════════════════════════════════════ */
.diff-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.diff-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }

.diff-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.diff-result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.diff-stats { display: flex; gap: 10px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-add { background: var(--green-bg); color: var(--green); }
.badge-rem { background: var(--red-bg);   color: var(--red);   }

.diff-lines {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
}

.diff-line { display: flex; min-height: 26px; }
.diff-line:hover { filter: brightness(1.12); }

.line-num {
  min-width: 46px;
  text-align: right;
  padding: 2px 10px 2px 4px;
  color: var(--muted);
  user-select: none;
  font-size: 11px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.line-sign {
  min-width: 22px;
  text-align: center;
  padding: 2px 0;
  flex-shrink: 0;
  font-weight: 700;
}

.line-content {
  padding: 2px 14px;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line.added     { background: var(--green-bg); }
.diff-line.added     .line-sign { color: var(--green); }
.diff-line.removed   { background: var(--red-bg); }
.diff-line.removed   .line-sign { color: var(--red); }
.diff-line.unchanged .line-sign { color: transparent; }

.diff-separator {
  padding: 4px 16px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.diff-empty {
  padding: 52px;
  text-align: center;
  color: #3e3e4a;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══════════════════════════════════════
   JSON FORMATTER
═══════════════════════════════════════ */
.json-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

.json-stats { display: flex; gap: 6px; margin-left: auto; }

.json-stat-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--muted);
}

.json-error {
  display: none;
  background: var(--red-bg);
  border: 1px solid #6b2530;
  border-radius: var(--r);
  padding: 11px 16px;
  margin-bottom: 16px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  color: var(--red);
}

.json-output-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.json-output-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.json-copy-btn { padding: 4px 14px; font-size: 12px; }

.json-output {
  margin: 0;
  padding: 16px 18px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
  min-height: 120px;
  max-height: 540px;
  overflow-y: auto;
  color: var(--text);
}

.json-placeholder { color: #3e3e4a; }

.j-key  { color: #a78bfa; }
.j-str  { color: #6ee7a0; }
.j-num  { color: #f9a74b; }
.j-bool { color: #60b8f8; }
.j-null { color: #e05c6e; }

/* ═══════════════════════════════════════
   REGEX TESTER
═══════════════════════════════════════ */
.rx-pattern-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.rx-pattern-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color .15s;
}
.rx-pattern-wrap:focus-within { border-color: var(--accent); }

.rx-slash {
  padding: 0 10px;
  color: var(--muted);
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 17px;
  user-select: none;
  flex-shrink: 0;
}

.rx-pattern-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 14px;
  padding: 11px 0;
  outline: none;
  min-width: 0;
}

.rx-flags { display: flex; gap: 2px; padding-right: 8px; flex-shrink: 0; }

.rx-flag {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  transition: all .15s;
}
.rx-flag:hover { color: var(--text); background: var(--surface2); }
.rx-flag.active { color: var(--accent); background: rgba(124, 106, 247, 0.15); }

.rx-error {
  display: none;
  background: var(--red-bg);
  border: 1px solid #6b2530;
  border-radius: var(--r);
  padding: 11px 16px;
  margin-bottom: 16px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  color: var(--red);
}

.rx-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 16px;
}

.rx-output-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.rx-count {
  display: none;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
}

.rx-highlight {
  margin: 0;
  padding: 14px 18px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  color: var(--text);
}

.rx-highlight mark {
  background: rgba(124, 106, 247, 0.3);
  color: #d4c8ff;
  border-radius: 2px;
  padding: 0 1px;
}

.rx-placeholder { color: #3e3e4a; }

.rx-match-list {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}

.rx-match-list-header {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.rx-match-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
}
.rx-match-item:last-child { border-bottom: none; }
.rx-match-item:hover { background: var(--surface2); }

.rx-match-num  { color: var(--muted); font-size: 11px; min-width: 28px; }
.rx-match-val  { color: #c4b5fd; }
.rx-match-idx  { color: var(--muted); font-size: 11px; margin-right: auto; }

.rx-match-groups { display: flex; gap: 6px; flex-wrap: wrap; }

.rx-group {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--muted);
}
.rx-group span { color: var(--text); }

/* ═══════════════════════════════════════
   MARKDOWN PREVIEWER
═══════════════════════════════════════ */
.md-actions { display: flex; gap: 10px; margin-bottom: 16px; }

.md-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 220px);
  min-height: 480px;
}

.md-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}

.md-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.md-editor {
  flex: 1;
  resize: none;
  min-height: 0;
  border: none !important;
  border-radius: 0 !important;
  padding: 16px 18px !important;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
  background: transparent !important;
}

.md-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.md-placeholder { color: #3e3e4a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* Preview typography */
.md-preview h1,
.md-preview h2,
.md-preview h3,
.md-preview h4,
.md-preview h5,
.md-preview h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.25;
  color: var(--text);
}
.md-preview h1 { font-size: 1.9em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.md-preview h2 { font-size: 1.45em; padding-bottom: 0.2em; border-bottom: 1px solid var(--border); }
.md-preview h3 { font-size: 1.2em; }
.md-preview h4 { font-size: 1em; }
.md-preview h1:first-child,
.md-preview h2:first-child { margin-top: 0; }

.md-preview p  { margin: 0.85em 0; }
.md-preview p:first-child { margin-top: 0; }

.md-preview a  { color: var(--accent); text-decoration: none; }
.md-preview a:hover { text-decoration: underline; }

.md-preview strong { font-weight: 700; }
.md-preview em     { font-style: italic; }
.md-preview del    { color: var(--muted); }

.md-preview code {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}

.md-preview pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1em 0;
}
.md-preview pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.6;
}

.md-preview blockquote {
  border-left: 3px solid var(--accent);
  margin: 1em 0;
  padding: 4px 0 4px 18px;
  color: var(--muted);
}

.md-preview ul,
.md-preview ol  { margin: 0.8em 0; padding-left: 1.8em; }
.md-preview li  { margin: 0.3em 0; }

.md-preview hr  {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.md-preview img { max-width: 100%; border-radius: var(--r); }

.md-preview table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 13px; }
.md-preview th,
.md-preview td   { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md-preview th   { background: var(--surface2); font-weight: 600; }

/* ═══════════════════════════════════════
   BASE64
═══════════════════════════════════════ */
.b64-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.b64-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

.b64-file-row input[type="file"] { display: none; }

.output-textarea {
  background: var(--surface2) !important;
  color: var(--muted) !important;
  cursor: default;
}

/* ═══════════════════════════════════════
   URL ENCODER
═══════════════════════════════════════ */
.url-params {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-top: 16px;
}

.url-params-header {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
}

.url-params-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  background: var(--surface);
}
.url-params-table th,
.url-params-table td {
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.url-params-table tr:last-child td { border-bottom: none; }
.url-params-table th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.url-params-table td:first-child { color: var(--accent); }

/* ═══════════════════════════════════════
   HASH GENERATOR
═══════════════════════════════════════ */
.hash-results {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}

.hash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12px;
}
.hash-row:last-child { border-bottom: none; }

.hash-algo {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  min-width: 62px;
  flex-shrink: 0;
}

.hash-val {
  flex: 1;
  word-break: break-all;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}

.hash-copy { padding: 4px 12px; font-size: 11px; flex-shrink: 0; }

.hash-empty {
  padding: 36px;
  text-align: center;
  color: #3e3e4a;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══════════════════════════════════════
   JWT DECODER
═══════════════════════════════════════ */
.jwt-output {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.jwt-panel {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}

.jwt-panel-header {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.jwt-pre {
  margin: 0;
  padding: 14px 16px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text);
}

.jwt-sig-val {
  padding: 14px 16px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 11.5px;
  word-break: break-all;
  color: var(--muted);
  line-height: 1.5;
}

.jwt-status {
  display: none;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.jwt-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.jwt-badge-green { background: var(--green-bg); color: var(--green); }
.jwt-badge-red   { background: var(--red-bg);   color: var(--red);   }
