:root {
    --ink: #17211b;
    --muted: #667268;
    --paper: #f7f2e8;
    --panel: rgba(255, 252, 244, 0.88);
    --line: rgba(23, 33, 27, 0.14);
    --accent: #e75f45;
    --accent-dark: #a83f2f;
    --ok: #2f8f63;
    --blue: #3f6ea5;
    --shadow: 0 24px 70px rgba(45, 54, 44, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
    background:
        linear-gradient(90deg, rgba(23, 33, 27, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(23, 33, 27, 0.045) 1px, transparent 1px),
        linear-gradient(135deg, #fbf0df 0%, #eef4e9 48%, #edf1f6 100%);
    background-size: 40px 40px, 40px 40px, auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.todo-shell {
    width: min(1400px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 48px;
}

.todo-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.todo-header .header-title {
    flex: 1;
    margin: 0;
    font-size: 1.8em;
    font-weight: 800;
    text-align: center;
}

.cloud-toggle-wrap {
    flex-shrink: 0;
}

.display-toggle {
    position: relative;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.display-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.display-toggle i {
    position: relative;
    width: 42px;
    height: 24px;
    border: 1px solid rgba(23, 33, 27, 0.18);
    border-radius: 999px;
    background: rgba(23, 33, 27, 0.14);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.display-toggle i::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 3px 8px rgba(23, 33, 27, 0.18);
    content: "";
    transition: transform 0.2s ease;
}

.display-toggle input:checked + i {
    border-color: rgba(36, 94, 168, 0.42);
    background: var(--blue);
}

.display-toggle input:checked + i::after {
    transform: translateX(18px);
}

.back-link {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    color: #9a5c17;
    border: 1px solid #9a5c17;
    border-radius: 999px;
    background: rgba(255, 252, 243, 0.72);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.icon-button,
.modal-close {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-family: SimSun, "宋体", serif;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    font-size: 18px;
}

.primary-button,
.ghost-button,
.tab-button {
    min-height: 42px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid var(--line);
    font-weight: 800;
}

.primary-button {
    color: #fff9ef;
    border-color: transparent;
    background: var(--accent);
    box-shadow: 0 12px 28px rgba(231, 95, 69, 0.24);
}

.ghost-button,
.tab-button {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.64);
}

.ghost-button.danger {
    color: var(--accent-dark);
}

.storage-banner,
.category-panel,
.work-panel,
.modal-card {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.storage-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 18px;
}

.storage-banner[hidden] {
    display: none;
}

.storage-banner.warning {
    border-color: rgba(231, 95, 69, 0.45);
    background: rgba(255, 243, 231, 0.94);
}

.storage-track {
    width: min(420px, 56vw);
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(23, 33, 27, 0.1);
}

.storage-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ok), var(--accent));
}

.storage-actions,
.modal-actions,
.todo-card-actions,
.category-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.todo-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 18px;
    align-items: start;
}

.category-panel,
.work-panel {
    border-radius: 24px;
}

.category-panel {
    padding: 18px;
    position: sticky;
    top: 18px;
}

.panel-title-row,
.toolbar,
.tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.category-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.category-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.46);
}

.category-item.active {
    border-color: rgba(23, 33, 27, 0.22);
    background: #fffaf1;
}

.category-filter {
    min-width: 0;
    display: grid;
    grid-template-columns: 14px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 0;
    color: var(--ink);
    background: transparent;
    text-align: left;
}

.mini-button {
    min-width: 30px;
    height: 30px;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    background: rgba(23, 33, 27, 0.06);
    font-size: 12px;
    font-weight: 800;
}

.category-actions {
    padding-right: 8px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--tag-color, var(--accent));
}

.category-meta {
    color: var(--muted);
    font-size: 12px;
}

.work-panel {
    min-height: 640px;
    padding: 18px;
}

.tabs {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.tabs-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tab-button.active {
    color: #fff9ef;
    border-color: transparent;
    background: var(--ink);
}

.toolbar {
    margin: 16px 0;
}

.search-box {
    min-width: min(360px, 100%);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid rgba(63, 110, 165, 0.34);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.68);
}

.search-box span {
    color: var(--blue);
    font-size: 13px;
    font-weight: 900;
}

.search-box input {
    min-height: 42px;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
}

.search-box input::placeholder {
    color: rgba(102, 114, 104, 0.56);
}

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

.empty-state {
    padding: 58px 20px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.36);
}

.todo-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    transition: transform 180ms ease, border-color 180ms ease;
}

.todo-card:hover {
    transform: translateY(-2px);
    border-color: rgba(23, 33, 27, 0.28);
}

.todo-check {
    width: 22px;
    min-width: 22px;
    height: 22px;
    min-height: 22px;
    margin-top: 0;
    padding: 0;
    align-self: center;
    appearance: none;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.todo-check:checked {
    border-color: var(--ok);
    background: var(--ok);
}

.todo-main {
    min-width: 0;
}

.todo-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.todo-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 18px;
    font-weight: 900;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.todo-title-meta {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
}

.todo-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--ink);
    background: rgba(23, 33, 27, 0.08);
    font-size: 12px;
    font-weight: 800;
}

.category-badge {
    background: color-mix(in srgb, var(--tag-color, var(--blue)) 20%, white);
}

.todo-desc {
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.todo-image-thumb {
    width: 112px;
    height: 76px;
    object-fit: cover;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.text-button {
    padding: 0;
    border: 0;
    color: var(--accent-dark);
    background: transparent;
    font-weight: 800;
}

.modal,
.lightbox {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(23, 33, 27, 0.42);
    z-index: 10;
}

.modal.open,
.lightbox.open {
    display: grid;
}

.modal-card {
    width: min(760px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    position: relative;
    padding: 24px;
    border-radius: 24px;
}

.modal-card.small {
    width: min(440px, 100%);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    border: 0;
    font-size: 24px;
}

.modal-copy {
    margin: 18px 0 20px;
    color: var(--muted);
    line-height: 1.7;
}

.danger-button {
    background: var(--accent-dark);
    box-shadow: 0 12px 28px rgba(168, 63, 47, 0.22);
}

.todo-form,
.category-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 18px;
}

.category-form {
    grid-template-columns: 1fr 1fr;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.78);
}

input,
select {
    min-height: 42px;
    padding: 0 12px;
}

#todo-image {
    padding: 6px 12px;
    line-height: 28px;
}

#todo-image::-webkit-file-upload-button {
    height: 28px;
    margin: 0 12px 0 0;
    vertical-align: middle;
}

textarea {
    padding: 12px;
    resize: vertical;
}

.full-field {
    grid-column: 1 / -1;
}

.paste-zone {
    padding: 14px;
    border: 1px dashed rgba(23, 33, 27, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.42);
}

.paste-zone small {
    color: var(--muted);
    font-weight: 600;
    line-height: 1.6;
}

#image-preview {
    width: 180px;
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.lightbox button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    font-size: 26px;
}

.lightbox img {
    max-width: min(92vw, 1100px);
    max-height: 86vh;
    border-radius: 18px;
    background: #fff;
}

@media (max-width: 900px) {
    .storage-banner,
    .todo-layout,
    .toolbar,
    .todo-card {
        grid-template-columns: 1fr;
    }

    .todo-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tabs-group {
        flex-wrap: wrap;
    }

    .storage-banner,
    .toolbar {
        align-items: stretch;
    }

    .category-panel {
        position: static;
    }

    .todo-form {
        grid-template-columns: 1fr;
    }

    .category-form {
        grid-template-columns: 1fr;
    }
}
