/*
    /my/dictionaries and /my/dictionaries/{id}: a subscriber's synced dictionaries on the website.
    Theme tokens from themes.css, so light and dark follow the site. NewsTemplate's style.css resets
    ul/a/span globally, so list and link styles are explicit here.
*/

.dict-page {
    --dict-surface: var(--theme-surface, #fff);
    --dict-bg: var(--theme-body-bg, #f8fafc);
    --dict-border: var(--theme-border, #e2e8f0);
    --dict-text: var(--theme-text, #1e293b);
    --dict-muted: var(--theme-text-muted, #64748b);
    --dict-accent: var(--theme-primary, #2563eb);
    --dict-accent-soft: var(--theme-primary-light, #eff6ff);
    color: var(--dict-text);
}

.dict-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.dict-head h1 {
    margin: 0 0 .35rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.dict-head__flag {
    margin-right: .6rem;
    vertical-align: -2px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}

.dict-head__lead {
    max-width: 60ch;
    margin: 0;
    color: var(--dict-muted);
}

.dict-crumbs {
    margin-bottom: .75rem;
    font-size: .9rem;
}

.dict-crumbs a {
    color: var(--dict-muted);
    text-decoration: none;
}

.dict-crumbs a:hover {
    color: var(--dict-accent);
}

.dict-sync {
    display: flex;
    align-items: center;
    margin: 0 0 1rem;
    color: var(--dict-muted);
    font-size: .88rem;
}

.dict-sync i {
    color: #16a34a;
}

/* ── Dictionary cards ─────────────────────────────────────────── */

.dict-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.dict-grid > .dict-form {
    grid-column: 1 / -1;
}

.dict-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--dict-border);
    border-radius: 14px;
    background: var(--dict-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.dict-card:hover {
    border-color: var(--dict-accent);
    box-shadow: 0 4px 18px rgba(0, 0, 0, .08);
}

.dict-card.is-default {
    border-color: color-mix(in srgb, #16a34a 55%, var(--dict-border));
}

.dict-card__main {
    display: flex;
    flex: 1;
    gap: .85rem;
    padding: 1rem 1rem .75rem;
    color: var(--dict-text);
    text-decoration: none;
}

.dict-card__main:hover {
    color: var(--dict-text);
}

.dict-card__flags {
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 34px;
}

.dict-card__flags .psc-lang-flag {
    display: block;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
    object-fit: cover;
}

.dict-card__flags .dict-card__flag2 {
    position: absolute;
    right: 0;
    bottom: -4px;
    border-radius: 3px;
    box-shadow: 0 0 0 2px var(--dict-surface);
}

.dict-card__text {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}

.dict-card__name {
    font-size: 1.08rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.dict-card__langs {
    color: var(--dict-muted);
    font-size: .82rem;
}

.dict-card__desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: .2rem;
    font-size: .88rem;
}

.dict-card__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    padding: .5rem .5rem .5rem 1rem;
    border-top: 1px solid var(--dict-border);
}

.dict-card__count {
    color: var(--dict-muted);
    font-size: .85rem;
    font-weight: 600;
}

.dict-card__spacer {
    flex: 1;
}

.dict-card__add {
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
}

.dict-card__more {
    color: var(--dict-muted);
}

.dict-badge {
    display: inline-flex;
    align-items: center;
    padding: .05rem .5rem;
    border-radius: 999px;
    background: color-mix(in srgb, #16a34a 15%, transparent);
    color: #16a34a;
    font-size: .72rem;
    font-weight: 600;
}

.dict-badge--shop {
    background: color-mix(in srgb, #f59e0b 16%, transparent);
    color: #d97706;
}

/* ── Free accounts: "sync with the app is Premium" ───────────── */

.dict-upsell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: 1.25rem;
    padding: .85rem 1rem;
    border: 1px solid var(--dict-border);
    border-radius: 12px;
    background: linear-gradient(120deg, var(--dict-accent-soft), transparent 80%);
}

.dict-upsell__icon {
    color: var(--dict-accent);
    font-size: 1.4rem;
}

.dict-upsell__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 240px;
    font-size: .92rem;
}

.dict-upsell__text span {
    color: var(--dict-muted);
}

.dict-upsell__text .dict-usage {
    margin-top: .15rem;
    font-weight: 600;
}

.dict-upsell__text .dict-usage.is-full {
    color: #d97706;
}

/* ── Merge offer ───────────────────────────────────────────── */

.dict-merge {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    border: 1px solid var(--dict-accent);
    border-radius: 12px;
    background: var(--dict-accent-soft);
}

.dict-merge__icon {
    color: var(--dict-accent);
    font-size: 1.4rem;
}

.dict-merge__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 220px;
    font-size: .92rem;
}

.dict-merge__text span {
    color: var(--dict-muted);
}

/* ── Forms ─────────────────────────────────────────────────────── */

.dict-form {
    margin-bottom: 1.25rem;
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--dict-accent);
    border-radius: 14px;
    background: var(--dict-surface);
}

.dict-form h2 {
    margin: 0 0 .9rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.dict-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1rem;
}

/* ── Empty states and the Premium pitch ───────────────────────── */

.dict-empty,
.dict-premium {
    padding: 2.5rem 1.5rem;
    border: 1px dashed var(--dict-border);
    border-radius: 14px;
    text-align: center;
    color: var(--dict-muted);
}

.dict-empty i {
    display: block;
    margin-bottom: .5rem;
    font-size: 2.2rem;
    opacity: .5;
}

.dict-premium {
    border-style: solid;
    background: linear-gradient(160deg, var(--dict-accent-soft), transparent 70%);
    color: var(--dict-text);
}

.dict-premium__icon {
    display: inline-block;
    margin-bottom: .5rem;
    color: var(--dict-accent);
    font-size: 2.4rem;
}

.dict-premium h2 {
    margin-bottom: .6rem;
    font-size: 1.35rem;
    font-weight: 700;
}

.dict-premium p {
    max-width: 56ch;
    margin: 0 auto 1rem;
}

.dict-premium ul {
    display: inline-block;
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
    text-align: left;
}

.dict-premium li {
    margin: .25rem 0;
}

.dict-premium li::before {
    content: "✓";
    margin-right: .5rem;
    color: #16a34a;
    font-weight: 700;
}

/* ── Words ─────────────────────────────────────────────────────── */

.dict-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.dict-search {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 460px;
}

.dict-search i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dict-muted);
}

.dict-search input {
    width: 100%;
    padding: .5rem .75rem .5rem 2.2rem;
    border: 1px solid var(--dict-border);
    border-radius: 10px;
    background: var(--dict-surface);
    color: var(--dict-text);
}

.word-list {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    border: 1px solid var(--dict-border);
    border-radius: 14px;
    background: var(--dict-surface);
    overflow: hidden;
}

.word-list > li + li {
    border-top: 1px solid var(--dict-border);
}

.word-list__edit {
    padding: .75rem;
}

.word-list__edit .dict-form {
    margin: 0;
}

.word-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .75rem .7rem 1rem;
}

.word-row:hover {
    background: rgba(127, 127, 127, .05);
}

.word-row__main {
    flex: 1;
    min-width: 0;
}

.word-row__original {
    font-size: 1.02rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.word-row__article {
    margin-right: .3rem;
    color: var(--dict-muted);
    font-weight: 400;
}

.word-row__gender {
    margin-left: .4rem;
    color: var(--dict-muted);
    font-size: .78rem;
    font-weight: 400;
    font-style: italic;
}

.word-row__translations {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .25rem;
}

.word-chip {
    padding: .05rem .5rem;
    border-radius: 6px;
    background: var(--dict-accent-soft);
    color: var(--dict-accent);
    font-size: .82rem;
}

.word-row__note {
    margin-top: .25rem;
    color: var(--dict-muted);
    font-size: .82rem;
}

.word-type {
    flex-shrink: 0;
    color: var(--dict-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.word-row__actions {
    display: flex;
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .word-type {
        display: none;
    }

    .dict-head .btn {
        width: 100%;
    }
}
