/* Направление: тёплая бумага. Мир — заметки на холодильнике, билеты в кино,
   вечерний свет. Тихий хром, один акцент (тлеющий оранжевый), единственный
   богатый момент — билет случайной идеи.
   Редизайн по методике unslop (CC BY 4.0, Damir Sokolovsky — @heydamir). */

:root {
    --bg: #f7f4ee;
    --card: #fdfbf7;
    --raised: #efe9df;
    --hairline: rgba(31, 27, 22, 0.08);
    --text: #1f1b16;
    --text-secondary: #5e554a;
    --text-muted: #7b7266;
    --accent: #c2410c;
    --accent-ink: #ffffff;
    --danger: #dc2626;
    --ticket-bg: #fbf2df;
    --toast-bg: #2b2721;
    --toast-text: #f7f4ee;

    --font-ui: "Instrument Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Instrument Serif", Georgia, serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
    --bg: #161513;
    --card: #1c1a18;
    --raised: #262421;
    --hairline: rgba(239, 233, 222, 0.08);
    --text: #efe9de;
    --text-secondary: #aaa398;
    --text-muted: #8a847a;
    --accent: #e8753f;
    --accent-ink: #1c1a18;
    --danger: #e5484d;
    --ticket-bg: #2a2118;
    --toast-bg: #efe9de;
    --toast-text: #1f1b16;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--text);
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    transition: background-color 200ms var(--ease), color 200ms var(--ease);
}

#app {
    max-width: 560px;
    margin: 0 auto;
    padding: 20px 16px;
}

svg.lucide {
    width: 18px;
    height: 18px;
    stroke-width: 1.5;
    flex-shrink: 0;
}

.hidden {
    display: none !important;
}

/* ---------- Вкладки ---------- */

.view {
    animation: view-in 300ms var(--ease) both;
}

@keyframes view-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.view-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

h1 {
    font-size: 24px;
    font-weight: 500;
    letter-spacing: 0;
}

.page-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ---------- Чипы категорий ---------- */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 16px;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 150ms var(--ease), border-color 150ms var(--ease),
        color 150ms var(--ease);
}

.chip svg.lucide {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.chip .count {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.chip.active {
    background: var(--raised);
    border-color: var(--accent);
    color: var(--text);
}

.chip.active svg.lucide {
    color: var(--accent);
}

/* ---------- Карточки идей ---------- */

.cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card {
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 16px;
    animation: card-in 300ms var(--ease) both;
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card .cat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.card .cat svg.lucide {
    width: 16px;
    height: 16px;
}

.card .text {
    font-size: 15px;
    line-height: 1.35;
    word-break: break-word;
}

.card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.card .del {
    display: inline-flex;
    align-items: center;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.card .del:hover {
    color: var(--danger);
    background: var(--raised);
}

.card .del svg.lucide {
    width: 16px;
    height: 16px;
}

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 24px;
    font-size: 14px;
    line-height: 1.5;
}

/* ---------- Билет случайной идеи ---------- */

#random-slot {
    margin-bottom: 20px;
}

.ticket {
    position: relative;
    background: var(--ticket-bg);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    overflow: hidden;
    animation: card-in 300ms var(--ease) both;
}

.ticket__main {
    padding: 24px 20px;
    text-align: center;
}

.ticket__cat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ticket__cat svg.lucide {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.ticket__text {
    font-family: var(--font-serif);
    font-size: 24px;
    line-height: 1.25;
    color: var(--text);
    word-break: break-word;
}

.ticket__placeholder {
    font-size: 14px;
    color: var(--text-muted);
    padding: 24px 0;
}

/* Перфорация билета — фирменная деталь */
.ticket__stub {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--text-muted);
    padding: 12px 20px;
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.ticket__stub::before,
.ticket__stub::after {
    content: "";
    position: absolute;
    top: -9px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--hairline);
}

.ticket__stub::before {
    left: -10px;
}

.ticket__stub::after {
    right: -10px;
}

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

/* ---------- Форма добавления ---------- */

textarea {
    width: 100%;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    padding: 12px;
    resize: none;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 150ms var(--ease);
}

textarea:focus {
    border-color: var(--accent);
}

textarea::placeholder {
    color: var(--text-muted);
}

.field-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.cat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    transition: background-color 150ms var(--ease), border-color 150ms var(--ease),
        color 150ms var(--ease);
}

.cat-btn svg.lucide {
    color: var(--text-muted);
    transition: color 150ms var(--ease);
}

.cat-btn.active {
    background: var(--raised);
    border-color: var(--accent);
    color: var(--text);
}

.cat-btn.active svg.lucide {
    color: var(--accent);
}

/* ---------- Кнопки ---------- */

.btn-primary {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    min-height: 44px;
    padding: 12px 20px;
    cursor: pointer;
    transition: opacity 150ms var(--ease), transform 120ms var(--ease);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
}

[data-theme="dark"] .btn-primary {
    background: var(--raised);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .btn-primary svg.lucide {
    color: var(--accent);
}

/* ---------- Нижняя навигация ---------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--hairline);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 10;
}

.tab {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-muted);
    padding: 8px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: color 150ms var(--ease);
}

.tab span {
    font-size: 12px;
}

.tab.active {
    color: var(--accent);
}

/* ---------- Тост ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--toast-bg);
    color: var(--toast-text);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    z-index: 20;
    animation: card-in 200ms var(--ease);
    white-space: nowrap;
}
