:root {
    --bg-base: #fafafa;
    --bg-panel: #ffffff;
    --bg-hover: #f4f4f5;

    --border-light: #e4e4e7;
    --border-highlight: #d4d4d8;

    --text-main: #18181b;
    --text-muted: #71717a;

    --accent: #8b5cf6;
    --accent-hover: #7c3aed;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body.dark-theme {
    --bg-base: #09090b;
    --bg-panel: #18181b;
    --bg-hover: #27272a;

    --border-light: #27272a;
    --border-highlight: #3f3f46;

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;

    --accent: #a78bfa;
    --accent-hover: #c4b5fd;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 16px -4px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.flex-1 {
    flex: 1;
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger) !important;
}

.font-medium {
    font-weight: 500;
}

.text-sm {
    font-size: 0.875rem;
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 12px;
}

body.dark-theme .logo-icon {
    color: #000;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

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

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

body.dark-theme .btn-primary {
    color: #000;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-highlight);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}

.form-input {
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
}

/* Control Panel */
.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 500px) {
    .control-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        text-align: center;
    }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
    position: relative;
    transition: background-color 0.3s;
}

.pulse-dot.active {
    background-color: var(--success);
}

.pulse-dot.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--success);
    animation: ripple 2s infinite ease-in-out;
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.permission-notice {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* History Panel */
.history-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
}

.search-input {
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.875rem;
    outline: none;
    width: 150px;
}

/* History List & Items */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.history-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-body {
    background: var(--bg-base);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-main);
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid transparent;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem auto;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.875rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    transform: translateY(100px);
    background: var(--text-main);
    color: var(--bg-base);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}