:root {
    --bg: #f5efe4;
    --bg-accent: #e4d4b2;
    --panel: rgba(255, 250, 242, 0.92);
    --border: rgba(85, 66, 37, 0.16);
    --text: #2b2115;
    --muted: #705b3a;
    --button: #b6462f;
    --button-hover: #963724;
    --shadow: 0 18px 45px rgba(67, 46, 18, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 32%),
        linear-gradient(135deg, var(--bg), #f0e2c8 45%, var(--bg-accent));
}

.page-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0 64px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

.hero-copy {
    flex: 1;
}

.control-stack {
    width: min(280px, 100%);
    display: grid;
    gap: 14px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2.2rem, 5vw, 4rem);
    line-height: 0.95;
}

.subtitle {
    max-width: 700px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.generate-button {
    border: 0;
    border-radius: 999px;
    padding: 16px 28px;
    color: #fff;
    background: var(--button);
    box-shadow: var(--shadow);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

.generate-button:hover:not(:disabled) {
    background: var(--button-hover);
    transform: translateY(-1px);
}

.generate-button:disabled {
    cursor: wait;
    opacity: 0.75;
}

.size-control {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
}

.size-control input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    color: var(--text);
    background: rgba(255, 250, 242, 0.85);
    font: inherit;
}

.size-control input:focus {
    outline: 2px solid rgba(182, 70, 47, 0.25);
    outline-offset: 2px;
}

.status-message {
    min-height: 24px;
    margin: 0 0 22px;
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 18px;
}

.panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 1rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.panel-content {
    min-height: 82px;
    font-size: 1.08rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.panel-content-large {
    min-height: 112px;
    font-size: 1.5rem;
}

.empty-state {
    color: var(--muted);
}

.word-chip {
    display: inline;
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
    border-bottom: 2px solid rgba(182, 70, 47, 0.28);
    transition: border-color 0.18s ease, color 0.18s ease;
}

.word-chip:hover {
    color: var(--button);
    border-color: rgba(182, 70, 47, 0.8);
}

.word-popover {
    position: absolute;
    z-index: 20;
    width: min(280px, calc(100vw - 24px));
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(43, 33, 21, 0.94);
    box-shadow: var(--shadow);
    color: #fff6eb;
}

.hidden {
    display: none;
}

.popover-word {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 700;
}

.popover-line {
    margin: 4px 0 0;
    color: rgba(255, 246, 235, 0.86);
}

@media (max-width: 760px) {
    .page-shell {
        width: min(100% - 20px, 1080px);
        padding-top: 28px;
    }

    .hero {
        flex-direction: column;
    }

    .generate-button {
        width: 100%;
    }

    .panel {
        padding: 18px;
    }

    .panel-content-large {
        font-size: 1.3rem;
    }
}
