@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500&display=swap");

/* ═══════════════════════════════════════════════════════════════════
   ClewdR — Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────────── */
:root {
    --bg:        #0a0e14;
    --surface:   #111720;
    --card:      #151d28;
    --card-border: rgba(255,255,255,0.06);
    --input-bg:  #0d131c;
    --hover:     #1a2330;

    --border:    #1e2a36;
    --border-hi: #2a3a4a;

    --accent:    #06b6d4;
    --accent-hi:#22d3ee;
    --accent-dim:#0891b2;
    --danger:    #ef4444;
    --danger-hi: #f87171;
    --success:   #22c55e;
    --warn:      #eab308;

    --text:      #e2e8f0;
    --text-dim:  #94a3b8;
    --text-mute: #64748b;

    --font:      "DM Sans", system-ui, sans-serif;
    --mono:      "JetBrains Mono", monospace;

    --radius:    8px;
    --radius-sm: 4px;
    --radius-lg: 14px;

    --divider:   rgba(255,255,255,0.05);
    --overlay:   rgba(255,255,255,0.02);
    --shadow:    0 2px 12px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.03) inset;
}

/* ── Light Theme ───────────────────────────────────────────────── */
[data-theme="light"] {
    --bg:        #e3e7ee;
    --surface:   #d7dde5;
    --card:      #f5f7fa;
    --card-border: rgba(0,0,0,0.07);
    --input-bg:  #f5f7fa;
    --hover:     #eaedf4;

    --border:    #b9c1cc;
    --border-hi: #8b98a8;

    --accent-dim:#0e7490;
    --accent:    #0891b2;
    --accent-hi:#06b6d4;

    --text:      #0e1525;
    --text-dim:  #334155;
    --text-mute: #58667a;

    --divider:   rgba(0,0,0,0.07);
    --overlay:   rgba(0,0,0,0.025);
    --shadow:    0 1px 3px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.03);
}

