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

:root,
[data-theme="dark"] {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #1e2433;
    --text-primary: #e7e9ea;
    --text-secondary: #8b98a5;
    --accent-primary: #1d9bf0;
    --accent-success: #00ba7c;
    --accent-warning: #ffad1f;
    --accent-error: #f4212e;
    --border-color: #2f3542;
    --input-bg: #273340;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --border-radius: 8px;
}

[data-theme="light"] {
    --bg-primary: #f5f8fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #14171a;
    --text-secondary: #657786;
    --accent-primary: #1d9bf0;
    --accent-success: #17bf63;
    --accent-warning: #f5a623;
    --accent-error: #e0245e;
    --border-color: #e1e8ed;
    --input-bg: #f5f8fa;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

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

/* Theme toggle */
.theme-toggle {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.3rem;
    z-index: 100;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.theme-toggle:hover {
    opacity: 1;
}

.theme-btn {
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    opacity: 0.5;
}

.theme-btn:hover {
    opacity: 1;
    background: var(--bg-card);
}

.theme-btn.active {
    background: var(--accent-primary);
    opacity: 1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

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

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Search */
.search-bar {
    display: flex;
    gap: 0.5rem;
}

.search-bar input {
    flex: 1;
}

/* Inputs */
input, textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: inherit;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.2);
}

input::placeholder, textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: #1a8cd8;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #00a36c;
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Transfer timeline */
.timeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 0;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    z-index: 1;
}

.timeline-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.3s;
}

.timeline-step.done .timeline-dot {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.timeline-step.active .timeline-dot {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(29, 155, 240, 0.2);
}

.timeline-step.error .timeline-dot {
    background: var(--accent-error);
    border-color: var(--accent-error);
    color: white;
}

.timeline-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 5rem;
}

.timeline-step.done .timeline-label {
    color: var(--accent-success);
}

.timeline-step.active .timeline-label {
    color: var(--accent-primary);
    font-weight: 600;
}

.timeline-step.error .timeline-label {
    color: var(--accent-error);
    font-weight: 600;
}

.timeline-line {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 -0.25rem;
    margin-bottom: 1.4rem;
    transition: background 0.3s;
}

.timeline-line.done {
    background: var(--accent-success);
}

/* Status card */
.status-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(29, 155, 240, 0.06) 100%);
    border-color: var(--accent-primary);
}

.status-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.status-row .label {
    color: var(--text-secondary);
}

.status-row .value {
    color: var(--text-primary);
    font-weight: 500;
}

.status-row .value a {
    color: var(--accent-primary);
    text-decoration: none;
}

.status-row .value a:hover {
    text-decoration: underline;
}

.status-row .value.mono {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8rem;
}

/* Diagnosis banner */
.diagnosis {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.diagnosis.error {
    background: rgba(244, 33, 46, 0.1);
    border: 1px solid rgba(244, 33, 46, 0.3);
    color: var(--accent-error);
}

.diagnosis.warning {
    background: rgba(255, 173, 31, 0.1);
    border: 1px solid rgba(255, 173, 31, 0.3);
    color: var(--accent-warning);
}

.diagnosis.success {
    background: rgba(0, 186, 124, 0.1);
    border: 1px solid rgba(0, 186, 124, 0.3);
    color: var(--accent-success);
}

.diagnosis.info {
    background: rgba(29, 155, 240, 0.1);
    border: 1px solid rgba(29, 155, 240, 0.3);
    color: var(--accent-primary);
}

/* Action card */
.action-card {
    border-color: var(--accent-warning);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 173, 31, 0.04) 100%);
}

.action-card.action-success {
    border-color: var(--accent-success);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 186, 124, 0.04) 100%);
}

/* Wallet status */
.wallet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.wallet-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-connected {
    background: rgba(0, 186, 124, 0.2);
    color: var(--accent-success);
}

.status-disconnected {
    background: rgba(244, 33, 46, 0.2);
    color: var(--accent-error);
}

.wallet-address {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Logs */
.logs-card details summary {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
}

.logs-card details summary::-webkit-details-marker {
    display: none;
}

.logs-card details summary::before {
    content: '\25B6';
    font-size: 0.6rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.logs-card details[open] summary::before {
    transform: rotate(90deg);
}

.logs {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    max-height: 250px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.75rem;
    margin-top: 0.75rem;
}

.log-entry {
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.log-time {
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.log-info { color: var(--accent-primary); }
.log-success { color: var(--accent-success); }
.log-error { color: var(--accent-error); }
.log-warning { color: var(--accent-warning); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

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

/* Hidden */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
    .search-bar {
        flex-direction: column;
    }

    .wallet-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .timeline-label {
        font-size: 0.6rem;
        max-width: 3.5rem;
    }
}
