:root {
    color-scheme: light;
    --background: #f3eee7;
    --surface: #fffdf9;
    --surface-soft: #f8f3ec;
    --text: #302a26;
    --muted: #756b63;
    --border: #ded3c7;
    --accent: #80634f;
    --accent-dark: #624938;
    --success: #35654a;
    --success-bg: #e9f4ec;
    --error: #8a3636;
    --error-bg: #faeaea;
    --shadow: 0 18px 50px rgba(71, 53, 40, 0.09);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, #faf7f2 0, transparent 42%),
        var(--background);
    font-family:
        Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    line-height: 1.55;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    border-radius: 12px;
    padding: 12px 20px;
    color: white;
    background: var(--accent);
    font-weight: 700;
    cursor: pointer;
    transition:
        background 150ms ease,
        transform 150ms ease;
}

button:hover {
    background: var(--accent-dark);
}

button:active {
    transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(128, 99, 79, 0.28);
    outline-offset: 2px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: white;
}

input {
    min-height: 48px;
    padding: 10px 13px;
    margin-bottom: 18px;
}

textarea {
    min-height: 230px;
    padding: 15px;
    margin-bottom: 14px;
    resize: vertical;
    line-height: 1.6;
}

input:hover,
textarea:hover {
    border-color: #c5b7aa;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 500;
    letter-spacing: -0.025em;
}

h2 {
    margin-bottom: 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
    font-weight: 500;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.intro,
.empty-state {
    color: var(--muted);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.write-card,
.history-card {
    border: 1px solid rgba(222, 211, 199, 0.85);
    border-radius: 22px;
    background: rgba(255, 253, 249, 0.96);
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 430px);
    padding: clamp(28px, 6vw, 48px);
}

.login-card h1 {
    margin-bottom: 12px;
}

.login-card .intro {
    margin-bottom: 28px;
}

.login-card button {
    width: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 34px 0 24px;
}

.topbar form {
    flex: 0 0 auto;
}

.secondary-button {
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--surface);
}

.secondary-button:hover {
    background: var(--surface-soft);
}

.journal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 22px;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding-bottom: 50px;
}

.write-card,
.history-card {
    padding: clamp(22px, 4vw, 34px);
}

.write-card .intro {
    margin-bottom: 24px;
}

.success,
.error {
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 18px;
    font-size: 0.92rem;
}

.success {
    color: var(--success);
    background: var(--success-bg);
}

.error {
    color: var(--error);
    background: var(--error-bg);
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.section-heading span {
    color: var(--muted);
    font-size: 0.82rem;
}

.entry-list {
    display: grid;
    gap: 13px;
}

.entry-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: var(--surface-soft);
}

.entry-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: capitalize;
}

.entry-text {
    margin-bottom: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.reflection {
    border-top: 1px solid var(--border);
    margin-top: 16px;
    padding-top: 14px;
}

.reflection-label {
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.reflection-text {
    margin-bottom: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.entry-status {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.retry-form {
    margin-top: 14px;
}

.retry-form input {
    display: none;
}

.retry-button {
    border: 1px solid var(--border);
    padding: 8px 12px;
    color: var(--text);
    background: var(--surface);
    font-size: 0.84rem;
}

.retry-button:hover {
    background: white;
}

.delete-form {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.delete-form input {
    display: none;
}

.delete-button {
    border: 1px solid rgba(138, 54, 54, 0.28);
    padding: 8px 12px;
    color: var(--error);
    background: transparent;
    font-size: 0.82rem;
}

.delete-button:hover {
    color: white;
    background: var(--error);
}

.guided-reflection,
.insight-block {
    border-top: 1px solid var(--border);
    margin-top: 16px;
    padding-top: 14px;
}

.question-count {
    margin-bottom: 5px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.follow-up-question {
    margin-bottom: 14px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
}

.guide-comment {
    color: var(--muted);
    font-size: 0.9rem;
}

.answer-box {
    min-height: 120px;
}

.finish-form {
    margin-top: 10px;
}

.finish-form input {
    display: none;
}

.finish-form .secondary-button {
    padding: 9px 13px;
    font-size: 0.84rem;
}

.insight-block ul,
.weekly-group ul {
    margin: 0;
    padding-left: 20px;
}

.insight-block li,
.weekly-group li {
    margin-bottom: 5px;
}

.weekly-section {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto 50px;
    border: 1px solid rgba(222, 211, 199, 0.85);
    border-radius: 22px;
    padding: clamp(22px, 4vw, 34px);
    background: rgba(255, 253, 249, 0.96);
    box-shadow: var(--shadow);
}

.weekly-list {
    display: grid;
    gap: 12px;
}

.weekly-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 15px 17px;
    background: var(--surface-soft);
}

.weekly-card summary {
    color: var(--accent-dark);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
}

.weekly-card[open] summary {
    margin-bottom: 14px;
}

.weekly-group {
    margin-top: 14px;
}

@media (max-width: 780px) {
    .topbar {
        align-items: flex-end;
        width: min(100% - 28px, 620px);
        padding-top: 24px;
    }

    .journal-layout {
        grid-template-columns: 1fr;
        width: min(100% - 28px, 620px);
    }

    .history-card {
        order: 2;
    }

    .weekly-section {
        width: min(100% - 28px, 620px);
    }

    textarea {
        min-height: 200px;
    }
}
