:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-soft: #243044;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.15);
    --success: #22c55e;
    --danger: #ef4444;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

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

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

a:hover {
    text-decoration: underline;
}

/* ===== Display Page ===== */
.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.page-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin-bottom: 0.35rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    margin-top: 0.85rem;
}

.queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    transition: border-color 0.2s, transform 0.15s;
}

.queue-item:first-child {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, var(--bg-card) 100%);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.queue-num {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--text-muted);
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.queue-item:first-child .queue-num {
    background: var(--primary);
    color: #fff;
}

.queue-info {
    flex: 1;
    min-width: 0;
}

.queue-name {
    font-weight: 700;
    font-size: 1.1rem;
    word-break: break-word;
}

.queue-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.queue-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.65rem 1.2rem;
    border-radius: 8px;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.28);
}

.btn-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.btn-success:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.28);
}

.btn-ghost {
    background: var(--bg-soft);
    color: var(--text-muted);
}

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

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.empty-state strong {
    display: block;
    color: var(--text);
    font-size: 1.15rem;
    margin-bottom: 0.4rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.links-box {
    margin-top: 2rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.links-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.link-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.link-row:last-child {
    margin-bottom: 0;
}

.link-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 70px;
    flex-shrink: 0;
}

.link-input {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.8rem;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-family: inherit;
}

.copy-btn {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

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

/* ===== Add Page ===== */
.add-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}

.add-card h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    text-align: center;
}

.add-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.form-actions .btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.alert.show {
    display: block;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ===== OBS Overlay ===== */
body.obs {
    background: transparent;
    overflow: hidden;
}

.obs-wrap {
    padding: 12px;
    max-width: 420px;
}

.obs-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.obs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.obs-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 20, 25, 0.82);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.obs-item.current {
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(37, 99, 235, 0.35);
}

.obs-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.obs-item.current .obs-num {
    background: #3b82f6;
    color: #fff;
}

.obs-name {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    word-break: break-word;
}

.obs-empty {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    padding: 8px 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

@media (max-width: 480px) {
    .page {
        padding: 1.25rem 0.85rem 2rem;
    }
    .page-header h1 {
        font-size: 1.4rem;
    }
    .queue-name {
        font-size: 1rem;
    }
}
