* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    --bg: #fcf6f4;
    --surface: #fffaf8;
    --surface-elevated: #ffffff;
    --text: #241919;
    --muted: #7f6767;
    --accent: #b42318;
    --accent-strong: #8f1d14;
    --accent-soft: rgba(180, 35, 24, 0.12);
    --accent-glow: rgba(180, 35, 24, 0.18);
    --border: rgba(97, 36, 31, 0.12);
    --button-border: rgba(125, 43, 37, 0.22);
    --button-bg: rgba(255, 255, 255, 0.96);
    --button-text: #6f4442;
    --button-hover-bg: #b42318;
    --button-hover-text: #fff7f6;
    --timer-bg: #8f1d14;
    --timer-text: #fff7f6;
    --output-bg: #fff4f1;
    --panel-bg: #fff6f3;
    --panel-border: rgba(137, 43, 36, 0.14);
    --shadow: 0 24px 60px rgba(91, 24, 21, 0.12);
    --review-bg: rgba(255, 248, 246, 0.62);
    --review-text: rgba(88, 39, 36, 0.54);
    --review-author: rgba(121, 62, 57, 0.42);
    --toggle-track: rgba(180, 35, 24, 0.2);
    --toggle-knob: #ffffff;
    --toggle-track-active: #b42318;
}
body.dark-theme {
    --bg: #140d0d;
    --surface: #1d1212;
    --surface-elevated: #241616;
    --text: #fff1ef;
    --muted: rgba(255, 224, 220, 0.72);
    --accent: #ff5b4d;
    --accent-strong: #ff7f74;
    --accent-soft: rgba(255, 91, 77, 0.14);
    --accent-glow: rgba(255, 91, 77, 0.22);
    --border: rgba(255, 162, 153, 0.12);
    --button-border: rgba(255, 163, 154, 0.2);
    --button-bg: #241616;
    --button-text: rgba(255, 235, 232, 0.82);
    --button-hover-bg: #ff5b4d;
    --button-hover-text: #180d0d;
    --timer-bg: #ff5b4d;
    --timer-text: #180d0d;
    --output-bg: #241616;
    --panel-bg: #241616;
    --panel-border: rgba(255, 163, 154, 0.12);
    --shadow: 0 28px 80px rgba(0,0,0,0.42);
    --review-bg: rgba(255, 91, 77, 0.08);
    --review-text: rgba(255, 229, 225, 0.46);
    --review-author: rgba(255, 210, 205, 0.3);
    --toggle-track: rgba(255, 91, 77, 0.24);
    --toggle-knob: #fff1ef;
    --toggle-track-active: #ff5b4d;
}
body {
    font-family: monospace;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    color: var(--text);
    position: relative;
    overflow-x: hidden;
    transition: background 0.2s ease, color 0.2s ease;
}
body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}
body::before {
    top: 4%;
    left: 3%;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, rgba(180, 35, 24, 0.1) 0%, rgba(255, 255, 255, 0) 72%);
}
body::after {
    right: 4%;
    bottom: 2%;
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(180, 35, 24, 0.07) 0%, rgba(255, 255, 255, 0) 74%);
}
body:has(.setup-screen:not(.hidden))::before,
body:has(.setup-screen:not(.hidden))::after {
    opacity: 1;
}
.container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
    z-index: 2;
}
.container:has(.writing-screen:not(.hidden)) {
    max-width: 1200px;
}
.container:has(.complete-screen:not(.hidden)) {
    max-width: 1200px;
}
.setup-screen, .writing-screen {
    background: var(--surface);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.setup-screen {
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 34px 96px rgba(91, 24, 21, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.7) inset, var(--shadow);
}
.setup-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.12) 34%, var(--accent-soft) 100%);
    pointer-events: none;
}
.complete-screen {
    background: var(--surface);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
}
.setup-screen h1, .complete-screen h1 {
    margin-bottom: 20px;
    color: var(--text);
    text-align: center;
}
.setup-screen h1 {
    margin-bottom: 2px;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 0 18px var(--accent-soft);
}
.brand-subheading {
    margin-bottom: 14px;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--muted);
}
.brand-subheading a {
    color: var(--accent-strong);
    text-decoration: none;
}
.brand-subheading a:hover {
    text-decoration: underline;
}
.setup-screen p {
    margin-bottom: 30px;
    color: var(--muted);
    line-height: 1.6;
}
.controls-row {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}
.floating-reviews {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    display: none;
}
body:has(.setup-screen:not(.hidden)) .floating-reviews {
    display: block;
}
.review-card {
    position: absolute;
    width: min(280px, 26vw);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--review-bg);
    color: var(--review-text);
    box-shadow: 0 16px 38px rgba(75, 18, 15, 0.06);
    opacity: 0.28;
    backdrop-filter: blur(12px);
}
.review-card p {
    margin: 0;
    color: inherit;
    line-height: 1.5;
}
.review-author {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--review-author);
}
.container:has(.setup-screen:not(.hidden)) {
    max-width: 900px;
}
.review-pos-1 {
    top: 6%;
    left: 4%;
    transform: rotate(-4deg);
}
.review-pos-2 {
    top: 0%;
    right: 3%;
    transform: rotate(3deg);
}
.review-pos-3 {
    bottom: 22%;
    right: 2%;
    transform: rotate(2deg);
}
.review-pos-4 {
    right: 26%;
    bottom: 6%;
    width: min(340px, 30vw);
    transform: rotate(-2deg);
}
.review-pos-5 {
    bottom: 12%;
    left: 4%;
    transform: rotate(-1deg);
}
.time-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}
.mode-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}
.mode-label {
    font-size: 14px;
    color: var(--muted);
    font-weight: bold;
}
.group-separator {
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    opacity: 0.7;
    margin: 0 4px;
}
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-track);
    transition: 0.3s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--toggle-knob);
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--toggle-track-active);
}
input:checked + .slider:before {
    transform: translateX(26px);
}
.time-btn {
    padding: 10px 20px;
    border: 1px solid var(--button-border);
    background: var(--button-bg);
    cursor: pointer;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s;
    color: var(--button-text);
    box-shadow: 0 8px 20px rgba(91, 24, 21, 0.06);
}
.time-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}
.writing-screen {
    position: relative;
    min-height: 500px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-elevated) 0%, var(--surface) 100%);
}
.red-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s;
    z-index: 1;
}
#notepad {
    width: 100%;
    height: 500px;
    padding: 40px;
    padding-top: 50px;
    border: none;
    outline: none;
    font-family: monospace;
    font-size: 16px;
    resize: none;
    position: relative;
    z-index: 0;
    background: transparent;
    color: var(--text);
}
#notepad::placeholder {
    color: var(--muted);
}
.timer-display {
    position: absolute;
    top: 10px;
    right: 120px;
    background: var(--timer-bg);
    color: var(--timer-text);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12px;
    min-width: 96px;
    text-align: center;
    white-space: nowrap;
    z-index: 2;
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 12px 26px rgba(98, 21, 17, 0.22);
}
.writing-reset-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 8px 16px;
    border: 1px solid var(--button-border);
    background: var(--button-bg);
    color: var(--button-text);
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    box-shadow: 0 8px 20px rgba(91, 24, 21, 0.08);
}
.writing-reset-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}
.writing-screen:has(#redOverlay[style*="rgba(255, 0, 0"]) .writing-reset-btn,
.writing-screen:has(#redOverlay[style*="rgb(255, 0, 0"]) .writing-reset-btn {
    background: rgba(120, 12, 12, 0.88);
    border-color: rgba(255, 215, 215, 0.24);
    color: #fff4f3;
}

.writing-screen:has(#redOverlay[style*="rgba(255, 0, 0"]) .timer-display,
.writing-screen:has(#redOverlay[style*="rgb(255, 0, 0"]) .timer-display {
    background: rgba(120, 12, 12, 0.96);
    color: #fff4f3;
}
.style-options {
    display: flex;
    gap: 15px;
    margin: 20px 0;

}
.style-btn {
    padding: 8px 16px;
    border: 1px solid #666;
    background: white;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.2s;
}
.style-btn:hover, .style-btn.active {
    background: #666;
    color: white;
}
.output-text {
    margin: 20px 0;
    padding: 20px;
    background: var(--output-bg);
    border-radius: 16px;
    min-height: 200px;
    white-space: pre-wrap;
    font-family: monospace;
    color: var(--text);
    border: 1px solid var(--border);
}
.action-btn {
    padding: 8px 20px;
    background: var(--button-hover-bg);
    color: var(--button-hover-text);
    border: none;
    cursor: pointer;
    font-size: 13px;
    border-radius: 999px;
    margin-right: 10px;
    margin-top: 5px;
    box-shadow: 0 12px 24px rgba(98, 21, 17, 0.16);
}
.action-btn:hover {
    opacity: 0.92;
}
.api-section {
    margin: 15px 0;
    padding: 15px;
    background: var(--panel-bg);
    border-radius: 16px;
    border: 1px solid var(--panel-border);
}
.api-section p {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}
.api-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.hidden {
    display: none;
}
.domain-expand {
    display: inline-block;
}

.setup-screen strong,
.complete-screen strong {
    color: var(--accent);
}

@media (max-width: 640px) {
    body {
        height: auto;
        min-height: 100vh;
        padding: 24px 0;
    }

    .setup-screen, .complete-screen {
        padding: 24px;
    }

    .controls-row {
        gap: 12px;
    }

    .mode-selector {
        width: auto;
        min-width: 240px;
        justify-content: center;
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }

    .mode-selector .mode-label:first-child {
        text-align: right;
    }

    .mode-selector .mode-label:last-child {
        text-align: left;
    }

    .mode-selector .toggle {
        justify-self: center;
    }

    .group-separator {
        display: none;
    }

    .floating-reviews {
        display: none;
    }
}
