:root {
    color-scheme: light;
    --bg: #f4f5ef;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --line: rgba(17, 24, 39, 0.08);
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #1d4ed8;
    --accent-soft: rgba(29, 78, 216, 0.1);
    --danger: #b91c1c;
    --shadow: 0 18px 60px rgba(15, 23, 42, 0.08);
    font-family: "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(29, 78, 216, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(22, 163, 74, 0.09), transparent 24%),
        var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

.button-reset {
    appearance: none;
    border: 0;
    background: transparent;
}

.dashboard-shell {
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 1rem 1rem 0;
}

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.8rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
    backdrop-filter: blur(18px);
}

.page-shell {
    width: min(100vw - 1.5rem, 42rem);
    margin: 1rem auto 2rem;
}

.page-header {
    margin-bottom: 1rem;
}

.page-title {
    margin: 0;
    font-size: clamp(1.8rem, 7vw, 2.6rem);
}

.page-body {
    min-height: 60vh;
}

.empty-panel {
    min-height: 52vh;
    border-radius: 24px;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.72)),
        var(--surface);
    box-shadow: var(--shadow);
}

.home-shell {
    display: grid;
    gap: 0.85rem;
}

.home-actions {
    display: grid;
    gap: 0.85rem;
}

.home-link {
    display: block;
    width: 100%;
    padding: 1.1rem 1rem;
    border-radius: 22px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background:
        linear-gradient(135deg, rgba(29, 78, 216, 0.1), rgba(34, 197, 94, 0.08)),
        rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 44px rgba(15, 23, 42, 0.08);
    font-size: 1.05rem;
    font-weight: 700;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-card {
    width: min(440px, 100%);
    padding: 2rem;
    border-radius: 28px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    box-shadow: var(--shadow);
}

.login-title {
    margin: 0 0 0.5rem;
    font-size: 2rem;
}

.login-copy {
    margin: 0 0 1.5rem;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 1rem;
}

.form-field {
    display: grid;
    gap: 0.45rem;
}

.form-label {
    font-weight: 600;
}

.form-input {
    width: 100%;
    padding: 0.92rem 1rem;
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 16px;
    background: #fafaf9;
    font: inherit;
}

.form-input:focus {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    border-color: rgba(29, 78, 216, 0.4);
}

.login-button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    padding: 0.8rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.error-box {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: rgba(185, 28, 28, 0.08);
    color: var(--danger);
    font-size: 0.95rem;
}

.chat-shell {
    display: grid;
    gap: 1rem;
}

.chat-log {
    display: grid;
    gap: 0.8rem;
    min-height: 48vh;
}

.chat-empty {
    padding: 1rem;
    border-radius: 22px;
    border: 1px dashed rgba(17, 24, 39, 0.12);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.55);
}

.chat-message {
    display: grid;
    gap: 0.3rem;
    padding: 0.95rem 1rem;
    border-radius: 22px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.chat-message.user {
    margin-left: 1.25rem;
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.12), rgba(29, 78, 216, 0.04));
}

.chat-message.assistant {
    margin-right: 1.25rem;
    background: rgba(255, 255, 255, 0.92);
}

