:root {
    color-scheme: light dark;
    --bg: var(--tg-theme-bg-color, #f5f5f7);
    --card: var(--tg-theme-secondary-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #202124);
    --muted: var(--tg-theme-hint-color, #85858b);
    --accent: var(--tg-theme-button-color, #3488d1);
    --accent-text: var(--tg-theme-button-text-color, #fff);
    --border: rgba(128, 128, 128, .18);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--tg-theme-bg-color, #151517);
        --card: var(--tg-theme-secondary-bg-color, #242426);
        --text: var(--tg-theme-text-color, #f5f5f5);
    }
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont,
                 "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

main {
    max-width: 600px;
    margin: auto;
    padding: 22px 18px 40px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}

h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -1.5px;
}

h2 {
    margin: 0 0 20px;
    font-size: 22px;
}

.subtitle {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--muted);
}

button {
    border: 0;
    border-radius: 12px;
    padding: 12px 15px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

button:disabled {
    opacity: .5;
    cursor: default;
}

.primary {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

#add {
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 30px;
    flex-shrink: 0;
}

.tabs {
    display: flex;
    gap: 5px;
    padding: 4px;
    border-radius: 15px;
    background: var(--card);
}

.tabs button {
    flex: 1;
    color: var(--muted);
}

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

.categories {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 16px 0;
    scrollbar-width: none;
}

.categories button {
    white-space: nowrap;
    border-radius: 30px;
    padding: 9px 14px;
    font-size: 13px;
}

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

.idea {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--card);
    border-radius: 15px;
    padding: 16px;
    margin-bottom: 9px;
}

.idea input[type="checkbox"] {
    width: 21px;
    height: 21px;
    accent-color: var(--accent);
    flex-shrink: 0;
    margin: 1px 0 0;
}

.idea-body {
    flex: 1;
    min-width: 0;
}

.idea-title {
    font-weight: 600;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.idea.done .idea-title {
    text-decoration: line-through;
    opacity: .65;
}

.idea-category {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}

.idea-description {
    font-size: 14px;
    margin: 8px 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.idea a {
    display: inline-block;
    color: var(--accent);
    font-size: 13px;
    margin-top: 8px;
}

.edit {
    color: var(--muted);
    padding: 0 5px 8px;
    font-size: 22px;
}

.empty {
    text-align: center;
    padding: 45px 10px;
    color: var(--muted);
}

#notice, #form-error {
    background: var(--card);
    border-radius: 12px;
    padding: 12px;
    font-size: 13px;
    overflow-wrap: anywhere;
}

dialog {
    width: min(94%, 480px);
    max-height: 90dvh;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--card);
    color: var(--text);
}

dialog::backdrop {
    background: rgba(0, 0, 0, .45);
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 16px 0 7px;
}

form input, textarea {
    width: 100%;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

textarea {
    resize: vertical;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    margin-top: 22px;
}

#delete, #form-error {
    color: #e05252;
}

/* Category icons */

.categories {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
    padding: 16px 0 5px;
}

.categories button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 46px;
    padding: 0;
    border-radius: 12px;
}

.categories svg {
    width: 23px;
    height: 23px;
}

#category-label {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin: 5px 0 16px;
}

@media (max-width: 360px) {
    main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .categories {
        gap: 4px;
    }

    .categories svg {
        width: 20px;
        height: 20px;
    }
}

/* Emoji categories */

.categories button {
    font-family: "Apple Color Emoji",
                 "Segoe UI Emoji",
                 "Noto Color Emoji", sans-serif;
    font-size: 24px;
    border: 1.5px solid transparent;
}

.categories .selected {
    background: rgba(52, 136, 209, .15);
    border-color: var(--accent);
}

@media (max-width: 360px) {
    .categories button {
        font-size: 21px;
    }
}


/* Editor category picker */

.editor-categories {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    padding: 0 0 8px;
}

.editor-categories button {
    background: var(--bg);
    height: 44px;
    font-size: 24px;
}

.editor-categories .selected {
    background: rgba(52, 136, 209, .15);
    border-color: var(--accent);
}

@media (max-width: 360px) {
    .editor-categories button {
        font-size: 20px;
        height: 40px;
    }
}


#editor-category-label {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 12px;
}


/* Idea voting */

.idea-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.idea-footer .idea-category {
    margin-top: 0;
    overflow-wrap: anywhere;
}

.heart-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    padding: 5px 7px;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    flex-shrink: 0;
}

.heart-button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linejoin: round;
}

.heart-button.liked {
    color: #ed4965;
}

.heart-button.liked svg {
    fill: currentColor;
}

.heart-count {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}


/* Disable zoom */

html, body {
    touch-action: pan-y;
}

button, input, textarea {
    touch-action: manipulation;
}
