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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3a;
    --text: #e1e4ed;
    --text-muted: #8b8fa3;
    --accent: #6c8cff;
    --accent-hover: #8aa4ff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

#app {
    width: 100%;
    max-width: 640px;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Home page grid */
.grid {
    display: grid;
    gap: 1rem;
}

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

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

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

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

/* Util pages */
.util-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.back {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    align-self: flex-start;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"] {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.checkbox-group {
    flex-direction: row;
    gap: 1.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
}

input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.output-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.password-display {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.95rem;
    word-break: break-all;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

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

/* Textarea */
textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}

textarea:focus {
    border-color: var(--accent);
}

/* JWT input overlay (color-coded token) */
.jwt-input-wrap {
    position: relative;
}

.jwt-input-wrap textarea {
    position: relative;
    width: 100%;
    color: transparent;
    caret-color: var(--text);
    background: transparent;
    z-index: 1;
    resize: vertical;
}

.jwt-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.jwt-part-header    { color: #fb7185; }
.jwt-part-payload   { color: #a78bfa; }
.jwt-part-signature { color: #22d3ee; }
.jwt-part-dot       { color: var(--text-muted); }

/* JWT decoder */
.jwt-output {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 2.4rem;
}

.jwt-output pre {
    margin: 0;
    padding: 0.75rem;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.error-message {
    color: #ff6b6b;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: 6px;
}