.chat-message-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.chat-message-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.chat-message-tools {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.chat-message-action {
    min-height: 2rem;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(17, 24, 39, 0.04);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-message-action:disabled {
    opacity: 0.55;
    cursor: default;
}

.chat-message-text {
    white-space: pre-wrap;
    line-height: 1.55;
}

.chat-edit-area {
    display: grid;
    gap: 0.65rem;
}

.chat-edit-textarea {
    width: 100%;
    min-height: 7rem;
    resize: vertical;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 18px;
    background: #fafaf9;
    font: inherit;
    line-height: 1.55;
}

.chat-edit-textarea:focus {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    border-color: rgba(29, 78, 216, 0.4);
}

.chat-edit-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.chat-composer {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.chat-textarea {
    width: 100%;
    min-height: 8rem;
    resize: vertical;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 18px;
    background: #fafaf9;
    font: inherit;
}

.chat-textarea:focus {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    border-color: rgba(29, 78, 216, 0.4);
}

.chat-actions {
    display: flex;
    gap: 0.75rem;
}

.chat-submit,
.chat-reset {
    min-height: 3rem;
    padding: 0.8rem 1rem;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.chat-submit {
    border: 0;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.chat-reset {
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(17, 24, 39, 0.04);
    color: var(--text);
}

.chat-status {
    min-height: 1.3rem;
    color: var(--muted);
    font-size: 0.94rem;
}

.chat-status.is-error {
    color: var(--danger);
}

.chat-modal[hidden] {
    display: none;
}

.chat-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.chat-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(4px);
}

.chat-modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 28rem);
    padding: 1.2rem;
    border-radius: 24px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.18);
}

.chat-modal-title {
    margin: 0;
    font-size: 1.15rem;
}

.chat-modal-copy {
    margin: 0.7rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.chat-modal-actions {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.chat-modal-primary,
.chat-modal-secondary {
    min-height: 3rem;
    padding: 0.85rem 1rem;
    border-radius: 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.chat-modal-primary {
    border: 0;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.chat-modal-secondary {
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(17, 24, 39, 0.04);
    color: var(--text);
}

.postit-shell {
    display: grid;
    gap: 1rem;
}

.postit-banner {
    padding: 0.95rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(29, 78, 216, 0.15);
    background: rgba(29, 78, 216, 0.1);
    color: #1e3a8a;
    font-weight: 600;
    line-height: 1.45;
}

.postit-list,
.postit-ranking-list {
    display: grid;
    gap: 0.9rem;
}

.postit-day-card,
.postit-card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.85)),
        rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.07);
}

.postit-day-card.is-running {
    border-color: rgba(29, 78, 216, 0.18);
}

.postit-day-head,
.postit-card-head,
.postit-ranking-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.postit-day-date,
.postit-card-title {
    margin: 0;
    font-size: 1rem;
}

.postit-badge {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.06);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: lowercase;
}

.postit-day-preview,
.postit-card-meta,
.postit-copy-text,
.postit-empty-copy,
.postit-day-error {
    margin: 0;
    line-height: 1.5;
}

.postit-card-meta {
    color: var(--muted);
}

.postit-day-error {
    color: var(--danger);
}

.postit-regenerate-form {
    display: flex;
}

.postit-primary,
.postit-copy {
    min-height: 2.8rem;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.postit-primary {
    border: 0;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.postit-primary[disabled] {
    cursor: wait;
    opacity: 0.62;
}

.postit-copy-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.postit-ranking-actions,
.postit-detail-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.postit-copy {
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(17, 24, 39, 0.04);
    color: var(--text);
}

.postit-expand {
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(29, 78, 216, 0.08);
    color: var(--text);
    min-height: 2.8rem;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.postit-expand-shell {
    display: grid;
    gap: 0.8rem;
}

.postit-expand-summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.8rem;
    width: fit-content;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(29, 78, 216, 0.08);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.postit-expand-summary::-webkit-details-marker {
    display: none;
}

.postit-expand-label {
    pointer-events: none;
}

.postit-expand-label-open {
    display: none;
}

.postit-expand-shell[open] .postit-expand-label-open {
    display: inline;
}

.postit-expand-shell[open] .postit-expand-label-closed {
    display: none;
}

.postit-poem {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font: inherit;
    line-height: 1.65;
}

.postit-ranking-item {
    display: grid;
    gap: 0.85rem;
    padding: 0.9rem;
    border-radius: 20px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(17, 24, 39, 0.02);
}

.postit-ranking-item.is-selected {
    border-color: rgba(22, 163, 74, 0.22);
    background: rgba(22, 163, 74, 0.08);
}

.postit-ranking-extra {
    display: grid;
    gap: 0.8rem;
}

.postit-detail-block {
    display: grid;
    gap: 0.55rem;
    padding-top: 0.1rem;
    border-top: 1px solid rgba(17, 24, 39, 0.08);
}

.postit-detail-title {
    margin: 0;
    font-size: 0.95rem;
}

@media (min-width: 900px) {
    .topbar {
        padding: 1.5rem 2rem 0;
    }

    .page-shell {
        width: min(100vw - 3rem, 52rem);
        margin-top: 1.25rem;
    }

    .empty-panel {
        min-height: 58vh;
    }

    .home-link,
    .chat-composer {
        padding-left: 1.4rem;
        padding-right: 1.4rem;
    }

    .chat-message.user {
        margin-left: 6rem;
    }

    .chat-message.assistant {
        margin-right: 6rem;
    }

    .chat-modal-actions {
        grid-template-columns: 1fr 1fr;
    }

    .postit-day-card,
    .postit-card {
        padding: 1.3rem;
    }
}
