:root {
    color-scheme: light;
    --bg-top: #eef3f5;
    --bg-bottom: #f6f4ef;
    --paper: #fffdf8;
    --surface: #ffffff;
    --text: #25231f;
    --muted: #6d6a62;
    --line: #dedbd2;
    --accent: #2b7168;
    --accent-hover: #235e57;
    --accent-soft: #e5f3ef;
    --logout: #2f6fb2;
    --logout-hover: #255d98;
    --secondary: #efeee8;
    --secondary-hover: #e4e1d8;
    --success-bg: #e4f4ea;
    --success-text: #23633d;
    --error-bg: #f9e9e5;
    --error-text: #8b3228;
    --shadow: 0 22px 70px rgba(40, 37, 29, 0.12);
    --paper-shadow: 0 30px 80px rgba(48, 44, 35, 0.15), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(43, 113, 104, 0.08), transparent 34rem),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    min-height: 48px;
    padding: 0 24px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(43, 113, 104, 0.22);
    transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: 0 12px 28px rgba(43, 113, 104, 0.28);
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(43, 113, 104, 0.26);
    outline-offset: 3px;
}

.button-secondary {
    background: var(--logout);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(47, 111, 178, 0.2);
}

.button-secondary:hover {
    background: var(--logout-hover);
    box-shadow: 0 12px 28px rgba(47, 111, 178, 0.26);
}

.login-wrap {
    width: min(100% - 32px, 440px);
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    place-items: center;
    padding: 32px 0;
}

.login-box {
    width: 100%;
    padding: 34px;
    border: 1px solid rgba(222, 219, 210, 0.72);
    border-radius: 8px;
    background: rgba(255, 254, 251, 0.94);
    box-shadow: var(--shadow);
}

.login-box h1,
.editor-head h1 {
    margin: 0;
    font-size: 29px;
    line-height: 1.2;
    letter-spacing: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.login-box p {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.login-box label {
    display: block;
    margin-top: 26px;
    margin-bottom: 9px;
    color: var(--text);
    font-weight: 700;
}

.password-field {
    position: relative;
}

.login-box input {
    width: 100%;
    min-height: 56px;
    padding: 13px 116px 13px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: 20px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.password-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 7px;
    background: var(--secondary);
    color: var(--text);
    font-size: 15px;
    box-shadow: none;
}

.password-toggle:hover {
    background: var(--secondary-hover);
    box-shadow: none;
}

.login-box > button {
    width: 100%;
    margin-top: 20px;
}

.editor-wrap {
    width: min(100% - 36px, 900px);
    margin: 0 auto;
    padding: 28px 0 42px;
}

.editor-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-bottom: 18px;
}

.editor-head form {
    display: flex;
    flex: 0 0 auto;
    align-self: center;
}

.message {
    margin: 0 0 14px;
    padding: 12px 15px;
    border-radius: 8px;
    line-height: 1.4;
    font-weight: 700;
    transition: opacity 220ms ease, transform 220ms ease;
}

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

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

.message.is-hiding {
    opacity: 0;
    transform: translateY(-4px);
}

.editor-form {
    display: grid;
    gap: 16px;
}

.writer-layout {
    display: grid;
    grid-template-columns: minmax(0, 900px);
    gap: 18px;
    justify-content: center;
}

.overview-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 18px;
    border: 1px solid rgba(222, 219, 210, 0.72);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 16px 42px rgba(48, 44, 35, 0.08);
}

.overview-panel h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: 0;
}

.overview-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 0;
}

.overview-list div {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
}

.overview-list dt {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.25;
    white-space: nowrap;
}

.overview-list dd {
    margin: 0;
    color: var(--text);
    font-size: 17px;
    line-height: 1.35;
    font-weight: 700;
}

#save-status[data-status="saved"] {
    color: var(--success-text);
}

#save-status[data-status="dirty"],
#save-status[data-status="saving"] {
    color: #8a5a10;
}

#save-status[data-status="error"] {
    color: var(--error-text);
}

.document-panel {
    min-width: 0;
}

textarea {
    width: 100%;
    min-height: 74vh;
    padding: 44px 48px;
    border: 0;
    border-radius: 8px;
    background: var(--paper);
    color: var(--text);
    font-size: 20px;
    line-height: 1.65;
    resize: vertical;
    box-shadow: var(--paper-shadow);
}

textarea::placeholder {
    color: var(--muted);
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 860px) {
    .overview-panel {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 640px) {
    .login-wrap,
    .editor-wrap {
        width: min(100% - 24px, 900px);
    }

    .login-box {
        padding: 26px;
    }

    .login-box h1 {
        font-size: 26px;
    }

    .editor-head {
        align-items: stretch;
        flex-direction: column;
    }

    .editor-head form,
    .editor-head button,
    .editor-actions button {
        width: 100%;
    }

    .overview-panel {
        padding: 14px 16px;
    }

    .overview-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    textarea {
        min-height: 68vh;
        padding: 26px 20px;
        font-size: 20px;
        line-height: 1.6;
    }
}
