* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
}

/* ── Layout states ─────────────────────────────────────────────────────────── */

.container {
    display: flex;
    height: 100vh;
    transition: none; /* children transition individually */
}

/* Default: centered form, no PDF panel */
.panel.left {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: center;   /* don't stretch to full column height */
    margin-bottom: 24vh;   /* nudge slightly above true center */
    border-right: none;
    transition: width 0.45s cubic-bezier(.4,0,.2,1),
                max-width 0.45s cubic-bezier(.4,0,.2,1),
                padding 0.45s cubic-bezier(.4,0,.2,1),
                align-self 0s,
                opacity 0.3s ease;
    overflow: hidden;
}

/* In centered state, hide elements that only make sense post-processing */
.container:not(.split):not(.collapsed) .status-log,
.container:not(.split):not(.collapsed) #download-btn {
    display: none;
}

.panel.right {
    width: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: width 0.45s cubic-bezier(.4,0,.2,1);
}

/* Split state: 20/80 */
.container.split .panel.left {
    width: 20%;
    max-width: 20%;
    margin: 0;
    margin-bottom: 0;
    padding: 20px 16px;
    justify-content: flex-start;
    align-self: stretch;
    border-right: 1px solid #2a2a4a;
}

.container.split .panel.right {
    width: 80%;
}

/* Collapsed state: 0/100 */
.container.collapsed .panel.left {
    width: 0;
    max-width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
}

.container.collapsed .panel.right {
    width: 100%;
}

/* ── Toggle button on the divider ──────────────────────────────────────────── */

#toggle-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 20px;
    height: 48px;
    background: #2a2a4a;
    border: 1px solid #3a3a6a;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: #6666aa;
    font-size: 11px;
    padding: 0;
    transition: left 0.45s cubic-bezier(.4,0,.2,1), background 0.2s;
    left: 0; /* updated by JS */
}

#toggle-btn:hover { background: #3a3a5a; color: #aaaaee; }

.container.split  ~ #toggle-btn,
.container.collapsed ~ #toggle-btn { display: flex; }

/* Use adjacent sibling — button is after .container in DOM */
.container.split + #toggle-btn,
.container.collapsed + #toggle-btn { display: flex; }

/* ── Typography ────────────────────────────────────────────────────────────── */

h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #8888cc;
}

#about-link {
    font-size: 1.1rem;
    font-weight: 400;
    color: #8888cc;
    text-decoration: none;
    margin-left: 6px;
    vertical-align: baseline;
}

#about-link:hover { text-decoration: underline; }

/* ── About page (full-screen) ─────────────────────────────────────────────── */

#about-page {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #ffffff;
    color: #333333;
    overflow-y: auto;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

.about-nav {
    position: sticky;
    top: 0;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 16px 32px;
    max-width: 720px;
    margin: 0 auto;
}

.about-nav a {
    color: #4444aa;
    text-decoration: none;
    font-size: 0.9rem;
}

.about-nav a:hover { text-decoration: underline; }

.about-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.about-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5em;
    color: #1a1a1a;
}

.about-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 1.8em 0 0.5em;
    color: #1a1a1a;
}

.about-content p {
    margin: 0 0 0.9em;
}

.about-content ol,
.about-content ul {
    margin: 0 0 0.9em;
    padding-left: 1.5em;
}

.about-content li {
    margin-bottom: 0.35em;
}

.about-content b {
    font-weight: 700;
}

h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #6666aa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #aaa;
}

/* ── Form controls ─────────────────────────────────────────────────────────── */

.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

input[type="file"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16162a;
    color: #e0e0e0;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    min-width: 0;
}

input[type="file"]:focus { border-color: #6666aa; }

#clear-btn {
    width: auto;
    padding: 10px 16px;
    background: #882222;
    flex-shrink: 0;
}

#clear-btn:hover { background: #aa3333; }

button {
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #4444aa;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

button:hover { background: #5555bb; }
button:disabled { background: #333; cursor: not-allowed; color: #666; }

.mode-row {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-row label { margin-bottom: 0; }

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16162a;
    color: #e0e0e0;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236666aa' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select:focus { border-color: #6666aa; }

#random-opts {
    display: flex;
    align-items: center;
    gap: 10px;
}

#random-opts label { white-space: nowrap; margin-bottom: 0; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #aaa;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #6666aa;
    cursor: pointer;
    flex-shrink: 0;
}

#max-n {
    width: 60px;
    padding: 8px 10px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16162a;
    color: #e0e0e0;
    font-size: 0.9rem;
    outline: none;
    text-align: center;
}

#max-n:focus { border-color: #6666aa; }

/* ── Status log ────────────────────────────────────────────────────────────── */

.status-log {
    margin-top: 24px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#status-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    font-family: monospace;
}

#status-list li {
    padding: 6px 0;
    border-bottom: 1px solid #1e1e3a;
    color: #8a8;
}

/* ── Download button ───────────────────────────────────────────────────────── */

#download-btn {
    display: block;
    margin-top: 16px;
    padding: 10px;
    border-radius: 6px;
    background: #226622;
    color: #fff;
    font-size: 0.95rem;
    text-align: center;
    text-decoration: none;
    transition: background 0.2s;
    flex-shrink: 0;
}

#download-btn:hover { background: #338833; }

/* ── PDF panel ─────────────────────────────────────────────────────────────── */

#pdf-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 0.95rem;
    height: 100%;
    width: 100%;
    text-align: center;
    padding: 40px;
}

/* ── Reading view ──────────────────────────────────────────────────────────── */

#reader-view {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 48px 32px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#reader-view > * {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

#reader-view h2 {
    font-size: 1.35em;
    font-weight: 700;
    margin: 1.6em 0 0.6em;
    line-height: 1.3;
}

#reader-view h2:first-child {
    margin-top: 0;
}

#reader-view p {
    margin: 0 0 0.9em;
    text-align: justify;
    word-spacing: 0.02em;
}

#reader-view b {
    font-weight: 700;
}

#reader-view ol,
#reader-view ul {
    margin: 0 0 0.9em;
    padding-left: 1.5em;
}

#reader-view li {
    margin-bottom: 0.3em;
}

#reader-view h3 {
    font-size: 1.1em;
    font-weight: 700;
    margin: 1.4em 0 0.4em;
    line-height: 1.3;
    color: inherit;
    text-transform: none;
    letter-spacing: 0;
}

.page-sep {
    border: none;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    margin: 2.5em auto;
}

/* In centered state, show a subtle tagline under the form */
.panel.left .tagline {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #444466;
    text-align: center;
}

.container.split .tagline,
.container.collapsed .tagline {
    display: none;
}

.logo-row {
    text-align: center;
    margin-top: 16px;
}

.logo-mark {
    width: 48px;
    height: 48px;
    opacity: 0.35;
}

.container.split .logo-row,
.container.collapsed .logo-row {
    display: none;
}
