:root {
    --background: #fafafa;
    --foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #0052ff;
    --accent-secondary: #4d7cff;
    --accent-foreground: #ffffff;
    --border: #e2e8f0;
    --card: #ffffff;
    --ring: rgba(0, 82, 255, 0.18);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
    --shadow-accent: 0 14px 34px rgba(0, 82, 255, 0.22);
    --gradient: linear-gradient(135deg, #0052ff, #4d7cff);
    --transition: all 0.24s ease-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: 'Inter', system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(77, 124, 255, 0.14), transparent 30%),
        radial-gradient(circle at bottom right, rgba(0, 82, 255, 0.08), transparent 28%),
        var(--background);
    color: var(--foreground);
    line-height: 1.65;
    padding: 24px;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: none;
}

.page-shell {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    gap: 28px;
}

.panel {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
}

.panel::after {
    content: '';
    position: absolute;
    inset: auto -80px -80px auto;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(0, 82, 255, 0.1), transparent 70%);
    pointer-events: none;
}

.panel-dark {
    background:
        radial-gradient(circle at 20% 10%, rgba(77, 124, 255, 0.18), transparent 24%),
        radial-gradient(circle at 85% 80%, rgba(0, 82, 255, 0.14), transparent 22%),
        var(--foreground);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.18);
}

.panel-dark::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
}

.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 32px;
    padding: 42px;
}

.hero-content,
.hero-visual {
    position: relative;
    z-index: 1;
}

.hero-kicker,
.badge-text {
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(0, 82, 255, 0.08);
    border: 1px solid rgba(77, 124, 255, 0.25);
    color: var(--accent);
    margin-bottom: 18px;
}

.panel-dark .section-badge {
    color: #dbeafe;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(148, 163, 184, 0.25);
}

.badge-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 8px rgba(0, 82, 255, 0.12);
}

.pulse-dot-badge .badge-dot {
    animation: pulseDot 2s infinite;
}

