* {
    box-sizing: border-box
}

html {
    color-scheme: light;
    --bg: #f6f8fc;
    --card: #fff;
    --soft: #eef4fa;
    --ink: #192f45;
    --muted: #566b80;
    --edge: #dce5ee;
    --sea: #19668e;
    --tint: #e6f3fa;
    --mint: #317466;
    --shadow: 0 12px 42px #2339500a
}

html[data-dark] {
    color-scheme: dark;
    --bg: #0e1117;
    --card: #161c26;
    --soft: #202838;
    --ink: #e1ecf4;
    --muted: #acbed0;
    --edge: #304050;
    --sea: #8cd6fa;
    --tint: #183549;
    --mint: #8bdfcb;
    --shadow: none
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 "DM Sans", "Microsoft YaHei UI", system-ui, sans-serif
}

body,
header,
footer,
main,
.card,
.chip,
nav,
button,
input,
textarea,
select {
    transition: background-color .28s cubic-bezier(.4, 0, .2, 1), color .28s, border-color .28s
}

#app {
    max-width: 760px;
    margin: auto;
    height: var(--height, 100dvh);
    display: flex;
    flex-direction: column;
    position: relative
}

header,
footer {
    flex: none
}

header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(14px + env(safe-area-inset-top)) 20px 13px;
    border-bottom: 1px solid var(--edge)
}

h1,
h2,
h3,
p {
    margin: 0
}

h1 {
    font-size: 20px;
    letter-spacing: -.04em;
    margin-right: auto
}

h2 {
    font-size: 24px;
    line-height: 1.3
}

h3 {
    font-size: 16px
}

small,
.muted {
    color: var(--muted)
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 13px;
    background: var(--soft);
    padding: 8px 13px;
    min-height: 38px
}

button:disabled {
    opacity: .5;
    cursor: default
}

button:focus-visible,
:focus-visible {
    outline: 3px solid var(--sea);
    outline-offset: 2px
}

.primary {
    background: var(--sea);
    color: var(--card);
    font-weight: 700
}

.chip,
.speak,
.add {
    font-size: 13px;
    padding: 5px 10px;
    min-height: 32px;
    color: var(--sea);
    background: var(--tint);
    border-radius: 99px
}

.icon {
    width: 38px;
    height: 38px;
    padding: 8px;
    background: transparent
}

.icon svg,
nav svg,
.speak svg {
    width: 21px;
    height: 21px;
    vertical-align: middle
}

main {
    flex: 1;
    overflow: auto;
    overscroll-behavior: contain;
    min-height: 0;
    padding: 20px;
    scroll-padding: 16px;
    overflow-wrap: anywhere
}

.empty {
    display: flex;
    min-height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    gap: 10px
}

.hero {
    width: min(55vw, 225px);
    height: auto;
    object-fit: contain;
    animation: float 4.6s ease-in-out infinite
}

.empty p {
    max-width: 22em;
    margin: 0 auto;
    color: var(--muted);
    font-size: 14px
}

.suggestions,
.row,
.chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap
}

.suggestions {
    justify-content: center;
    margin-top: 14px
}

.suggestions button {
    border: 1px solid var(--edge);
    background: var(--card);
    font-size: 13px
}

.card,
.bubble {
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 20px;
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 12px
}

.card section {
    border-top: 1px solid var(--edge);
    padding-top: 13px;
    margin-top: 13px
}

.card h3 {
    margin: 4px 0 7px
}

.bubble {
    margin: 10px 0;
    max-width: 90%;
    border-radius: 18px 18px 18px 4px
}

.user {
    background: var(--tint);
    margin-left: auto;
    width: fit-content;
    border-radius: 18px 18px 4px 18px;
    white-space: pre-wrap
}

.avatar {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 50%;
    background: var(--tint)
}

.ai {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-bottom: 8px
}

.ai .bubble {
    margin: 0
}

.turn {
    animation: arrive .35s ease-out
}

.word {
    padding: 12px 0;
    border-bottom: 1px solid var(--edge)
}

.word:last-child {
    border: 0
}

.word strong,
.phrase strong {
    font-family: Georgia, serif;
    font-size: 20px
}

.phrase {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 7px 0
}

.speak {
    flex: none;
    padding: 4px 9px
}

.speak svg {
    width: 17px
}

.row.spread {
    justify-content: space-between
}

.brand {
    width: 56px;
    height: 56px;
    border-radius: 17px
}

