:root {
    --aegyo-ink: #111015;
    --aegyo-panel: #1b1820;
    --aegyo-panel-deep: #15121a;
    --aegyo-paper: #fff8eb;
    --aegyo-orange: #ff7a1a;
    --aegyo-pink: #ff5d8f;
    --aegyo-mint: #59d9c3;
    --aegyo-line: rgba(255, 248, 235, 0.16);
    --aegyo-muted: rgba(255, 248, 235, 0.58);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    background-color: var(--aegyo-ink);
    color: var(--aegyo-paper);
    font-family: "Space Grotesk", "Pretendard", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.aegyo-body {
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        linear-gradient(90deg, rgba(255, 248, 235, 0.035) 1px, transparent 1px),
        linear-gradient(rgba(255, 248, 235, 0.035) 1px, transparent 1px);
    background-size: 32px 32px;
}

.aegyo-corner {
    position: fixed;
    z-index: 20;
    top: 18px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--aegyo-line);
    background: rgba(17, 16, 21, 0.86);
    color: var(--aegyo-paper);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.aegyo-corner:hover {
    border-color: var(--aegyo-orange);
    background: #201b23;
    color: var(--aegyo-orange);
}

.aegyo-corner:focus-visible,
.aegyo-icon-btn:focus-visible,
.aegyo-draw-button:focus-visible,
.aegyo-recent-item:focus-visible {
    outline: 3px solid var(--aegyo-mint);
    outline-offset: 3px;
}

.aegyo-corner--back { left: 18px; }
.aegyo-corner--brand { right: 18px; }

.aegyo-main {
    width: min(960px, calc(100% - 32px));
    margin: 0 auto;
    padding: clamp(6.7rem, 10vw, 8.6rem) 0 3rem;
}

.aegyo-header { text-align: center; margin-bottom: clamp(1.7rem, 4vw, 3.2rem); }

.aegyo-eyebrow {
    margin: 0 0 0.7rem;
    color: var(--aegyo-mint);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.aegyo-header h1 {
    margin: 0;
    color: var(--aegyo-paper);
    font-family: "Do Hyeon", sans-serif;
    font-size: clamp(2.7rem, 8vw, 5.4rem);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 0.96;
}

.aegyo-subtitle { margin: 1rem 0 0; color: var(--aegyo-muted); font-size: clamp(0.9rem, 2vw, 1.05rem); }

.aegyo-customize {
    width: min(560px, 100%);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 0.7rem;
    margin: 0 auto clamp(1.5rem, 3vw, 2.3rem);
    padding: 0.75rem;
    border: 1px solid var(--aegyo-line);
    background: rgba(27, 24, 32, 0.72);
}

.aegyo-field { min-width: 0; display: grid; gap: 0.35rem; }
.aegyo-field span { color: var(--aegyo-muted); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; }
.aegyo-field input {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--aegyo-line);
    border-radius: 6px;
    background: var(--aegyo-panel-deep);
    color: var(--aegyo-paper);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
    padding: 0.5rem 0.65rem;
}
.aegyo-field input:focus { border-color: var(--aegyo-mint); box-shadow: 0 0 0 3px rgba(89, 217, 195, 0.16); }
.aegyo-customize-mark { padding-bottom: 0.55rem; color: var(--aegyo-pink); font-family: "Do Hyeon", sans-serif; font-size: 1.3rem; }

.aegyo-stage {
    position: relative;
    min-height: clamp(370px, 53vw, 500px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--aegyo-line);
    background: var(--aegyo-panel-deep);
    box-shadow: 12px 12px 0 rgba(255, 93, 143, 0.16), -8px -8px 0 rgba(89, 217, 195, 0.08);
}

.aegyo-stage::before,
.aegyo-stage::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.aegyo-stage::before {
    inset: 14px;
    border: 1px dashed rgba(255, 248, 235, 0.11);
}

.aegyo-stage::after {
    width: 170%;
    height: 38px;
    bottom: -18px;
    left: -35%;
    background: repeating-linear-gradient(90deg, var(--aegyo-orange) 0 22px, var(--aegyo-pink) 22px 44px, var(--aegyo-mint) 44px 66px, var(--aegyo-paper) 66px 88px);
    transform: rotate(-3deg);
    opacity: 0.95;
}

.aegyo-stage-topline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 11px;
}