.hero h1,
h2 {
    font-family: 'Calistoga', Georgia, serif;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.hero h1 {
    font-size: clamp(2.9rem, 6vw, 5.1rem);
    line-height: 1.06;
    margin-bottom: 18px;
}

.hero-description {
    max-width: 720px;
    color: rgba(248, 250, 252, 0.8);
    font-size: 1.05rem;
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-actions,
.btn-container,
.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-actions {
    margin: 28px 0 30px;
}

.btn {
    min-height: 48px;
    padding: 0 20px;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    color: var(--accent-foreground);
    background: var(--gradient);
    box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-secondary {
    background: var(--muted);
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-secondary:hover,
.btn-ghost:hover {
    border-color: rgba(0, 82, 255, 0.28);
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    background: transparent;
    color: inherit;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.btn-small {
    min-height: 40px;
    padding: 0 16px;
    font-size: 0.95rem;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.metric-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.metric-label {
    display: block;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.62);
    margin-bottom: 8px;
}

.metric-card strong {
    font-size: 1rem;
}

.hero-visual {
    min-height: 360px;
    display: grid;
    place-items: center;
}

.rotating-ring {
    position: absolute;
    width: min(32vw, 360px);
    height: min(32vw, 360px);
    border-radius: 50%;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    animation: spinSlow 60s linear infinite;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(16px);
}

.orb-a {
    width: 170px;
    height: 170px;
    background: rgba(77, 124, 255, 0.3);
    top: 30px;
    right: 70px;
}

.orb-b {
    width: 120px;
    height: 120px;
    background: rgba(0, 82, 255, 0.24);
    left: 80px;
    bottom: 40px;
}

.floating-card {
    position: absolute;
    padding: 18px 20px;
    min-width: 180px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--foreground);
    box-shadow: var(--shadow-lg);
}

.floating-card span {
    display: block;
    font-size: 0.84rem;
    color: var(--muted-foreground);
    margin-bottom: 8px;
}

.floating-card strong {
    font-size: 1.12rem;
}

.card-top {
    top: 44px;
    left: 18px;
    animation: floatY 5s ease-in-out infinite;
}

.card-bottom {
    bottom: 38px;
    right: 26px;
    animation: floatY 4s ease-in-out infinite reverse;
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 28px;
}

.config-panel,
.status-panel,
.messages-panel {
    padding: 30px;
}

.sidebar-stack {
    display: grid;
    gap: 28px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.compact-header {
    margin-bottom: 18px;
}

h2 {
    font-size: clamp(2rem, 3vw, 2.75rem);
    margin-bottom: 8px;
}

h3 {
    font-size: 1.08rem;
    margin-bottom: 6px;
}

.panel-header p,
.toggle-row p,
.section-actions p,
.empty-state span,
.message-content,
.message-time,
.status-meta span {
    color: var(--muted-foreground);
}

.tabs {
    display: grid;
    gap: 22px;
}

.tab-buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    border-radius: 20px;
    background: var(--muted);
}

.tab-button {
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    background: transparent;
    color: var(--muted-foreground);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.tab-button.active {
    background: var(--card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.config-grid {
    display: grid;
    gap: 18px;
}

.single-column {
    grid-template-columns: 1fr;
}

.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-full {
    grid-column: 1 / -1;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.92rem;
    font-weight: 600;
}

.input-group input,
.input-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.9);
    padding: 14px 16px;
    color: var(--foreground);
    outline: none;
    transition: var(--transition);
}

.input-group input {
    min-height: 52px;
}

.input-group textarea {
    min-height: 140px;
    resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: rgba(0, 82, 255, 0.4);
    box-shadow: 0 0 0 4px var(--ring);
    background: #fff;
}

.stack-list {
    display: grid;
    gap: 14px;
}

.group-item,
.reply-rule,
.message {
    position: relative;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94));
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.group-item:hover,
.reply-rule:hover,
.message:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.group-item::before,
.reply-rule::before,
.message::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20px;
    bottom: 20px;
    width: 4px;
    border-radius: 999px;
    background: var(--gradient);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.switch {
    position: relative;
    width: 58px;
    height: 34px;
    display: inline-block;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: var(--transition);
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    top: 4px;
    left: 4px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
    transition: var(--transition);
}

.switch input:checked + .switch-slider {
    background: linear-gradient(135deg, rgba(0, 82, 255, 0.9), rgba(77, 124, 255, 0.8));
}

.switch input:checked + .switch-slider::before {
    transform: translateX(24px);
}

.status {
    padding: 18px 20px;
    border-radius: 18px;
    font-weight: 600;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.status-info {
    background: rgba(0, 82, 255, 0.08);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.16);
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.18);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.18);
}

.status-meta {
    display: grid;
    gap: 12px;
}

.status-meta div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--muted);
}

.messages-container {
    max-height: 680px;
    overflow: auto;
    display: grid;
    gap: 14px;
    padding-right: 6px;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.55);
    border-radius: 999px;
}

.empty-state {
    border-radius: 18px;
    border: 1px dashed var(--border);
    padding: 30px 20px;
    text-align: center;
    background: rgba(248, 250, 252, 0.85);
}

.empty-state strong,
.message-header {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.message-time {
    display: block;
    font-size: 0.82rem;
    margin-top: 10px;
}

.message-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    margin-bottom: 12px;
    background: rgba(0, 82, 255, 0.08);
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.input-error {
    border-color: rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12) !important;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.7; }
}

@keyframes floatY {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 1100px) {
    .hero,
    .main-grid {
        grid-template-columns: 1fr;
    }

    .hero-visual {
        min-height: 260px;
    }
}

@media (max-width: 820px) {
    body {
        padding: 14px;
    }

    .hero,
    .config-panel,
    .status-panel,
    .messages-panel {
        padding: 22px;
    }

    .tab-buttons,
    .two-column,
    .hero-metrics {
        grid-template-columns: 1fr;
    }

    .toggle-row,
    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-actions .btn,
    .section-actions .btn {
        width: 100%;
    }

    .hero-visual {
        display: none;
    }
}
