
/* 统一盒模型 */
* {
    box-sizing: border-box;
}

/* 页面基础样式 */
body {
    margin: 0;
    padding: 0 20px;

    background-color: #FFFFFF;
    color: #111827;

    font-family: -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Arial, sans-serif;
}

/* 主内容区域 */
main {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 32px 0;
}

/* APP 标题 */
h1 {
    font-size: 28px;
    margin: 0;
}

/* 副标题 */
header p {
    color: #6B7280;
    margin-top: 8px;
}

/* 区域标题 */
h2 {
    font-size: 17px;
}

/* 添加任务区域 */
section[aria-label="添加任务"] {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}

/* 新任务输入框 */
#task-input {
    flex: 1;
    min-width: 0;
    min-height: 48px;

    padding: 0 14px;

    border: 1px solid transparent;
    border-radius: 12px;

    background-color: #F3F4F6;
    color: #111827;

    font-family: inherit;
    font-size: 16px;
    outline: none;
}

/* 输入框获得焦点时 */
#task-input:focus {
    border-color: #2563EB;
}

/* 输入框提示文字 */
#task-input::placeholder {
    color: #6B7280;
}

/* 添加按钮 */
#add-button {
    min-height: 48px;
    padding: 0 20px;

    border: none;
    border-radius: 12px;

    background-color: #2563EB;
    color: #FFFFFF;

    font-family: inherit;
    font-size: 16px;
    font-weight: 600;

    cursor: pointer;
}

/* 鼠标悬停时 */
#add-button:hover {
    background-color: #1D4ED8;
}

/* 键盘操作时显示焦点 */
#add-button:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 3px;
}

/* 任务列表 */
#pending-list,
#completed-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* 单条任务 */
.task-item {
    display: flex;
    align-items: center;
    gap: 8px;

    min-height: 52px;
    padding: 4px 0;

    border-bottom: 1px solid #E5E7EB;
}

/* 完成与恢复按钮 */
.task-check {
    flex-shrink: 0;

    width: 44px;
    height: 44px;

    border: none;
    background: transparent;
    color: #9CA3AF;

    font-size: 24px;
    cursor: pointer;
}

/* 任务文字 */

.task-text {
    flex: 1;
    min-width: 0;

    color: #111827;
    font-size: 16px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* 编辑和删除按钮 */
.task-action {
    flex-shrink: 0;

    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;

    border: none;
    border-radius: 8px;

    background: transparent;
    color: #6B7280;

    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

.task-action:hover {
    background-color: #F3F4F6;
}

/* 编辑输入框 */
.task-edit-input {
    flex: 1;
    min-width: 0;
    min-height: 44px;

    padding: 0 10px;

    border: 1px solid #2563EB;
    border-radius: 8px;

    font-family: inherit;
    font-size: 16px;
}

/* 键盘焦点 */
.task-check:focus-visible,
.task-action:focus-visible,
.task-edit-input:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

/* 待办任务数量 */
#task-count {
    margin: 24px 0 0;
    color: #6B7280;
    font-size: 14px;
}

/* 任务区域标题 */
h2 {
    margin: 24px 0 12px;
    font-size: 17px;
    font-weight: 600;
}

/* 无待办任务提示 */
#empty-message {
    margin: 0;
    padding: 32px 0;
    color: #6B7280;
    font-size: 14px;
    text-align: center;
}

/* 已完成区域折叠按钮 */
#completed-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;
    min-height: 44px;
    padding: 0;

    border: none;
    background: transparent;

    color: #111827;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    text-align: left;

    cursor: pointer;
}

/* 默认向下箭头 */
#completed-toggle::after {
    content: "⌄";
    color: #6B7280;
    font-size: 24px;
    line-height: 1;
}

/* 展开时向上箭头 */
#completed-toggle[aria-expanded="true"]::after {
    content: "⌃";
}

/* 键盘焦点 */
#completed-toggle:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 3px;
    border-radius: 4px;
}

/* 隐藏元素时必须真正隐藏 */
[hidden] {
    display: none !important;
}

/* 编辑状态：允许内容换行 */
.task-item.is-editing {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
}

/* 编辑输入框独占第一行 */
.is-editing .task-edit-input {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
}

/* 编辑状态下的操作按钮 */
.is-editing .task-action {
    min-height: 44px;
    padding: 0 16px;

    border-radius: 8px;
    background-color: #F3F4F6;
    color: #111827;
}

/* 将第一个操作按钮推到右侧 */
.is-editing .task-action:first-of-type {
    margin-left: auto;
}

/* 编辑状态的键盘焦点 */
.is-editing .task-action:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}



/* 完成 / 恢复按钮 */
.task-status {
    flex-shrink: 0;
    width: 44px;
    height: 44px;

    padding: 0;
    border: none;
    background: transparent;

    color: #6B7280;
    font-size: 24px;
    cursor: pointer;
}


/* 已完成任务 */
.task-completed .task-text {
    color: #9CA3AF;
    text-decoration: line-through;
}

.task-completed .task-status {
    color: #2563EB;
}

