:root {
    /* Security Dark Palette */
    --primary: #F59E0B;
    /* Amber 500 */
    --primary-hover: #d97706;
    --accent: #EF4444;
    /* Red 500 */
    --background: #1A1A2E;
    /* Deep Navy */
    --surface: #16213E;
    /* Lighter Navy */

    --glass-bg: rgba(22, 33, 62, 0.7);
    --glass-border: rgba(245, 158, 11, 0.2);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --c-header: #fbbf24;
    /* Yellow */
    --c-payload: #34d399;
    /* Emerald */
    --c-signature: #f87171;
    /* Red */
    --c-neutral: #94a3b8;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 10% 20%, rgba(245, 158, 11, 0.08), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(239, 68, 68, 0.08), transparent 40%);
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.25rem;
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.flex-col {
    display: flex;
    flex-direction: column;
}

/* Utilities */
.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.ml-3 {
    margin-left: 1rem;
}

.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.text-error {
    color: var(--accent) !important;
}

.font-mono {
    font-family: 'Fira Code', monospace;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #cbd5e1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Tokens Input with Overlay for syntax highlight */
.input-wrapper {
    position: relative;
    height: 250px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.token-input,
.token-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-all;
    white-space: pre-wrap;
    margin: 0;
    border: none;
    border-radius: 8px;
}

.token-input {
    color: transparent;
    /* Text matches overlay, but caret shows */
    background: transparent;
    caret-color: #fff;
    resize: none;
    outline: none;
    z-index: 2;
}

.token-input::placeholder {
    color: var(--text-muted);
}

.token-overlay {
    z-index: 1;
    color: var(--text-muted);
    pointer-events: none;
}

/* Token Colors */
.tok-header {
    color: var(--c-header);
}

.tok-payload {
    color: var(--c-payload);
}

.tok-signature {
    color: var(--c-signature);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

.outline-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}

.outline-btn:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Forms */
.input-control {
    width: 100%;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-radius: 6px;
    outline: none;
    transition: 0.2s;
}

.input-control:focus {
    border-color: var(--primary);
}

/* Decoded Output */
.decoded-section {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.section-header {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header h3 {
    margin: 0;
    font-size: 0.9rem;
}

.section-header .dim {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8rem;
}

.type-header {
    background: rgba(251, 191, 36, 0.1);
    border-left: 2px solid var(--c-header);
}

.type-payload {
    background: rgba(52, 211, 153, 0.1);
    border-left: 2px solid var(--c-payload);
}

.type-signature {
    background: rgba(248, 113, 113, 0.1);
    border-left: 2px solid var(--c-signature);
}

.code-container {
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
}

pre {
    margin: 0;
    font-size: 0.9rem;
}

.wrap-text {
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--c-signature);
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.neutral {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

.status-badge.success {
    background: rgba(52, 211, 153, 0.2);
    color: #34d399;
}

.status-badge.error {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

/* Size Chart */
.size-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
    margin-top: 0.5rem;
}

.size-bar>div {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 0px;
    /* Hide text if too small, or handle gracefully */
    transition: width 0.3s ease;
}

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

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

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

.size-stats {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

/* Timeline */
.timeline-viz {
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.timeline-countdown {
    text-align: center;
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    color: var(--c-header);
    font-weight: 500;
}

/* Validator List */
.claim-list {
    list-style: none;
}

.claim-item {
    display: flex;
    align-items: baseline;
    padding: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.claim-item:last-child {
    border: none;
}

.claim-key {
    color: var(--c-payload);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    min-width: 60px;
}

.claim-desc {
    color: var(--text-main);
    font-size: 0.9rem;
    flex: 1;
}

.claim-status {
    font-weight: 600;
    font-size: 0.85rem;
}

.cs-ok {
    color: #34d399;
}

.cs-warn {
    color: var(--c-header);
}

.cs-err {
    color: #f87171;
}

/* JSON highlight colors */
.json-key {
    color: #93c5fd;
}

.json-string {
    color: #86efac;
}

.json-number {
    color: #fdba74;
}

.json-boolean {
    color: #c4b5fd;
}

.json-null {
    color: #fca5a5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast.show {
    opacity: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.compare-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    overflow: hidden;
}

.compare-col {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.compare-out {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

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