.aegyo-stage-topline span:nth-child(1), .aegyo-stage-topline span:nth-child(4) { background: var(--aegyo-orange); }
.aegyo-stage-topline span:nth-child(2), .aegyo-stage-topline span:nth-child(5) { background: var(--aegyo-pink); }
.aegyo-stage-topline span:nth-child(3) { background: var(--aegyo-mint); }

.aegyo-result {
    position: relative;
    z-index: 2;
    width: min(740px, calc(100% - 58px));
    min-height: 230px;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: clamp(1.8rem, 5vw, 3.8rem) clamp(1.2rem, 5vw, 4.6rem);
    border: 2px solid var(--aegyo-paper);
    border-radius: 8px;
    background: var(--aegyo-panel);
    text-align: center;
    box-shadow: 8px 8px 0 var(--aegyo-orange);
    transform-origin: center;
}

.aegyo-result-label {
    margin-bottom: 0.8rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid rgba(89, 217, 195, 0.7);
    color: var(--aegyo-mint);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.aegyo-quote-mark {
    position: absolute;
    top: clamp(0.5rem, 2vw, 1.1rem);
    left: clamp(0.7rem, 2vw, 1.4rem);
    margin: 0;
    color: var(--aegyo-pink);
    font-family: Georgia, serif;
    font-size: clamp(4rem, 9vw, 7rem);
    line-height: 0.75;
}

.aegyo-phrase {
    width: 100%;
    min-width: 0;
    max-width: 17em;
    color: var(--aegyo-paper);
    font-family: "Do Hyeon", sans-serif;
    font-size: clamp(2.1rem, 5.6vw, 4.2rem);
    font-weight: 400;
    line-height: 1.2;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: normal;
}

.aegyo-result.has-long-phrase {
    min-height: 320px;
    padding-block: clamp(2.3rem, 5vw, 3.9rem);
}

.aegyo-result.has-long-phrase .aegyo-phrase {
    max-width: min(22em, 100%);
    font-size: clamp(1.35rem, 3.1vw, 2.35rem);
    line-height: 1.42;
}

.aegyo-reading { min-height: 1.4em; margin: 1.1rem 0 0; color: var(--aegyo-muted); font-size: 0.82rem; }

.aegyo-result-tools { position: absolute; top: 0.8rem; right: 0.8rem; }

.aegyo-icon-btn {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--aegyo-line);
    border-radius: 8px;
    background: transparent;
    color: var(--aegyo-paper);
    cursor: pointer;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.aegyo-icon-btn:hover { border-color: var(--aegyo-mint); background: rgba(89, 217, 195, 0.1); color: var(--aegyo-mint); }
.aegyo-icon-btn--muted { width: 36px; height: 36px; color: var(--aegyo-muted); }

.aegyo-stage-foot {
    position: absolute;
    z-index: 3;
    right: 20px;
    bottom: 25px;
    left: 20px;
    display: flex;
    justify-content: space-between;
    color: var(--aegyo-ink);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.aegyo-stage-count b { font-variant-numeric: tabular-nums; }

.aegyo-actions { display: flex; justify-content: center; padding: clamp(1.7rem, 4vw, 2.7rem) 0; }

.aegyo-draw-button {
    min-width: min(100%, 320px);
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    border: 2px solid var(--aegyo-orange);
    border-radius: 8px;
    background: var(--aegyo-orange);
    color: var(--aegyo-ink);
    font-family: "Do Hyeon", sans-serif;
    font-size: 1.35rem;
    cursor: pointer;
    box-shadow: 6px 6px 0 var(--aegyo-pink);
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.aegyo-draw-button:hover { background: #ff922f; transform: translate(-2px, -2px); box-shadow: 9px 9px 0 var(--aegyo-pink); }
.aegyo-draw-button:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--aegyo-pink); }
.aegyo-draw-button:disabled { cursor: wait; opacity: 0.7; transform: none; box-shadow: 3px 3px 0 var(--aegyo-pink); }

.aegyo-recent { width: min(680px, 100%); margin: 0 auto; padding-top: 1.5rem; border-top: 1px solid var(--aegyo-line); }
.aegyo-recent-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.aegyo-recent-heading h2 { margin: 0; color: var(--aegyo-paper); font-size: 0.8rem; letter-spacing: 0.08em; }
.aegyo-recent-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; min-width: 0; margin: 0; padding: 0; list-style: none; }
.aegyo-recent-list > li { min-width: 0; }

.aegyo-recent-item {
    width: 100%;
    min-height: 44px;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    overflow: hidden;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--aegyo-line);
    border-radius: 8px;
    background: transparent;
    color: var(--aegyo-paper);
    text-align: left;
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease;
}

