:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2429;
    --muted: #79818c;
    --line: #e4e7ec;
    --accent: #2563eb;
    --accent-soft: #e8effd;
    --danger: #c94a4a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

.wrap {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 14px;
    min-width: 0;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 14px;
    color: var(--muted);
}

.topbar-user .name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
}

.card + .card {
    margin-top: 14px;
}

h2.title {
    margin: 0 0 14px;
    font-size: 18px;
}

.field {
    display: block;
    margin-bottom: 12px;
}

.field span {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--muted);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
    display: inline-block;
    padding: 10px 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.2;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.05);
}

.btn.block {
    width: 100%;
}

.btn.ghost {
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    padding: 6px 10px;
    font-size: 13px;
}

.btn.link {
    padding: 0;
    color: var(--accent);
    background: none;
    border: none;
    font-size: 14px;
}

.add-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.add-form input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
}

.add-form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.errors {
    margin: 0 0 12px;
    padding: 10px 12px;
    list-style: none;
    color: var(--danger);
    background: #fdf1f1;
    border: 1px solid #f3d3d3;
    border-radius: 8px;
    font-size: 14px;
}

.flash {
    margin: 0 0 12px;
    padding: 10px 12px;
    color: #2a5db0;
    background: var(--accent-soft);
    border-radius: 8px;
    font-size: 14px;
}

.summary {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--muted);
}

.todo-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
}

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

.todo-check {
    flex: 0 0 auto;
    padding-top: 2px;
}

.todo-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.todo-id {
    flex: 0 0 auto;
    min-width: 2.2em;
    padding-top: 1px;
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.todo-content {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.todo-item.done .todo-content {
    color: var(--muted);
    text-decoration: line-through;
}

.todo-item > form {
    flex: 0 0 auto;
    margin: 0;
}

.todo-del {
    flex: 0 0 auto;
    padding: 0;
    color: var(--muted);
    background: none;
    border: none;
    font-size: 13px;
    line-height: 1.5;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.todo-del:hover {
    color: var(--danger);
}

.todo-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.todo-time {
    font-size: 11px;
    line-height: 1.4;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.todo-item.done .todo-time {
    opacity: 0.75;
}

/* 操作区固定在右侧，不参与收缩，长内容折行也不会挤压按钮 */
.todo-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-top: 1px;
    white-space: nowrap;
}

.todo-actions form {
    flex: 0 0 auto;
    margin: 0;
}

.todo-edit-link,
.todo-cancel {
    flex: 0 0 auto;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.todo-edit-link:hover,
.todo-cancel:hover {
    color: var(--accent);
}

.todo-main .todo-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.todo-edit input[type="text"] {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 6px 10px;
    font-size: 15px;
}

.btn.sm {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
}

.empty {
    padding: 24px 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.auth-alt {
    margin: 14px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

.hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}
