:root {
    --paper: #ffffff;
    --ink: #111111;
    --muted: #6d6d6d;
    --line: #d8d8d8;
    --danger: #6f2222;
}

* {
    box-sizing: border-box;
}

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

body {
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
textarea {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.note-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-inline: clamp(24px, 3.8vw, 56px);
}

.note-header {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    border-bottom: 1px solid var(--line);
}

.note-heading {
    min-width: 0;
    display: flex;
    align-items: center;
}

.note-heading h1 {
    margin: 0;
    flex: 0 0 auto;
    color: var(--ink);
    font-family: Georgia, "Songti SC", "STSong", "SimSun", serif;
    font-size: clamp(34px, 3vw, 44px);
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.save-status {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    margin-left: 20px;
    padding-left: 28px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
}

.save-status.is-dirty {
    color: var(--ink);
}

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

.header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-button,
.clear-button {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 0 24px;
    border: 1px solid var(--ink);
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.06em;
    transition: background-color 140ms ease, color 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.save-button {
    min-width: 92px;
    background: var(--ink);
    color: #ffffff;
}

.clear-button {
    min-width: 80px;
    background: var(--paper);
    color: var(--ink);
}

.save-button:hover:not(:disabled) {
    background: #333333;
}

.clear-button:hover:not(:disabled) {
    background: #f3f3f3;
}

.save-button:active:not(:disabled),
.clear-button:active:not(:disabled) {
    transform: translateY(1px);
}

.save-button:focus-visible,
.clear-button:focus-visible {
    outline: 3px solid rgba(17, 17, 17, 0.22);
    outline-offset: 3px;
}

.save-button:disabled,
.clear-button:disabled {
    cursor: default;
    opacity: 0.58;
}

.editor-region {
    min-height: 0;
    position: relative;
}

#note-editor {
    width: 100%;
    height: 100%;
    display: block;
    resize: none;
    overflow: auto;
    padding: 40px 0 36px;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: #242424;
    caret-color: var(--ink);
    font-family: "SimSun", "宋体", "Songti SC", "STSong", serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.85;
    letter-spacing: 0.015em;
    white-space: pre-wrap;
}

#note-editor::placeholder {
    color: #777777;
    opacity: 1;
}

#note-editor:disabled {
    color: transparent;
    cursor: wait;
}

#note-editor:focus-visible {
    outline: none;
}

.note-footer {
    min-height: 103px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    line-height: 1;
}

.shortcut-hint {
    white-space: nowrap;
}

kbd {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}

.sr-only {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .note-shell {
        padding-inline: 18px;
    }

    .note-header {
        min-height: 82px;
        gap: 8px;
    }

    .note-heading h1 {
        font-size: 30px;
        letter-spacing: 0;
    }

    .save-status {
        min-height: 26px;
        margin-left: 10px;
        padding-left: 10px;
        font-size: 12px;
    }

    .header-actions {
        gap: 6px;
    }

    .save-button,
    .clear-button {
        min-width: 54px;
        min-height: 40px;
        padding-inline: 8px;
        font-size: 13px;
    }

    #note-editor {
        padding: 26px 0 22px;
        font-size: 16px;
        line-height: 1.75;
    }

    .note-footer {
        min-height: 58px;
        font-size: 12px;
    }
}

@media (max-width: 370px) {
    .save-status {
        max-width: 64px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .shortcut-hint {
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .save-button,
    .clear-button {
        transition: none;
    }
}
