:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #262626;
    --bg-tertiary: #2a2a2a;
    --bg-input: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #888888;
    --border-color: #404040;
    --border-accent: #333333;
    --error-color: #ff6b6b;
    --error-bg: #2a1a1a;
    --error-border: #ff4444;
    --accent-orange: #ffa500;
    --accent-blue: #4a9eff;
    --accent-red: #ff6b6b;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #333333;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --border-accent: #dee2e6;
    --error-color: #dc3545;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --accent-orange: #fd7e14;
    --accent-blue: #0d6efd;
    --accent-red: #dc3545;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    color: var(--text-primary);
    font-size: 18px;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.header p {
    opacity: 0.7;
    font-size: 0.95rem;
}

.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 600px;
}

.input-section {
    padding: 24px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
}

.output-section {
    padding: 24px;
    background: var(--bg-secondary);
}

.section-title {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.token-input {
    width: 100%;
    height: 200px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    resize: vertical;
    transition: border-color 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}

.token-input:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.token-input.error {
    border-color: var(--error-border);
}

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

.decode-parts {
    margin-top: 16px;
}

.token-part {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.token-part.header {
    border-left: 3px solid var(--accent-orange);
}

.token-part.payload {
    border-left: 3px solid var(--accent-blue);
}

.token-part.signature {
    border-left: 3px solid var(--accent-red);
}

.part-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.part-content {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 3px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-accent);
}

.error-message {
    color: var(--error-color);
    font-size: 13px;
    margin-top: 10px;
    padding: 10px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: 4px;
}

.info-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    margin-top: 50px;
    font-size: 0.9rem;
}

.footer {
    padding: 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.disclaimer {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
    line-height: 1.4;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--text-primary);
}

.timestamp-value {
    position: relative;
    cursor: help;
    color: var(--accent-blue);
    text-decoration: underline;
    text-decoration-style: dotted;
}

.timestamp-value::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    margin-bottom: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.timestamp-value::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-color);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1001;
}

.timestamp-value:hover::before,
.timestamp-value:hover::after {
    opacity: 1;
}

@media (max-width: 768px) {
    .main {
        grid-template-columns: 1fr;
    }
    
    .input-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}