:root {
    color-scheme: dark;

    /* The Wraeclast Palette */
    --bg-void: #050505;          /* Deepest black */
    --bg-surface: #111113;       /* Main background */
    --bg-elevated: #1a1a1e;      /* Cards / Panels */
    --bg-highlight: #222226;     /* Hover states */
    
    --border-dim: #27272a;
    --border-lit: #3f3f46;

    /* Text Colors */
    --text-bright: #f4f4f5;
    --text-main: #d4d4d8;
    --text-muted: #a1a1aa;
    --text-soft: #71717a;

    /* PoE Accents */
    --primary: #c8aa6e;          /* Exalted/Chaos Gold */
    --primary-hover: #dfc186;
    --primary-dim: rgba(200, 170, 110, 0.15);
    
    --danger: #7f1d1d;           /* Vaal Blood/Corrupted */
    --danger-hover: #991b1b;
    --danger-text: #fecaca;

    --success: #166534;
    --success-text: #bbf7d0;

    /* Sharper, modern gaming corners */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.8);

    --content-max-width: 1400px;
    --header-height: 64px;

    /* Spacing system */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-surface);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* App Shell (Header & Layout) */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(17, 17, 19, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-dim);
}

.app-header__inner {
    width: min(100% - 2rem, var(--content-max-width));
    height: var(--header-height);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-brand-link {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    text-decoration: none;
}

.app-brand-link__title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.app-brand-link__subtitle {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.app-main__inner {
    width: min(100% - 2rem, var(--content-max-width));
    margin: 0 auto;
    padding: var(--space-6) 0 var(--space-8);
}

/* Flattened Generic Page Structure */
.page-section {
    display: grid;
    gap: var(--space-6);
}

/* We remove the background/border from page-surface to stop the "box in a box" feel */
.page-surface {
    background: transparent;
    border: none;
    box-shadow: none;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-lit);
    margin-bottom: var(--space-2);
}

.page-header__content {
    display: grid;
    gap: var(--space-1);
}

.page-header__title {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.5rem);
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: -0.02em;
}

.page-header__subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.page-header__actions {
    display: flex;
    gap: var(--space-3);
}

/* Flattened Section Cards */
.section-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
}

.section-card__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-dim);
    background: rgba(0, 0, 0, 0.2);
}

.section-card__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-bright);
}

.section-card__body {
    padding: var(--space-5);
}

/* Typography & Links */
h1, h2, h3, h4, h5, h6 { color: var(--text-bright); margin-top: 0; line-height: 1.2; }
p { margin-top: 0; }
a { color: var(--primary); transition: color var(--transition-fast); }
a:hover { color: var(--primary-hover); }
.muted { color: var(--text-muted); }

/* Forms & Inputs */
label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], input[type="file"], input[type="number"],
textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-void);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text-bright);
    font: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

textarea { min-height: 100px; resize: vertical; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

input::placeholder, textarea::placeholder { color: var(--text-soft); }

.field-help { margin-top: var(--space-2); font-size: 0.85rem; color: var(--text-muted); }
.field-errors { margin-top: var(--space-2); color: var(--danger-text); font-size: 0.85rem; }

/* Sharp, Minimal Buttons */
button, input[type="submit"], .button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    background: var(--bg-highlight);
    border: 1px solid var(--border-lit);
    border-radius: var(--radius-sm);
    color: var(--text-bright);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.button-primary:hover, 
input[type="submit"]:hover,
a.button-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--bg-void); /* Forces text to stay dark void color */
    box-shadow: 0 0 12px rgba(200, 170, 110, 0.3);
}

/* Primary Button (Gold) */
.button-primary, input[type="submit"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--bg-void); /* Dark text on gold background */
}

.button-primary:hover, input[type="submit"]:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 0 12px rgba(200, 170, 110, 0.3);
}

/* Secondary Button (Ghost) */
.secondary-button {
    background: transparent;
    border-color: var(--border-dim);
    color: var(--text-main);
}

.secondary-button:hover {
    background: var(--bg-highlight);
    border-color: var(--border-lit);
    color: var(--text-bright);
}

/* Danger Button */
.danger-button {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger-text);
}

.danger-button:hover {
    background: var(--danger);
    color: #fff;
}

/* PoE Theme Tags */
.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg-highlight);
    border: 1px solid var(--border-dim);
    color: var(--text-main);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(320px, calc(100vw - 2rem));
}

.toast {
    position: relative;
    overflow: hidden;
    padding: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-lit);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    animation: toast-in 200ms ease-out;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--danger { border-left: 3px solid var(--danger); }
.toast--info { border-left: 3px solid var(--primary); }

.toast__message { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--text-bright); }
.toast__progress {
    position: absolute; bottom: 0; left: 0; height: 2px; width: 100%;
    background: var(--primary);
    transform-origin: left;
    animation: toast-progress linear forwards;
}
.toast--closing { animation: toast-out 150ms ease-in forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 768px) {
    .page-header { flex-direction: column; align-items: stretch; }
}

/* --- Global Town Crier Banner --- */
.global-banner {
    width: 100%;
    padding: 0.6rem var(--space-4);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    animation: banner-slide-down 0.3s ease-out;
}

.global-banner__inner {
    width: min(100%, var(--content-max-width));
    margin: 0 auto;
}

.global-banner--info { background: rgba(30, 58, 138, 0.4); color: #93c5fd; border-bottom-color: #1e3a8a; box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.2); }
.global-banner--warning { background: rgba(120, 53, 15, 0.4); color: #fde047; border-bottom-color: var(--primary); box-shadow: inset 0 0 12px rgba(200, 170, 110, 0.2); }
.global-banner--danger { background: rgba(127, 29, 29, 0.5); color: #fca5a5; border-bottom-color: #991b1b; box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.2); }

@keyframes banner-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}