:root {
    --bg-1: #f4efe8;
    --bg-2: #d7e8e4;
    --panel: #fffdf7;
    --ink: #1f2d2a;
    --muted: #4b5f5a;
    --accent: #0f766e;
    --accent-2: #0a4b7b;
    --error: #b42318;
    --border: #d6dfdc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, #cde4dc 0%, transparent 40%),
        radial-gradient(circle at bottom left, #f2ddc7 0%, transparent 42%),
        linear-gradient(140deg, var(--bg-1), var(--bg-2));
}

.app-shell {
    width: min(960px, 92vw);
    margin: 3rem auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 12px 30px rgba(20, 37, 44, 0.12);
}

h1 {
    margin-top: 0;
    margin-bottom: 0.4rem;
    font-size: clamp(1.6rem, 2.6vw, 2.2rem);
}

.subtitle {
    margin-top: 0;
    color: var(--muted);
}

.controls label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto;
    gap: 0.8rem;
    align-items: center;
}

#disconnectBtn {
    background: linear-gradient(140deg, #a13b2e, #7d251b);
}

select,
button {
    border-radius: 10px;
    border: 1px solid var(--border);
    font: inherit;
    padding: 0.7rem 0.9rem;
}

select {
    width: 100%;
    background: #ffffff;
}

button {
    background: linear-gradient(140deg, var(--accent), #0a625b);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
    filter: brightness(1.05);
}

button:active {
    transform: translateY(1px) scale(0.99);
}

button:disabled {
    cursor: not-allowed;
    filter: grayscale(25%);
    opacity: 0.65;
}

.status-wrap {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    background: #f7fbfa;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
}

.led {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.25);
}

.led-offline {
    background: #969fa8;
}

.led-connecting {
    background: #2269cc;
    box-shadow: 0 0 8px #2269cc;
}

.led-ready {
    background: #239953;
    box-shadow: 0 0 8px #239953;
}

.led-error {
    background: #cc2f2f;
    box-shadow: 0 0 8px #cc2f2f;
}

.question-box {
    margin-top: 1.4rem;
}

.speech-buttons {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

#askBtn {
    min-width: 180px;
    background: linear-gradient(140deg, var(--accent-2), #17385c);
}

#askNoHistoryBtn {
    min-width: 240px;
    background: linear-gradient(140deg, #8c2f39, #652028);
}

.hint {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.message {
    margin-top: 1rem;
    min-height: 1.5rem;
    font-weight: 600;
}

.message.error {
    color: var(--error);
}

.message.info {
    color: #0d5870;
}

.message.success {
    color: #0d6a36;
}

.debug-output {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem;
    min-height: 120px;
    max-height: 320px;
    overflow: auto;
    background: #fbfbf9;
    color: #24302f;
    font-size: 0.88rem;
    line-height: 1.35;
}

@media (max-width: 760px) {
    .app-shell {
        margin: 1.2rem auto;
    }

    .panel {
        padding: 1rem;
    }

    .row {
        grid-template-columns: 1fr;
    }

    .status-wrap {
        width: fit-content;
    }

    .speech-buttons {
        flex-direction: column;
    }
}