/* ── Light overrides for hardcoded dark colors ─────────────────── */
[data-theme="light"] .alert-success { color: #16a34a; background: rgba(22,163,74,0.06); border-color: rgba(22,163,74,0.2); }
[data-theme="light"] .alert-error   { color: #dc2626; background: rgba(220,38,38,0.06); border-color: rgba(220,38,38,0.2); }
[data-theme="light"] .alert-info    { color: #0891b2; background: rgba(8,145,178,0.06); border-color: rgba(8,145,178,0.2); }
[data-theme="light"] .alert-warn    { color: #b45309; background: rgba(180,83,9,0.06);  border-color: rgba(180,83,9,0.2); }

[data-theme="light"] .section-title-valid    { color: #16a34a; }
[data-theme="light"] .section-title-exhausted { color: #b45309; }
[data-theme="light"] .section-title-invalid   { color: #dc2626; }

[data-theme="light"] .badge-on  { color: #16a34a; background: rgba(22,163,74,0.1);  border-color: rgba(22,163,74,0.3); }
[data-theme="light"] .badge-off { color: #58667a; background: rgba(100,116,139,0.08); border-color: rgba(100,116,139,0.25); }

[data-theme="light"] .cookie-section-valid    { background: rgba(22,163,74,0.02); border-color: rgba(22,163,74,0.18); }
[data-theme="light"] .cookie-section-exhausted { background: rgba(180,83,9,0.02); border-color: rgba(180,83,9,0.18); }
[data-theme="light"] .cookie-section-invalid   { background: rgba(220,38,38,0.02); border-color: rgba(220,38,38,0.18); }

[data-theme="light"] ::-webkit-scrollbar-thumb       { background: #c4cad3; border-radius: 3px; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #a0a7b4; }

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 60% 50% at 50% -10%, rgba(6,182,212,0.06), transparent),
        radial-gradient(ellipse 30% 40% at 90% 90%, rgba(3,105,161,0.04), transparent);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: #2d3748; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: #4a5568; }

::selection { background: rgba(6,182,212,0.25); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Typography ────────────────────────────────────────────────── */
h1,.h1 { font-size: 1.25rem; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
h2,.h2 { font-size: 1.15rem; font-weight: 600; color: var(--text); }
h3,.h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); }
h4,.h4 { font-size: 0.875rem; font-weight: 600; color: var(--text-dim); }

.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-dim  { color: var(--text-dim); }
.text-mute { color: var(--text-mute); }
.text-mono { font-family: var(--mono); }

a, .link { color: var(--accent); text-underline-offset: 2px; }
a:hover, .link:hover { color: var(--accent-hi); }

/* ── Layout ────────────────────────────────────────────────────── */
.container {
    width: 100%; max-width: 720px; margin: 0 auto; padding: 0 1.25rem;
}
@media (min-width: 768px)  { .container { max-width: 780px; padding: 0 2rem; } }
@media (min-width: 1200px) { .container { max-width: 860px; } }

.card-wrap { width: 100%; max-width: 100%; margin: 0 auto; }

/* Flex */
.row       { display: flex; align-items: center; gap: 0.75rem; }
.row-sm    { display: flex; align-items: center; gap: 0.375rem; }
.row-lg    { display: flex; align-items: center; gap: 1.5rem; }
.row-start { display: flex; align-items: flex-start; gap: 0.75rem; }
.row-btw   { display: flex; align-items: center; justify-content: space-between; }
.row-wrap  { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.flex-1    { flex: 1; min-width: 0; }

/* Stack (vertical) */
.stack    { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.5rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Card ──────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font: inherit; font-weight: 500; font-size: 0.875rem;
    border: none; cursor: pointer;
    transition: all 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary {
    background: var(--accent-dim);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent);
    box-shadow: 0 0 20px rgba(6,182,212,0.25);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger-hi);
    box-shadow: 0 0 20px rgba(239,68,68,0.25);
}

.btn-ghost {
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--hover);
    color: var(--text);
    border-color: var(--border-hi);
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.7rem; border-radius: var(--radius-sm); }

/* ── Inputs ────────────────────────────────────────────────────── */
.label { display: block; font-size: 0.875rem; color: var(--text-dim); margin-bottom: 0.25rem; }
.label-sm { font-size: 0.75rem; color: var(--text-mute); }

.input, .textarea {
    width: 100%; padding: 0.6rem 0.85rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit; font-size: 0.875rem;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:hover:not(:disabled), .textarea:hover:not(:disabled) {
    border-color: var(--border-hi);
    background: var(--surface);
}
.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6,182,212,0.12);
}
.input:disabled, .textarea:disabled { opacity: 0.4; cursor: not-allowed; }
.input-sm { padding: 0.4rem 0.65rem; font-size: 0.8125rem; }

.textarea {
    resize: vertical; min-height: 100px; line-height: 1.6;
    font-family: var(--mono); font-size: 0.8125rem;
}

input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 1.1rem; height: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    cursor: pointer; flex-shrink: 0;
    transition: all 150ms ease;
}
input[type="checkbox"]:hover { border-color: var(--accent-dim); }
input[type="checkbox"]:checked {
    background: var(--accent-dim); border-color: var(--accent-dim);
    box-shadow: 0 0 6px rgba(6,182,212,0.3);
}
input[type="checkbox"]:checked::after {
    content: ""; display: block;
    margin: 1px 0 0 3px;
    width: 5px; height: 9px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-row {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.875rem; color: var(--text-dim);
    cursor: pointer;
}

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; border: 1px solid;
}
.alert-success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.25); color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); color: #f87171; }
.alert-info    { background: rgba(6,182,212,0.06); border-color: rgba(6,182,212,0.2);  color: #67e8f9; }
.alert-warn    { background: rgba(234,179,8,0.08); border-color: rgba(234,179,8,0.25); color: #facc15; }

/* ── Header ────────────────────────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--divider);
    padding: 0.75rem 1rem;
}

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs {
    display: flex; gap: 0.25rem; margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--divider);
}
.tab {
    padding: 0.5rem 1rem; font-size: 0.875rem;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--text-dim); background: none; border: none;
    cursor: pointer; transition: color 150ms ease;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--text); background: var(--surface);
    border-bottom: 2px solid var(--accent);
    font-weight: 500;
}

.sub-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.sub-tab {
    padding: 0.375rem 0.75rem; font-size: 0.8125rem;
    border-radius: var(--radius);
    background: var(--surface); color: var(--text-dim);
    border: 1px solid var(--border); cursor: pointer;
    transition: all 150ms ease;
}
.sub-tab:hover { background: var(--hover); color: var(--text); }
.sub-tab.active {
    background: var(--accent-dim); color: #fff; border-color: var(--accent-dim);
}

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
    position: fixed; top: 1rem; right: 1rem; z-index: 50;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    color: #fff;
    animation: toast-in 300ms ease;
}
.toast-success { background: rgba(22,163,74,0.9); border: 1px solid rgba(34,197,94,0.4); }
.toast-error   { background: rgba(185,28,28,0.9); border: 1px solid rgba(239,68,68,0.4); }
.toast-close { margin-left: 0.75rem; font-weight: 700; cursor: pointer; opacity: 0.7; }
.toast-close:hover { opacity: 1; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(2rem) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── Cookie Sections ───────────────────────────────────────────── */
.cookie-section {
    border: 1px solid; border-radius: var(--radius-lg); padding: 0.75rem;
}
.cookie-section-valid     { border-color: rgba(34,197,94,0.2); background: rgba(34,197,94,0.02); }
.cookie-section-exhausted  { border-color: rgba(234,179,8,0.2); background: rgba(234,179,8,0.02); }
.cookie-section-invalid    { border-color: rgba(239,68,68,0.2); background: rgba(239,68,68,0.02); }

.section-title { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; }
.section-title-valid     { color: #4ade80; }
.section-title-exhausted  { color: #facc15; }
.section-title-invalid    { color: #f87171; }

.section-empty { font-size: 0.75rem; color: var(--text-mute); }

.cookie-row {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.5rem 0; font-size: 0.875rem;
}
.cookie-row + .cookie-row { border-top: 1px solid var(--divider); }

/* ── Badges (1M toggles) ───────────────────────────────────────── */
.badge {
    padding: 0.25rem 0.5rem; font-size: 0.7rem;
    border-radius: var(--radius-sm); border: 1px solid;
    cursor: pointer; font-family: var(--font);
    transition: all 150ms ease;
}
.badge:disabled { opacity: 0.5; cursor: not-allowed; }
.badge-on  { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.4); color: #4ade80; }
.badge-off { background: rgba(100,116,139,0.1); border-color: rgba(100,116,139,0.3); color: #94a3b8; }
.badge-on:hover:not(:disabled)  { background: rgba(34,197,94,0.2); }
.badge-off:hover:not(:disabled) { background: rgba(100,116,139,0.2); }

/* ── Lang selector ─────────────────────────────────────────────── */
.lang-btn {
    padding: 0.25rem 0.5rem; font-size: 0.7rem; border-radius: var(--radius-sm);
    border: none; cursor: pointer; font-family: var(--font); font-weight: 500;
    transition: all 150ms ease;
}
.lang-btn.on  { background: var(--accent-dim); color: #fff; }
.lang-btn.off { background: var(--surface); color: var(--text-dim); }
.lang-btn.off:hover { background: var(--hover); color: var(--text); }

/* ── Footer ────────────────────────────────────────────────────── */
.footer {
    text-align: center; color: var(--text-mute); font-size: 0.875rem;
    padding: 1rem 0; margin-top: 3rem;
    border-top: 1px solid var(--divider);
}

/* ── Delete icon ───────────────────────────────────────────────── */
.icon-del {
    color: #f87171; font-size: 0.75rem; cursor: pointer;
    background: none; border: none;
    transition: color 150ms ease;
}
.icon-del:hover { color: var(--danger); }
.icon-del:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-copy {
    color: var(--text-mute); font-size: 0.7rem; cursor: pointer;
    background: none; border: none;
    transition: color 150ms ease;
}
.icon-copy:hover { color: var(--text); }

/* ── Usage details ─────────────────────────────────────────────── */
details summary {
    cursor: pointer; font-size: 0.75rem; color: var(--text-mute);
    transition: color 150ms ease; padding: 0.125rem 0;
}
details summary:hover { color: var(--text-dim); }

/* ── Config sections ───────────────────────────────────────────── */
.config-section {
    padding: 1rem; border-radius: var(--radius);
    border: 1px solid var(--card-border);
    background: var(--overlay);
}
.config-section + .config-section { margin-top: 0.75rem; }

.config-section-title {
    font-size: 0.875rem; font-weight: 600; color: var(--text-dim);
    margin-bottom: 0.25rem;
}
.config-section-desc {
    font-size: 0.75rem; color: var(--text-mute);
    margin-bottom: 0.75rem;
}

/* ── Progress bar ──────────────────────────────────────────────── */
.progress {
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}
.progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 400ms var(--ease-out);
    min-width: 0;
}
.progress-bar.low  { background: var(--success); }
.progress-bar.mid  { background: var(--warn); }
.progress-bar.high { background: var(--danger); }

.progress-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 0.75rem;
}
.progress-label span:first-child { color: var(--text-dim); }
.progress-label span:last-child { color: var(--text-mute); font-size: 0.6875rem; }

/* ── Divider ───────────────────────────────────────────────────── */
.divider {
    border: none; border-top: 1px solid var(--divider);
    margin: 0.75rem 0;
}

/* ── Truncate ──────────────────────────────────────────────────── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Loading ───────────────────────────────────────────────────── */
.loading { text-align: center; color: var(--text-mute); padding: 2rem 0; }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }
.loading { animation: pulse 1.5s ease-in-out infinite; }

/* ── Page enter ────────────────────────────────────────────────── */
.card-wrap > * { animation: fade-in 350ms ease; }
@keyframes fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    html { font-size: 14px; }
    .container { padding: 0 0.75rem; }
}

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
    body { background: #fff; color: #000; }
}
