:root {
    --page-bg: #171719;
    --surface: #202024;
    --ink: #f4f1ed;
    --muted: #a49b94;
    --accent: #f4abba;
    --border: #39393e;
    --font-body: 'Montserrat', system-ui, sans-serif;
    --font-display: 'Lora', Georgia, serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 40px 20px;
    background: var(--page-bg);
    color: var(--ink);
    font-family: var(--font-body);
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

header {
    margin-bottom: 35px;
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 400;
    letter-spacing: -1.5px;
    margin: 0 0 8px;
}

section {
    margin-bottom: 25px;
}

.field-label {
    display: block;
    margin: 0 0 9px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

textarea {
    display: block;
    width: 100%;
    min-height: 105px;
    padding: 15px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    outline: none;
}

textarea:focus {
    border-color: var(--ink);
}

.field-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
}

.hint.warn {
    color: var(--accent);
}

.char-count {
    flex: 0 0 auto;
    text-align: right;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

button {
    font-family: var(--font-body);
}

.generate-btn,
.secondary-btn {
    padding: 13px 22px;
    border: 1px solid var(--ink);
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity .2s;
}

.generate-btn {
    background: var(--ink);
    color: var(--page-bg);
}

.secondary-btn {
    background: transparent;
    color: var(--ink);
}

.generate-btn:hover,
.secondary-btn:hover {
    opacity: .7;
}

button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.output-section {
    border-top: 1px solid var(--border);
    padding-top: 22px;
}

.output-section .field-label {
    margin-bottom: 15px;
}

/* OUTPUT CANVAS */

.output {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    width: 100%;
    min-height: 220px;
    padding: 25px 15px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    overflow: visible;
    row-gap: 12px;
}

.output-message {
    max-width: 52ch;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

/* WORD GROUPS */

.word {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    white-space: nowrap;
    break-inside: avoid;
    margin-right: 40px;
}

/* CUTOUT LETTERS */

.letter {
    display: block;
    flex: 0 0 auto;
    width: auto;
    height: var(--letter-height, 100px);
    margin: 0;
    margin-right: var(--letter-overlap, -10px);
    background: transparent;
    transform: rotate(var(--rotation));
    transform-origin: center;
    position: relative;
    user-select: none;
}

.letter img {
    display: block;
    width: auto;
    height: 100%;
    max-width: none;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.letter:nth-child(3n) {
    z-index: 2;
}

.letter:nth-child(3n + 1) {
    z-index: 1;
}

.letter:nth-child(3n + 2) {
    z-index: 3;
}

/* Declared after the nth-child rules so it wins at equal specificity */
.letter.letter--i {
    z-index: 10;
}

/* LINE BREAKS */

.word.newline {
    flex-basis: 100%;
    width: 100%;
    height: 0;
    margin: 0;
}

/* FIXED-WIDTH OFFSCREEN STAGE USED FOR EXPORT */

.output.export-stage {
    position: fixed;
    top: 0;
    left: -10000px;
    width: 1000px;
    min-height: 0;
    padding: 25px 15px;
    border: none;
    border-radius: 0;
    background: transparent;
    pointer-events: none;
}

.output.export-stage .word {
    margin-right: 40px;
}

/* FOOTER */

footer {
    margin-top: 20px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

footer a {
    color: #ffffff;
    text-decoration: underline;
}

footer a:hover {
    color: var(--accent);
}

/* MOBILE */

@media (max-width: 600px) {
    body {
        padding: 25px 14px;
    }

    .output {
        padding: 18px 8px;
        min-height: 160px;
        row-gap: 10px;
    }

    .word {
        margin-right: 16px;
    }

    .generate-btn,
    .secondary-btn {
        padding: 12px 15px;
    }
}
