:root,
[data-theme="light"] {
    --bg: #f0e7e2;
    --card: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.9);
    --input-bg: #ffffff;
    --border: #e0cfc7;
    --text: #3d312e;
    --text-2: #665551;
    --muted: #8c736c;
    --accent: #d08370;
    --accent-dark: #b56b5a;
    --chip: #f4e8e3;
    --shadow: 0 10px 25px rgba(208, 131, 112, 0.08);
    --good: #059669;
    --bad: #dc2626;
    --warn: #b45309;
    --check-a: #ffffff;
    --check-b: #ece1dc;
}

[data-theme="dark"] {
    --bg: #1c1512;
    --card: #2a201d;
    --card-border: #3f302b;
    --input-bg: #221a17;
    --border: #3f302b;
    --text: #f4e8e3;
    --text-2: #c4aca4;
    --muted: #9a837c;
    --accent: #e39a86;
    --accent-dark: #d08370;
    --chip: #382a26;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    --good: #34d399;
    --bad: #f87171;
    --warn: #fbbf24;
    --check-a: #2a201d;
    --check-b: #342824;
}

* { box-sizing: border-box; }

body.il-body {
    margin: 0;
    min-height: 100vh;
    padding: 28px 20px 48px;
    background: var(--bg);
    color: var(--text);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
}

.il-app {
    width: min(100%, 940px);
    margin: 0 auto;
    opacity: 0;
    animation: ilFade 1s ease-out forwards;
}

@keyframes ilFade {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.il-header { text-align: center; margin-bottom: 26px; }

.il-topbar { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 18px; }

.il-back { color: var(--muted); font-size: 0.86rem; font-weight: 600; text-decoration: none; }
.il-back:hover { color: var(--accent); }

.il-title-link { display: inline-block; text-decoration: none; transition: transform 0.3s ease; }
.il-title-link:hover { transform: scale(1.05); }

.il-title {
    margin: 0;
    color: var(--accent);
    font-family: 'Rubik Iso', sans-serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 10px rgba(208, 131, 112, 0.15);
}

.il-subtitle { margin: 10px auto 0; max-width: 560px; color: var(--muted); font-size: 0.95rem; }

.il-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.il-pill-btn:hover { border-color: var(--accent); }

.il-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 38px 20px;
    border: 2px dashed var(--accent);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.il-drop:hover, .il-drop:focus-visible, .il-drop.drag { background: var(--chip); transform: translateY(-2px); outline: none; }
.il-drop strong { font-size: 1.1rem; color: var(--accent); }
.il-drop span { color: var(--text-2); font-size: 0.9rem; }
.il-drop small { color: var(--muted); font-size: 0.78rem; }

.il-note { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--chip); color: var(--warn); font-size: 0.85rem; font-weight: 600; }

.il-card {
    margin-top: 18px;
    padding: 20px 22px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.il-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.il-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); min-width: 0; }
.il-field small { font-weight: 400; color: var(--muted); font-size: 0.74rem; line-height: 1.4; }
.il-field strong { color: var(--accent); }
.il-field input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }

.il-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: 0.92rem;
}
.il-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(208, 131, 112, 0.18); }
.il-input:disabled { opacity: 0.5; }
.il-color { width: 100%; height: 42px; padding: 3px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }

.il-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.il-chips button {
    padding: 3px 9px;
    border: none;
    border-radius: 8px;
    background: var(--chip);
    color: var(--accent-dark);
    font: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
}
[data-theme="dark"] .il-chips button { color: var(--accent); }
.il-chips button:hover { background: var(--accent); color: #fff; }

.il-hint { margin: 14px 0 0; color: var(--muted); font-size: 0.78rem; }

.il-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.il-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); transform: translateY(-1px); }
.il-btn:disabled { opacity: 0.5; pointer-events: none; }
.il-btn-ghost { background: transparent; color: var(--accent); }
.il-btn-ghost:hover { background: var(--accent); color: #fff; }
.il-btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.il-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 28px;
    margin-top: 18px;
    padding: 16px 22px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.il-summary[hidden] { display: none; }
.il-summary > div:not(.il-summary-actions) { display: flex; flex-direction: column; }
.il-summary span { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.il-summary strong { font-size: 1.1rem; }
#s_saved { color: var(--good); }
.il-summary-actions { margin-left: auto; display: flex; gap: 8px; }

.il-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.il-item {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.il-thumb {
    width: 84px;
    height: 84px;
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--check-a);
    background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%),
                      linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%);
    background-size: 14px 14px;
    background-position: 0 0, 7px 7px;
    border: 1px solid var(--border);
}
.il-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.il-info { min-width: 0; }
.il-name { display: block; font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.il-meta { display: block; margin-top: 3px; font-size: 0.8rem; color: var(--text-2); }
.il-meta b { color: var(--text); }
.il-saving { font-weight: 700; color: var(--good); }
.il-saving.worse { color: var(--bad); }
.il-status { display: block; margin-top: 3px; font-size: 0.76rem; color: var(--muted); }
.il-status.err { color: var(--bad); font-weight: 600; }
.il-status.warn { color: var(--warn); }

.il-bar { margin-top: 8px; height: 5px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.il-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }

.il-actions { display: flex; flex-direction: column; gap: 6px; }

.il-footer { margin: 28px 0 0; text-align: center; color: var(--muted); font-size: 0.78rem; }

@media (max-width: 760px) {
    .il-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    body.il-body { padding: 20px 14px 36px; }
    .il-grid { grid-template-columns: 1fr; }
    .il-card { padding: 16px; }
    .il-item { grid-template-columns: 64px minmax(0, 1fr); }
    .il-thumb { width: 64px; height: 64px; }
    .il-actions { grid-column: 1 / -1; flex-direction: row; }
    .il-actions .il-btn { flex: 1; }
    .il-summary-actions { margin-left: 0; width: 100%; }
    .il-summary-actions .il-btn { flex: 1; }
}
