:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --danger: #b91c1c;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

button,
input,
textarea {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.app-card {
    padding: 28px;
}

.app-title {
    margin: 0 0 8px;
    font-size: 1.75rem;
    line-height: 1.15;
}

.app-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 0.98rem;
}

.form {
    display: grid;
    gap: 14px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin: 0 0 8px;
}

.form-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 14px 16px;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.form-actions {
    display: flex;
    justify-content: flex-start;
}

.button {
    appearance: none;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    padding: 12px 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.output-wrap {
    margin-top: 24px;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.result-card--error {
    border-color: #fecaca;
}

.result-card__title {
    margin: 0 0 14px;
    font-size: 1.2rem;
    line-height: 1.2;
}

/* This keeps the first "Result" header and removes extra visual gap before the first line */
.result-section+.result-section {
    margin-top: 18px;
}

.result-section__title {
    margin: 0 0 6px;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--muted);
    text-transform: none;
}

.result-section__body>*:first-child {
    margin-top: 0;
}

.result-section__body>*:last-child {
    margin-bottom: 0;
}

/* Tightened spacing under Thai Translation / Context / Example */
.thai-line {
    margin: 0 0 4px;
    font-size: 1.4rem;
    line-height: 1.35;
    font-weight: 700;
    color: var(--text);
}

.romanization-line {
    margin: 0;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--muted);
}

.section-paragraph {
    margin: 0;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
}

/* Tightened example spacing */
.example-line {
    margin: 0;
    line-height: 1.5;
}

.example-line+.example-line {
    margin-top: 4px;
}

.example-line--english {
    font-weight: 600;
}

.example-line--thai {
    font-size: 1.05rem;
}

.example-line--romanization {
    color: var(--muted);
}

/* Optional section styled like the "Variation" layout idea */
.line-block+.line-block {
    margin-top: 12px;
}

.line-block__label {
    margin: 0 0 3px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--muted);
}

.line-block__value {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
}

.is-loading .form-textarea,
.is-loading .button {
    pointer-events: none;
}

@media (max-width: 640px) {
    .page {
        width: min(100% - 20px, 760px);
        margin: 20px auto 36px;
    }

    .app-card,
    .result-card {
        padding: 18px;
    }

    .app-title {
        font-size: 1.45rem;
    }

    .thai-line {
        font-size: 1.2rem;
    }
}