/* 编辑和删除按钮 */
.task-action {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;

    padding: 0 6px;
    border: none;
    border-radius: 8px;

    background: transparent;
    color: #6B7280;

    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

/* 鼠标悬停效果 */
.task-action:hover,
.task-status:hover {
    background-color: #F3F4F6;
}

/* 键盘焦点 */
.task-action:focus-visible,
.task-status:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

/* 编辑状态下的任务行 */
.task-item-editing {
    flex-wrap: wrap;
    padding: 8px 0;
}

/* 编辑输入框 */
.task-edit-input {
    flex: 1 1 100%;
    min-width: 0;
    min-height: 44px;

    padding: 0 12px;
    border: 1px solid #2563EB;
    border-radius: 8px;

    background-color: #F3F4F6;
    color: #111827;

    font-family: inherit;
    font-size: 16px;
}

/* 禁用状态 */
.task-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Area filters keep their natural button keyboard behavior and scroll on narrow screens. */
#area-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 3px 10px;
    margin: 20px -3px 0;
    scroll-padding-inline: 3px;
    -webkit-overflow-scrolling: touch;
}

.area-filter {
    flex: 0 0 auto;
    min-width: 48px;
    min-height: 44px;
    max-width: 100%;
    padding: 10px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 22px;
    background: #F3F4F6;
    color: #374151;
    font: inherit;
    font-size: 15px;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.area-filter[aria-pressed="true"] {
    border-color: #2563EB;
    background: #2563EB;
    color: #FFFFFF;
    font-weight: 600;
}

.area-filter:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.area-filter:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Native area control stays on its own row on small screens. */
.task-edit-area {
    flex: 0 0 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #4B5563;
    font-size: 14px;
}

.task-area-select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #9CA3AF;
    border-radius: 8px;
    background: #F3F4F6;
    color: #111827;
    font: inherit;
    font-size: 16px;
}

.task-area-select:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

/* Compact native disclosure for custom area management. */
#area-manager { margin: 4px 0 16px; }
#area-manager summary {
    min-height: 44px;
    padding: 12px 0;
    color: #4B5563;
    cursor: pointer;
}
.area-manage-hint, #area-manage-empty, #area-manage-status {
    color: #6B7280;
    font-size: 14px;
    line-height: 1.5;
}
#area-create-form > label, .area-manage-label { font-size: 14px; color: #4B5563; }
.area-create-row { display: flex; gap: 8px; margin-top: 6px; }
#area-name-input, .area-manage-input {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #9CA3AF;
    border-radius: 8px;
    background: #F3F4F6;
    color: #111827;
    font: inherit;
    font-size: 16px;
}
#area-name-input { flex: 1; }
#area-create-button {
    flex-shrink: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: #2563EB;
    color: white;
    font: inherit;
    cursor: pointer;
}
#area-manage-list { list-style: none; padding: 0; margin: 16px 0; }
.area-manage-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 0;
    border-bottom: 1px solid #E5E7EB;
}
.area-manage-label { flex: 0 0 100%; min-width: 0; }
.area-manage-input { display: block; margin-top: 6px; }
#area-manager summary:focus-visible, #area-name-input:focus-visible,
.area-manage-input:focus-visible, #area-create-button:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}
#area-manager input:disabled, #area-create-button:disabled { opacity: .5; cursor: not-allowed; }

/* Backup and restore use native controls with an explicit destructive confirmation. */
#data-manager { margin: 4px 0 16px; }
#data-manager summary { min-height: 44px; padding: 12px 0; color: #4B5563; cursor: pointer; }
#data-manager label { display: block; font-size: 14px; margin: 12px 0 6px; }
#data-manager input, #data-manager button {
    max-width: 100%; min-width: 0; min-height: 44px;
    font: inherit; font-size: 16px;
}
#data-manager input { width: 100%; }
#data-manager button {
    margin: 4px 4px 4px 0; padding: 8px 12px;
    border: 1px solid #9CA3AF; border-radius: 8px;
    background: #F3F4F6; color: #111827; cursor: pointer;
}
#data-manager button:disabled, #backup-file:disabled { opacity: .5; cursor: not-allowed; }
#backup-preview { padding: 12px; margin: 12px 0; border: 1px solid #9CA3AF; border-radius: 8px; }
#backup-warning { font-weight: 600; }
#data-manager #backup-confirm { background: #B91C1C; border-color: #B91C1C; color: white; }
.data-hint, #backup-edit-hint, #backup-status, #backup-counts {
    font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
#data-manager summary:focus-visible, #data-manager button:focus-visible,
#data-manager input:focus-visible, #backup-status:focus-visible {
    outline: 2px solid #2563EB; outline-offset: 2px;
}

/* Rename is an explicit single-row edit; the stored name remains separate from its marker. */
.area-manage-label { overflow-wrap: anywhere; }
.area-manage-input[readonly] { background: #FFFFFF; color: #4B5563; }

#app-controls { border: 0; padding: 0; margin: 0; min-width: 0; }
#pwa-info { font-size: 14px; color: #4B5563; overflow-wrap: anywhere; }
#pwa-recheck { min-height: 44px; padding: 8px 12px; font: inherit; border: 1px solid #9CA3AF; border-radius: 8px; background: #F3F4F6; cursor: pointer; }
#pwa-recheck:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }
