@import url('https://fonts.googleapis.com/css2?family=Annie+Use+Your+Telescope&display=swap');

/* ─── TOKENS ─────────────────────────────────────────────────────────────────── */
:root {
    --bg:          #0e0f12;
    --panel:       #16181d;
    --text:        #e7e8ea;
    --muted:       #9aa0a6;
    --accent:      #CC5500;
    --border:      #262a33;
    --handwriting: 'Annie Use Your Telescope', cursive;
    --ui:          system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* ─── RESET & BASE ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 var(--ui);
    display: flex;
    overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */
.sidebar {
    flex-shrink: 0;
    width: 280px;
    height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
}

.brand { text-align: center; }
.brand h1 { margin: 0; font-size: 20px; font-weight: normal; }
.brand .tagline { margin: -4px 0 16px 0; color: var(--muted); font-size: 13px; }

.photo img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    max-height: 500px;
    object-fit: cover;
    margin-bottom: 1em;
}

.minibio { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.minibio p { margin: 0; }

.sidebar nav ul { list-style: none; padding: 0; margin: 12px 0 0 0; }
.sidebar nav li { margin: 8px 0; font-size: 14px; }

.sidebar-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.sidebar-section strong {
    display: block;
    color: var(--text);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.sidebar footer {
    position: sticky;
    bottom: 0;
    padding-top: 16px;
    color: var(--muted);
    font-size: 12px;
    background: linear-gradient(to top, var(--panel), transparent);
}

/* ─── MAIN CONTENT COLUMN ────────────────────────────────────────────────────── */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    padding: 0 40px;
    max-width: 800px;
}

/* ─── PAGE HEADER (sticky, non-scrolling) ────────────────────────────────────── */
.poem-header {
    flex-shrink: 0;
    padding: 32px 0 20px 0;
    border-bottom: 1px solid var(--border);
}

.poem-title {
    font-family: var(--ui);
    font-size: 15px;
    font-weight: normal;
    color: var(--text);
    letter-spacing: 0.04em;
    margin: 0 0 4px 0;
}

.poem-description {
    font-family: var(--ui);
    font-size: 12px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

/* ─── SCROLL AREA ────────────────────────────────────────────────────────────── */
.poem-scroll {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Fade overlay at top — stays fixed as content scrolls beneath */
.poem-scroll-nolongerusing-coloncolonbefore {
    content: '';
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    display: block;
    height: 64px;
    margin-bottom: -64px;
    background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%);
    pointer-events: none;
    z-index: 2;
}

/* ─── COUPLET LIST ───────────────────────────────────────────────────────────── */
.poem {
    font-family: var(--handwriting);
    font-size: 1.55em;
    line-height: 1.9;
    color: var(--text);
    padding: 20px 0 48px 0;
}

.couplet {
    margin-bottom: 1.4em; /* breathing room between entries */
    padding-bottom: 1.4em;
    border-bottom: 1px solid var(--border);
}

.couplet:last-child {
    border-bottom: none;
}

/* Date label above each couplet */
.couplet-date {
    display: inline;
    font-family: var(--ui);
    font-size: 0.42em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.3em;
    user-select: none;
}

.couplet-time {
    display: inline;
    font-family: var(--ui);
    font-size: 0.42em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #232323;
    margin-bottom: 0.3em;
    user-select: none;
}

.couplet-line {
    display: block;
}

.constraint-word {

    color: var(--muted);
}

.poem-empty {
    font-family: var(--ui);
    color: var(--muted);
    font-size: 14px;
    font-style: italic;
    padding-top: 48px;
}

/* ─── GENERAL PAGE CONTENT ───────────────────────────────────────────────────── */
.page-content h1 {
    font-size: 22px;
    font-weight: normal;
    margin: 0 0 6px 0;
}

.page-content .page-meta {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 20px;
}

.page-content p { margin: 0 0 1em 0; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
button {
    background: var(--accent);
    color: #0b1115;
    border: 0;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--ui);
}

button:hover:not(:disabled) { opacity: .9; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ─── FORM ELEMENTS ──────────────────────────────────────────────────────────── */
label { display: block; margin: 10px 0 6px 0; color: var(--muted); font-size: 13px; }

input[type=text],
input[type=password],
textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #111317;
    color: var(--text);
    font-family: var(--ui);
    font-size: 1em;
}

textarea { resize: vertical; }

input:focus, textarea:focus {
    outline: none;
    border-color: #4a4f5a;
}

input:disabled, textarea:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ─── STATUS MESSAGES ────────────────────────────────────────────────────────── */
.status {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
    min-height: 1.4em;
    margin-top: 10px;
}

.status.error { color: #9e4a4a; }
.status.ok    { color: #5a8a5a; }

/* ─── POST PAGE ──────────────────────────────────────────────────────────────── */
.post-wrap { max-width: 520px; }

.word-label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

#word-display {
    font-family: var(--handwriting);
    font-size: 2.6em;
    color: var(--text);
    margin-bottom: 2px;
    line-height: 1.2;
}

#timer {
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 24px;
}

#timer.urgent { color: #9e4a4a; }

.line-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--border);
    margin-bottom: 4px;
}

.couplet-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.couplet-form textarea {
    font-family: var(--handwriting);
    font-size: 1.3em;
    min-height: 52px;
    line-height: 1.5;
    background: var(--panel);
    border-color: var(--border);
    border-radius: 6px;
    padding: 10px 14px;
}

.couplet-form textarea:focus { border-color: #4a4f5a; }

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.btn-replace {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    font-weight: normal;
    font-size: 13px;
    padding: 8px 14px;
}

.btn-replace:hover:not(:disabled) {
    border-color: var(--muted);
    color: var(--text);
    opacity: 1;
}

.btn-replace:disabled { border-color: var(--border); color: var(--border); }

.btn-submit {
    background: transparent;
    border: 1px solid #3a4f3a;
    color: #7a9a7a;
    border-radius: 6px;
    font-weight: normal;
    font-size: 13px;
    padding: 8px 14px;
}

.btn-submit:hover:not(:disabled) {
    border-color: #7a9a7a;
    color: #a0c0a0;
    opacity: 1;
}

.btn-submit:disabled { border-color: var(--border); color: var(--border); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
    body {
        display: block;
        overflow: auto;
    }

    .sidebar {
        width: auto;
        height: auto;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: grid;
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        align-items: center;
    }

    .sidebar .photo img { max-height: 180px; }

    .sidebar > footer {
        grid-column: 1 / -1;
        position: static;
        background: none;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    .sidebar-section { margin-top: 0; padding-top: 0; border-top: none; }

    .content {
        height: auto;
        padding: 16px;
    }

    .poem-scroll {
        overflow: visible;
    }

    .poem-scroll::before { display: none; }
}
