* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--gray-900);
    min-height: 100vh;
    line-height: 1.5;
}

/* 页面 */
.page {
    min-height: 100vh;
}

.page.hidden {
    display: none;
}

/* 登录页 */
#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.login-box {
    background: var(--card-bg);
    padding: 32px 24px;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 360px;
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

button[type="submit"] {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

button[type="submit"]:active {
    background: var(--primary-dark);
}

.error {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

/* 主页 */
header {
    background: var(--card-bg);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 18px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: var(--gray-100);
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.header-actions button:active {
    background: var(--gray-200);
}

/* 添加笔记 */
.add-note {
    background: var(--card-bg);
    padding: 16px;
    margin: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.add-note textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    margin-bottom: 12px;
}

.add-note textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.add-note button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.add-note button:active {
    background: var(--primary-dark);
}

/* 笔记列表 */
#notes-list {
    padding: 0 16px 100px;
}

.note-item {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    transition: all 0.2s;
}

.note-item.done {
    opacity: 0.6;
    background: var(--gray-100);
}

.note-item.done .note-content {
    text-decoration: line-through;
    color: var(--gray-500);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.note-content {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-all;
}

.note-meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 8px;
}

.note-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.note-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-done {
    background: var(--success);
    color: white;
}

.btn-done:hover {
    background: #16a34a;
}

.btn-done.done {
    background: var(--gray-300);
    color: var(--gray-700);
}

.btn-delete {
    background: var(--gray-100);
    color: var(--danger);
}

.btn-delete:active {
    background: #fee2e2;
}

/* 空状态 */
#empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

#empty-state p {
    font-size: 16px;
}

#empty-state .hint {
    font-size: 14px;
    margin-top: 8px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 360px;
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 12px;
}

.modal-desc {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

#device-list {
    margin-bottom: 16px;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--gray-100);
    border-radius: 8px;
    margin-bottom: 8px;
}

.device-item .name {
    font-size: 14px;
}

.device-item .time {
    font-size: 12px;
    color: var(--gray-500);
}

.device-item button {
    padding: 6px 12px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: var(--gray-200);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}