.menu {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--edge);
    margin: 4px 0;
    display: flex;
    justify-content: space-between;
    text-align: left;
    gap: 12px;
    align-items: center;
    padding: 13px 17px
}

.menu small {
    display: block
}

.menu b {
    font-weight: 650
}

.menu i {
    font-style: normal;
    color: var(--sea)
}

footer {
    padding: 4px 14px env(safe-area-inset-bottom);
    background: var(--bg)
}

.composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 22px;
    padding: 8px 9px 8px 14px;
    box-shadow: var(--shadow)
}

.composer textarea {
    margin: 0;
    padding: 4px 0;
    border: 0;
    min-height: 30px;
    max-height: 128px;
    background: transparent;
    resize: none
}

.send {
    flex: none;
    width: 38px;
    height: 38px;
    padding: 6px;
    border-radius: 50%
}

.send:disabled {
    background: var(--soft);
    color: var(--muted)
}

nav {
    display: flex;
    justify-content: space-around;
    padding: 5px 0 2px
}

nav button {
    font-size: 11px;
    min-width: 65px;
    background: transparent;
    color: var(--muted);
    padding: 3px
}

nav svg {
    display: block;
    margin: 0 auto 1px
}

nav .active {
    color: var(--sea);
    background: var(--tint)
}

label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin: 12px 0
}

input,
textarea,
select {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-top: 5px;
    border: 1px solid var(--edge);
    border-radius: 12px;
    background: var(--bg);
    font-size: 16px;
    line-height: 1.5
}

textarea {
    min-height: 90px
}

input[type=range] {
    padding: 0;
    accent-color: var(--sea)
}

input[type=checkbox] {
    width: auto;
    display: inline
}

.panel {
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 16px;
    padding: 9px 14px;
    margin-bottom: 6px;
    animation: arrive .2s ease-out
}

.panel input {
    flex: 1;
    width: 70px
}

.panel .chips {
    justify-content: space-evenly
}

.panel .chip {
    min-height: 28px
}

.sel {
    outline: 2px solid var(--sea)
}

.login {
    margin: auto;
    width: min(90%, 390px);
    text-align: center
}

.login img {
    width: 118px
}

.login label {
    text-align: left
}

.login .primary {
    width: 100%
}

.alert {
    color: #aa4343;
    background: #fff0eb;
    padding: 9px;
    border-radius: 12px;
    margin-top: 10px
}

dialog {
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 22px;
    width: min(90vw, 460px);
    max-height: 85dvh
}

dialog::backdrop {
    background: #15293c70
}

#notice:not(:empty) {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(78px + env(safe-area-inset-bottom));
    background: var(--ink);
    color: var(--card);
    border-radius: 15px;
    padding: 10px 18px;
    max-width: 88%;
    z-index: 5
}

#notice button {
    margin-left: 8px;
    color: var(--sea)
}

.dots i {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: var(--sea);
    margin: 1px;
    border-radius: 50%;
    animation: float .85s infinite
}

.dots i:nth-child(2) {
    animation-delay: .15s
}

.dots i:nth-child(3) {
    animation-delay: .3s
}

@keyframes float {
    50% {
        transform: translateY(-4px) rotate(1deg)
    }
}

@keyframes arrive {
    from {
        opacity: 0;
        transform: translateY(5px)
    }
}

@media(prefers-reduced-motion:reduce) {

    *,
    *::before {
        animation: none !important;
        transition: none !important
    }
}

@media(max-width:430px) {
    header {
        padding-left: 14px;
        padding-right: 14px;
        gap: 5px
    }

    main {
        padding: 14px
    }

    .card {
        padding: 15px
    }

    .empty h2 {
        font-size: 23px
    }
}

.hero-wrap {
    position: relative
}

.wordcard {
    position: absolute;
    bottom: 8%;
    right: 10%;
    padding: 3px 18px;
    transform: rotate(8deg);
    border: 1px solid var(--edge);
    color: var(--sea);
    background: var(--card);
    font: italic 32px Georgia, serif;
    border-radius: 8px;
    box-shadow: -4px -4px 0 var(--tint)
}

.login.card {
    margin: auto
}

.ai:has(.dots) .avatar {
    animation: float 1s ease-in-out infinite
}
.role-badge { display:inline-block; padding:.12rem .5rem; border-radius:1rem; background:var(--surface); font-size:.8rem; }
dialog [role="alert"]:not(:empty) { color:#b53d32; padding:.4rem; background:#fff1ec; border-radius:.4rem; }
