:root {
    --bg-color: #09090b; /* Zinc 950 - darker, neutral */
    --card-bg: #18181b; /* Zinc 900 */
    --text-color: #f4f4f5; /* Zinc 100 */
    --text-muted: #a1a1aa; /* Zinc 400 */
    --primary-brand: #6366f1; /* Indigo 500 - StreamSync brand */
    --primary-brand-hover: #4f46e5;
    --bsky-blue: #0085ff;
    --border-color: #27272a; /* Zinc 800 */
    --input-bg: #09090b;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: radial-gradient(circle at top center, rgba(99, 102, 241, 0.15), transparent 40%);
}

.container {
    width: 100%;
    max-width: 460px;
    padding: 24px;
    box-sizing: border-box;
}

h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin: 0 0 0.5rem 0;
    text-align: center;
    background: linear-gradient(to right, #fff, #a1a1aa);
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 3rem;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.input-group input {
    padding-left: 40px;
}

input:focus {
    outline: none;
    border-color: var(--primary-brand);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

input::-webkit-outer-spin-button, 
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    resize: vertical;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-brand);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: #006fd6;
    transform: translateY(-1px);
}

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

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

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

.btn-twitch {
    background-color: #9146FF;
    color: white;
}

.btn-twitch:hover {
    background-color: #772ce8;
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
}

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

.btn-danger:hover {
    background-color: #dc2626;
    color: white;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    display: none;
    position: absolute;
}

.loading .spinner {
    display: block;
}

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

.status-msg {
    margin-top: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

.error-msg { color: var(--danger); }
.success-msg { color: #10b981; }

a {
    color: var(--primary-brand);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-brand-hover);
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    margin-right: 12px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--card-bg);
    border: 2px solid #52525b;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-brand);
    border-color: var(--primary-brand);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* Add spacing to profile card */
.profile-card {
    margin-bottom: 24px;
}

.slide-wrapper {
    max-height: 130px;
    overflow: hidden;
    transition: max-height 0.6s ease-in-out, opacity 0.6s ease-in-out;
    opacity: 1;
}

.slide-wrapper.hidden {
    max-height: 0;
    opacity: 0;
    transition: max-height 0.6s ease-in-out, opacity 0.6s ease-in-out;
}

.btn-link-danger {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 8px;
    transition: color 0.2s;
}

.btn-link-danger:hover {
    color: var(--danger);
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(8, 75, 52, 0.2);
    border: 1px solid #10b981;
    color: #10b981;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    text-align: center;
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none; /* Prevent blocking while invisible */
}

.toast-notification.visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

.toast-notification.hidden-toast {
    opacity: 0;
    transform: translate(-50%, -20px);
}

/* Custom Dialog */
dialog {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
    /* Dialog polyfill/default override */
    margin: auto; 
    position: fixed;
    inset: 0;
}

dialog[open] {
    opacity: 1;
    transform: scale(1);
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

dialog[open]::backdrop {
    opacity: 1;
}

/* Animation classes for JS control if needed, but [open] selector handles basic state */
 @media screen and (max-width: 375px) {
    #twitchConnected > div, footer {
        flex-direction: column;
        gap: 1rem;
    }

    #twitchConnected > div {
        align-items: left;
    }
 }