:root {
    color-scheme:light;
    --bg:#f5f3eb;
    --card:#fffefa;
    --text:#243c33;
    --muted:#748078;
    --line:#e0e5dc;
    --accent:#365f4a;
    --soft:#e5ede5;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) {
        color-scheme:dark;
        --bg:#121a17;
        --card:#1d2923;
        --text:#e1eae3;
        --muted:#a2afa6;
        --line:#34483c;
        --accent:#b2d8bc;
        --soft:#2b4034;
    }
}

:root[data-theme="dark"] {
    color-scheme:dark;
    --bg:#121a17;
    --card:#1d2923;
    --text:#e1eae3;
    --muted:#a2afa6;
    --line:#34483c;
    --accent:#b2d8bc;
    --soft:#2b4034;
}

* {box-sizing:border-box}
[hidden] {display:none!important}

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

.container {
    max-width:760px;
    margin:auto;
    padding:calc(18px + env(safe-area-inset-top))
        20px 120px;
}

header,.brand,.detail-top,.section-title {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
}

.brand strong {
    font-size:25px;
    letter-spacing:4px;
}

.logo {
    display:grid;
    place-items:center;
    width:48px;
    height:48px;
    border-radius:15px;
    background:#365f4a;
    color:white;
    font-family:"Songti SC","SimSun",serif;
    font-size:29px;
}

small {
    display:block;
    color:var(--muted);
    font-size:12px;
    margin-top:5px;
}

.hero {padding:25px 0 17px}

.hero h1 {
    font-family:"Songti SC","SimSun",serif;
    font-size:38px;
    letter-spacing:4px;
    margin:8px 0 12px;
}

.hero p {
    color:var(--muted);
    font-size:14px;
    line-height:1.6;
}

.eyebrow {
    letter-spacing:3px;
    font-size:12px!important;
}

.search input {
    width:100%;
    padding:18px;
    border:1px solid var(--line);
    border-radius:17px;
    background:var(--card);
    color:var(--text);
    font-size:16px;
    outline-color:var(--accent);
}

button,input,select {font:inherit}

button,.file {
    border:none;
    background:var(--soft);
    color:var(--accent);
    border-radius:11px;
    padding:12px 15px;
    cursor:pointer;
}

button:active {opacity:.65}

button:focus-visible {
    outline:2px solid var(--accent);
}

button:disabled {opacity:.45}

.chips {
    display:flex;
    gap:8px;
    margin:16px 0 22px;
}

.chips button {
    flex:1;
    font-size:13px;
    padding:12px 4px;
}

.chips .active {
    color:white;
    background:#365f4a;
}

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

.daily-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
}

.daily-grid section {min-width:0}

.daily-grid h2 {
    font-size:17px;
    margin:0 0 12px;
}

.entry-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
}

.entry-shell {
    background:var(--card);
    border:1px solid var(--line);
    border-radius:17px;
    overflow:hidden;
    min-width:0;
    display:flex;
    flex-direction:column;
}

.entry-face {
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    justify-content:center;
    position:relative;
    width:100%;
    min-height:87px;
    background:transparent;
    color:var(--text);
    text-align:left;
    padding:15px;
}

.entry-face strong {
    display:block;
    font-family:"Songti SC","SimSun",serif;
    font-size:24px;
    padding-right:18px;
    overflow-wrap:anywhere;
}

.entry-face small {
    font-size:12px;
    color:var(--accent);
}

.sound-mark {
    position:absolute;
    right:11px;
    top:11px;
    font-size:19px;
    opacity:.7;
}

.entry-info {
    padding:0 14px 12px;
    display:flex;
    flex-direction:column;
    flex:1;
}

.entry-definition {
    font-size:13px;
    line-height:1.7;
    margin:7px 0 12px;
    overflow-wrap:anywhere;
}

.detail-link {
    align-self:flex-start;
    margin-top:auto;
    padding:8px 12px;
    font-size:12px;
}

.daily-grid .entry-shell {
    border:none;
    background:transparent;
}

.daily-grid .entry-face {
    aspect-ratio:1/1;
    min-height:0;
    border-radius:19px;
    background:#365f4a;
    color:white;
    align-items:center;
    text-align:center;
    padding:10px;
}

.daily-grid .entry-face strong {
    font-size:clamp(22px,5.8vw,38px);
    padding:0;
    line-height:1.4;
}

.daily-grid .entry-face small {
    color:#c6dccd;
    font-size:12px;
    margin-top:10px;
}

.daily-grid .entry-info {
    padding:3px 1px 6px;
}

.daily-grid .entry-definition {
    min-height:42px;
}

.card {
    background:var(--card);
    border:1px solid var(--line);
    border-radius:18px;
    padding:17px;
    margin-bottom:12px;
}

.card p {
    line-height:1.7;
    font-size:14px;
}

.card button,.file {
    display:block;
    width:100%;
    margin:10px 0;
    text-align:center;
}

.card label:not(.file) {
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin:14px 0;
    gap:10px;
}

select {
    background:var(--bg);
    color:var(--text);
    border:1px solid var(--line);
    border-radius:9px;
    padding:9px;
}

.section-title button {
    padding:8px 13px;
    font-size:12px;
}

.muted {
    color:var(--muted);
    font-size:12px;
    line-height:1.8;
}

.entry-grid > .muted {
    grid-column:1/-1;
}

#moreResults,#moreBrowse {
    width:100%;
    margin-top:15px;
}

nav {
    position:fixed;
    bottom:0;
    left:50%;
    transform:translateX(-50%);
    width:100%;
    max-width:760px;
    background:var(--card);
    border-top:1px solid var(--line);
    display:flex;
    padding:8px 8px calc(12px + env(safe-area-inset-bottom));
    z-index:5;
}

nav button {
    flex:1;
    background:transparent;
    color:var(--muted);
    font-size:11px;
}

nav button b {
    display:block;
    font-size:26px;
    line-height:30px;
}

nav button.active {
    color:var(--accent);
    background:var(--soft);
}

dialog {
    width:min(92vw,560px);
    max-height:85vh;
    max-height:85dvh;
    overflow:auto;
    background:var(--card);
    color:var(--text);
    padding:23px;
    border:1px solid var(--line);
    border-radius:24px;
}

dialog::backdrop {background:#0008}

.detailTitle {
    font-family:"Songti SC","SimSun",serif;
    font-size:40px;
    line-height:1.4;
    margin:18px 0 8px;
    overflow-wrap:anywhere;
}

.detailSection {
    border-top:1px solid var(--line);
    padding:14px 0;
    white-space:pre-wrap;
    line-height:1.8;
}

.detailSection h3 {
    color:var(--accent);
    font-size:14px;
    margin:0 0 8px;
}

.file input {
    width:100%;
    margin-top:10px;
    font-size:12px;
}

.danger {color:#b84c43}

#toast {
    position:fixed;
    bottom:110px;
    left:50%;
    transform:translateX(-50%);
    max-width:85vw;
    padding:13px 19px;
    border-radius:13px;
    background:#243c33;
    color:white;
    z-index:30;
    font-size:13px;
}

@media(min-width:650px) {
    .daily-grid {
        max-width:510px;
    }

    .entry-grid {
        grid-template-columns:repeat(3,minmax(0,1fr));
    }
}

@media(max-width:340px) {
    .container {
        padding-left:12px;
        padding-right:12px;
    }
    .entry-face strong {font-size:20px}
    .daily-grid {gap:8px}
}
