:root {
    --bg: #ffffff;
    --bg-card: #f5f5f7;
    --bg-input: #e8e8ed;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #007aff;
    --accent-light: #e3f0ff;
    --danger: #ff3b30;
    --success: #34c759;
    --border: #d2d2d7;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a2e;
        --bg-card: #25253e;
        --bg-input: #2d2d4a;
        --text: #f0f0f5;
        --text-secondary: #8e8ea0;
        --accent: #0a84ff;
        --accent-light: #1a2a4a;
        --danger: #ff453a;
        --success: #30d158;
        --border: #3a3a5c;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
}
#app {
    height: 100%; display: flex; flex-direction: column;
    padding-top: var(--safe-top);
}

/* ── 顶栏 ── */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; min-height: 48px; flex-shrink: 0;
}
.header h1 { font-size: 20px; font-weight: 700; }
.header-btn {
    background: none; border: none; color: var(--accent);
    font-size: 16px; cursor: pointer; padding: 4px 8px;
}
.back-btn::before { content: "‹ "; font-size: 22px; }

/* ── 滚动区 ── */
.content {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 16px 120px; overscroll-behavior: none;
}

/* ── 列表 ── */
.entry-list { list-style: none; }
.entry-item {
    background: var(--bg-card); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
    transition: transform 0.1s;
}
.entry-item:active { transform: scale(0.98); }
.entry-date { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.entry-summary { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.entry-preview {
    font-size: 14px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty-state {
    text-align: center; color: var(--text-secondary);
    padding: 60px 20px; font-size: 15px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; display: block; }

/* ── 底栏 ── */
.bottom-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: space-around;
    padding: 8px 16px; padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--bg); border-top: 0.5px solid var(--border); z-index: 100;
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center;
    background: none; border: none; color: var(--text-secondary);
    font-size: 10px; cursor: pointer; padding: 4px 12px; gap: 2px;
}
.nav-btn.active { color: var(--accent); }
.nav-btn .nav-icon { font-size: 24px; line-height: 1; }
.record-fab {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent); border: none; color: white;
    font-size: 24px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,122,255,0.4);
    transition: transform 0.15s; margin-top: -20px;
}
.record-fab:active { transform: scale(0.92); }

/* ── 录音 ── */
.mic-btn {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--accent); border: none; color: white;
    font-size: 28px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    margin: 20px auto;
}
.mic-btn.recording, .record-fab.recording {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(255,59,48,0.5);
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
.mic-status { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.realtime-text {
    background: var(--accent-light); border-radius: 8px;
    padding: 10px 14px; margin-top: 12px;
    font-size: 14px; color: var(--text-secondary); min-height: 40px;
}
.realtime-text.active { border-left: 3px solid var(--accent); }

/* ── 写入区 ── */
.write-area {
    width: 100%; min-height: 200px; background: var(--bg-input);
    border: none; border-radius: 12px; padding: 14px 16px;
    font-size: 16px; color: var(--text); resize: none; outline: none;
    font-family: inherit; line-height: 1.6;
}
.write-area::placeholder { color: var(--text-secondary); }

/* ── 按钮 ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: 10px; border: none;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: opacity 0.15s; gap: 6px;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: white; width: 100%; margin-top: 16px; }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; margin-top: 0; }

/* ── 详情 ── */
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
    font-size: 14px; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.detail-content {
    background: var(--bg-card); border-radius: 12px;
    padding: 14px 16px; font-size: 15px; line-height: 1.7; white-space: pre-wrap;
}
.muted { color: var(--text-secondary); font-size: 14px; }

/* ── Done/Todo ── */
.done-list, .todo-list { list-style: none; }
.done-list li, .todo-list li {
    background: var(--bg-card); border-radius: 10px;
    padding: 10px 14px; margin-bottom: 6px; font-size: 15px;
    display: flex; align-items: center; gap: 10px;
}
.done-list li::before { content: "✓"; color: var(--success); font-weight: 700; font-size: 16px; flex-shrink: 0; }
.todo-check {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--border); background: none; cursor: pointer;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: transparent; transition: all 0.2s;
}
.todo-check.checked { background: var(--success); border-color: var(--success); color: white; }
.todo-text { flex: 1; }
.todo-text.completed { text-decoration: line-through; color: var(--text-secondary); }
.todo-date { font-size: 12px; color: var(--text-secondary); }

/* ── Toast ── */
.toast {
    position: fixed; bottom: calc(80px + var(--safe-bottom));
    left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text); color: var(--bg);
    padding: 10px 20px; border-radius: 20px; font-size: 14px;
    opacity: 0; transition: all 0.3s; z-index: 200; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 锁屏 ── */
.lock-screen {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; padding: 40px 32px;
}
.lock-icon { font-size: 56px; margin-bottom: 16px; }
.lock-screen h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.lock-hint { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; text-align: center; }
.lock-input {
    width: 100%; max-width: 280px; padding: 12px 16px;
    background: var(--bg-input); border: none; border-radius: 10px;
    font-size: 18px; color: var(--text); text-align: center;
    outline: none; margin-bottom: 12px; letter-spacing: 4px;
}
.lock-screen .btn-primary { max-width: 280px; }