.aegyo-recent-item:hover { border-color: rgba(255, 122, 26, 0.8); background: rgba(255, 122, 26, 0.08); }
.aegyo-recent-number { flex: 0 0 auto; margin-top: 0.18rem; color: var(--aegyo-pink); font-size: 0.68rem; font-weight: 700; }
.aegyo-recent-text {
    min-width: 0;
    color: var(--aegyo-paper);
    font-size: 0.88rem;
    line-height: 1.58;
    overflow-wrap: anywhere;
    white-space: pre-line;
    word-break: normal;
}
.aegyo-recent-empty { padding: 0.9rem 0; color: var(--aegyo-muted); font-size: 0.86rem; }

.aegyo-source {
    width: min(680px, 100%);
    margin: 1.25rem auto 0;
    color: var(--aegyo-muted);
    font-size: 0.72rem;
    line-height: 1.6;
    text-align: center;
}

.aegyo-source a {
    color: var(--aegyo-mint);
    text-decoration-color: rgba(89, 217, 195, 0.48);
    text-underline-offset: 0.2em;
}

.aegyo-source a:hover { color: var(--aegyo-paper); }
.aegyo-source a:focus-visible { outline: 2px solid var(--aegyo-mint); outline-offset: 3px; }

.aegyo-result.is-shuffling { animation: aegyo-jitter 110ms steps(2, end) infinite; }
.aegyo-result.is-revealed { animation: aegyo-reveal 420ms cubic-bezier(0.16, 1.25, 0.3, 1); }
.aegyo-result.is-copy-success .aegyo-icon-btn { border-color: var(--aegyo-mint); color: var(--aegyo-mint); }

@keyframes aegyo-jitter {
    0% { transform: translate(-2px, 1px) rotate(-0.5deg); }
    100% { transform: translate(2px, -1px) rotate(0.5deg); }
}

@keyframes aegyo-reveal {
    0% { transform: scale(0.86) rotate(-1.5deg); opacity: 0.25; }
    65% { transform: scale(1.035) rotate(0.4deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    contain: layout paint;
    overflow-wrap: anywhere;
    white-space: normal;
    border: 0;
}

@media (max-width: 620px) {
    .aegyo-main { width: min(calc(100% - 24px), 960px); padding-top: 6.1rem; }
    .aegyo-corner { top: 12px; }
    .aegyo-corner--back { left: 12px; }
    .aegyo-corner--brand { right: 12px; }
    .aegyo-corner span { display: none; }
    .aegyo-stage { min-height: 390px; box-shadow: 6px 6px 0 rgba(255, 93, 143, 0.16); }
    .aegyo-result { width: calc(100% - 36px); min-height: 250px; padding-inline: 1.25rem; box-shadow: 5px 5px 0 var(--aegyo-orange); }
    .aegyo-phrase { max-width: min(12em, 100%); }
    .aegyo-result.has-long-phrase { min-height: 310px; padding-block: 2.5rem 2rem; }
    .aegyo-result.has-long-phrase .aegyo-phrase { max-width: min(15em, 100%); font-size: clamp(1.2rem, 5.1vw, 1.65rem); line-height: 1.4; }
    .aegyo-stage-foot { bottom: 23px; font-size: 0.56rem; }
    .aegyo-customize { gap: 0.45rem; padding: 0.6rem; }
    .aegyo-field span { font-size: 0.56rem; }
    .aegyo-field input { min-height: 38px; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
