:root {
    color-scheme: dark;
    --bg: #111318;
    --bg-soft: #171a21;
    --panel: rgba(26, 30, 38, 0.88);
    --panel-strong: #1d222c;
    --card: #151922;
    --text: #f6f7fb;
    --muted: #a9b0bf;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --accent: #27b277;
    --accent-strong: #1f9a66;
    --blue: #377df0;
    --amber: #d98a18;
    --red: #d84a4a;
    --violet: #8f63d9;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(39, 178, 119, 0.16), transparent 34rem),
        linear-gradient(135deg, #101218 0%, #191d24 52%, #101216 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.08;
}

h2 {
    margin-bottom: 4px;
    font-size: 19px;
    line-height: 1.2;
}

h3 {
    margin-bottom: 10px;
    font-size: 15px;
    line-height: 1.25;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 14px;
}

.panel {
    margin-top: 16px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.prompt-form {
    display: grid;
    gap: 16px;
}

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

.field {
    display: grid;
    gap: 7px;
}

label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

select,
input,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: #11151d;
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    min-height: 104px;
    resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(39, 178, 119, 0.16);
}

::placeholder {
    color: #727b8c;
}

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

button {
    min-height: 42px;
    padding: 11px 14px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

button:focus-visible {
    outline: 3px solid rgba(39, 178, 119, 0.36);
    outline-offset: 2px;
}

.primary-btn,
.tab-btn.active {
    background: var(--accent);
    box-shadow: 0 10px 24px rgba(39, 178, 119, 0.22);
}

.theme-toggle-btn {
    width: auto;
    min-width: 166px;
    background: #303743;
}

.random-btn {
    background: var(--violet);
}

.improve-btn {
    background: #7057d9;
}

.copy-btn {
    background: var(--blue);
}

.favorite-btn {
    background: var(--amber);
}

.clear-btn {
    background: var(--red);
}

.export-btn,
.tool-card button {
    width: auto;
    min-height: 38px;
    padding-inline: 13px;
    background: #208f72;
}

#output {
    display: block;
    min-height: 118px;
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: #0d1118;
    color: var(--text);
    line-height: 1.65;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.comparison-box,
.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.comparison-card,
.suggestions-box,
.list-box,
.tool-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

.comparison-card,
.suggestions-box,
.list-box {
    padding: 15px;
}

#beforeOutput,
#afterOutput {
    min-height: 58px;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.score-box {
    margin-top: 16px;
}

#scoreLabel {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.score-bar {
    height: 11px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #10141c;
}

#scoreFill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.25s ease, background 0.25s ease;
}

.suggestions-box {
    margin-top: 16px;
}

.suggestion-item,
#historyList li,
#favoritesList li {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-strong);
    color: var(--text);
    font-size: 13px;
    overflow-wrap: anywhere;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.suggestion-item {
    width: 100%;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
}

.suggestion-item:hover,
#historyList li:hover,
#favoritesList li:hover {
    border-color: var(--border-strong);
    background: #222835;
}

.small {
    min-height: 21px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
}

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

.tab-btn {
    border: 1px solid var(--border);
    background: #252b36;
    color: var(--text);
}

.search-box {
    margin-top: 14px;
}

.tab-content {
    display: none;
    margin-top: 14px;
}

.tab-content.active {
    display: block;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#historyList,
#favoritesList {
    margin: 0;
    padding: 0;
    list-style: none;
}

.prompt-text {
    cursor: pointer;
}

.remove-btn {
    width: auto;
    min-height: 34px;
    margin-top: 10px;
    padding: 8px 11px;
    background: #4b5564;
    font-size: 13px;
}

.tool-card {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 15px;
}

.tool-card h3,
.tool-card p {
    margin-bottom: 0;
}

.tool-card p {
    color: var(--muted);
    font-size: 13px;
}

#toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10;
    max-width: min(340px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: var(--radius);
    background: #242b36;
    color: #ffffff;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.32);
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

#toast.show {
    opacity: 1;
    transform: translateY(0);
}

#toast.success {
    background: var(--accent-strong);
}

#toast.error {
    background: var(--red);
}

#toast.info {
    background: var(--blue);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.light-mode {
    color-scheme: light;
    --bg: #f3f5f7;
    --bg-soft: #ffffff;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #f3f6f9;
    --card: #ffffff;
    --text: #151922;
    --muted: #5f6876;
    --border: rgba(21, 25, 34, 0.12);
    --border-strong: rgba(21, 25, 34, 0.22);
    --shadow: 0 20px 54px rgba(30, 40, 55, 0.14);
    background:
        radial-gradient(circle at top left, rgba(39, 178, 119, 0.14), transparent 32rem),
        linear-gradient(135deg, #f5f7f9 0%, #e8edf2 100%);
}

body.light-mode select,
body.light-mode input,
body.light-mode textarea,
body.light-mode #output {
    background: #ffffff;
    color: var(--text);
}

body.light-mode .theme-toggle-btn,
body.light-mode .tab-btn {
    background: #e6ebf1;
    color: var(--text);
}

body.light-mode .tab-btn.active {
    color: #ffffff;
}

body.light-mode .score-bar {
    background: #e7ebef;
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 24px, 620px);
        padding: 18px 0 24px;
    }

    .app-header {
        align-items: stretch;
        flex-direction: column;
    }

    .theme-toggle-btn {
        width: 100%;
    }

    .panel {
        padding: 18px;
    }

    .form-grid,
    .action-grid,
    .comparison-box,
    .tools-grid {
        grid-template-columns: 1fr;
    }

    select,
    input,
    textarea {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .app-shell {
        width: min(100% - 18px, 620px);
    }

    .panel {
        padding: 15px;
    }

    .tabs,
    .list-header {
        grid-template-columns: 1fr;
    }

    .list-header {
        align-items: stretch;
        flex-direction: column;
    }

    .export-btn {
        width: 100%;
    }

    #toast {
        right: 12px;
        bottom: 12px;
        left: 12px;
        max-width: none;
    }
}
