:root {
  --bg: #0d0f14;
  --panel: #161922;
  --panel-border: #272b36;
  --text: #f0ede6;
  --text-dim: #9b9fab;
  --accent: #e8a33d;
  --accent-dim: #8a6726;
  --accent-ink: #1a1304;
  --accent-hover: #f0b05a;
  --c-header: #6e9fc1;
  --c-payload: #e8a33d;
  --c-signature: #a07cc4;
  --success: #5b8c5a;
  --success-bg: #141c15;
  --success-border: #2b4a2b;
  --error: #c45c5c;
  --radius: 6px;
}

:root[data-theme="light"] {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-border: #ddd8cb;
  --text: #211f1a;
  --text-dim: #6b665c;
  --accent: #b5700f;
  --accent-dim: #8a5610;
  --accent-ink: #ffffff;
  --accent-hover: #c9820f;
  --c-header: #3f6f93;
  --c-payload: #b5700f;
  --c-signature: #7a5aa0;
  --success: #3f7a3e;
  --success-bg: #eef5ec;
  --success-border: #bfdcb9;
  --error: #a43f3f;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "IBM Plex Sans", -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

header {
  margin-bottom: 1.75rem;
}

.wordmark {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.wordmark-easy {
  color: var(--text);
}

.wordmark-jwt {
  color: var(--accent);
}

.tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: 0.3rem 0 0;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.token-panel {
  margin-bottom: 1.5rem;
}

.token-field {
  position: relative;
}

.token-field textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  padding: 0.7rem 0.8rem;
  font-family: "IBM Plex Mono", Consolas, Menlo, monospace;
  font-size: 0.88rem;
  resize: vertical;
}

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

.token-segments {
  display: flex;
  height: 4px;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: var(--panel-border);
}

.seg {
  flex: 1;
}

.seg-header {
  background: var(--c-header);
}

.seg-payload {
  background: var(--c-payload);
}

.seg-signature {
  background: var(--c-signature);
}

.seg-dot {
  display: none;
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

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

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tab-dot.header { background: var(--c-header); }
.tab-dot.payload { background: var(--c-payload); }
.tab-dot.signature { background: var(--c-signature); }
.tab-dot.warn { background: var(--error); }

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.hint {
  color: var(--text-dim);
  font-size: 0.87rem;
  margin: 0 0 0.9rem;
  max-width: 62ch;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.4rem 0 0.3rem;
  color: var(--text);
}

h3:first-child {
  margin-top: 0;
}

label {
  display: block;
}

input[type="text"], select, textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  font-family: "IBM Plex Mono", Consolas, Menlo, monospace;
  font-size: 0.88rem;
}

input[type="text"]:focus-visible, select:focus-visible, textarea:focus-visible, input[type="file"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

select {
  font-family: "IBM Plex Sans", sans-serif;
}

.field-row {
  display: flex;
  gap: 1rem;
  margin: 0.6rem 0;
}

.field-row label {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.field-row label input, .field-row label textarea {
  margin-top: 0.3rem;
}

.field-row.hidden {
  display: none;
}

.file-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.file-note {
  font-size: 0.76rem;
  color: var(--text-dim);
  opacity: 0.8;
}

input[type="file"] {
  width: 100%;
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
  margin-bottom: 0.8rem;
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.2rem;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
}

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

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

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.7rem;
}

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

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.loading::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.5em;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.columns {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.columns .panel {
  flex: 1;
  margin-top: 0;
}

.panel {
  margin-top: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.panel-head h3 {
  margin: 0 0 0.3rem;
}

.output-block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  font-family: "IBM Plex Mono", Consolas, Menlo, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.6rem;
  margin: 0.3rem 0 0;
  color: var(--text);
}

.copy-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success-border);
}

.result-box {
  margin-top: 1.1rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
}

.result-box.found {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.result-box strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 600;
}

.result-box code, .token-value {
  flex: 1;
  word-break: break-all;
  font-family: "IBM Plex Mono", Consolas, Menlo, monospace;
  font-size: 0.82rem;
  color: var(--text);
}

details.raw-output {
  margin-top: 1.1rem;
}

details.raw-output summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.82rem;
  padding: 0.2rem 0;
}

details.raw-output summary:hover {
  color: var(--text);
}

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--panel-border);
}

.warning {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .columns {
    flex-direction: column;
  }
  .field-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .tabs {
    overflow-x: auto;
  }
  .wordmark {
    font-size: 1.4rem;
  }
}

h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 0.3rem;
  text-transform: none;
}

.json-editor {
  min-height: 140px;
  line-height: 1.5;
}

.credits {
  display: flex;
  gap: 0.5rem;
  margin: 0.7rem 0 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--panel-border);
}

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

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.icon-moon {
  display: none;
}

:root[data-theme="light"] .icon-sun {
  display: none;
}

:root[data-theme="light"] .icon-moon {
  display: block;
}
