:root {
  --bg: #0a111a;
  --bg-soft: #0f1925;
  --panel: #111d2b;
  --panel-2: #162435;
  --field: #0e1824;
  --line: #243447;
  --line-soft: #1b293a;
  --text: #f3efe5;
  --muted: #8d9bad;
  --faint: #617084;
  --gold: #d9b477;
  --gold-bright: #efcf94;
  --gold-dim: #a8865a;
  --green: #66c7a0;
  --green-soft: #a7e2c5;
  --danger: #d97a6d;
  --danger-soft: #f0a69a;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100svh;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(52, 83, 117, .25), transparent 60%),
    radial-gradient(900px 600px at 100% 20%, rgba(153, 115, 57, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.ambient { position: fixed; border-radius: 999px; filter: blur(90px); pointer-events: none; z-index: 0; }
.ambient-a { width: 340px; height: 340px; left: -180px; top: -140px; background: rgba(55, 103, 143, .22); }
.ambient-b { width: 300px; height: 300px; right: -180px; top: 35%; background: rgba(169, 126, 58, .10); }

.app {
  position: relative;
  min-width: 0;
  overflow-x: clip;
  z-index: 1;
  width: min(100%, 860px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(26px + var(--safe-bottom));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: .01em; }
.brand p { margin: 4px 0 0; font-size: 10px; letter-spacing: .11em; color: var(--gold-dim); }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(17, 29, 43, .75); color: var(--muted);
  transition: border-color .18s, color .18s, background .18s;
}
.icon-btn:hover { color: var(--text); border-color: #3b5068; background: var(--panel-2); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 34px; height: 34px; font-size: 23px; font-weight: 300; line-height: 1; }

.content { display: grid; gap: 22px; min-width: 0; }
.panel {
  background: linear-gradient(155deg, rgba(20, 34, 50, .92), rgba(13, 23, 35, .94));
  border: 1px solid rgba(77, 103, 133, .22);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.calendar-card { padding: 20px 18px 18px; min-width: 0; }
.month-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; min-width: 0; }
.month-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-shrink: 1; }
.month-title span { color: var(--faint); font-size: 12px; letter-spacing: .1em; }
.month-title strong { font-family: Georgia, "Songti SC", "STSong", serif; font-size: 30px; font-weight: 500; letter-spacing: .02em; }
.month-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.text-btn, .round-btn { border: 1px solid var(--line); color: var(--muted); background: transparent; transition: all .18s; }
.text-btn { padding: 7px 11px; border-radius: 999px; font-size: 11px; }
.round-btn { width: 32px; height: 32px; border-radius: 50%; font-size: 19px; line-height: 1; }
.text-btn:hover, .round-btn:hover { color: var(--gold-bright); border-color: var(--gold-dim); }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { margin-bottom: 6px; }
.weekdays span { text-align: center; font-size: 10px; color: var(--faint); padding: 4px 0; letter-spacing: .08em; }
.calendar-grid { gap: 2px; }
.day-cell {
  position: relative; aspect-ratio: 1 / 1.08; min-height: 44px;
  border: 1px solid transparent; border-radius: 12px; background: transparent;
  color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: background .16s, border-color .16s, transform .16s;
}
.day-cell:hover { background: rgba(255, 255, 255, .035); }
.day-cell.other-month { color: #435267; }
.day-cell.today .day-num { color: var(--gold-bright); }
.day-cell.selected { background: linear-gradient(145deg, rgba(217, 180, 119, .17), rgba(217, 180, 119, .06)); border-color: rgba(217, 180, 119, .42); }
.day-cell.selected .day-num { font-weight: 700; }
.day-num { font-size: 14px; line-height: 1; }
.day-dots { display: flex; height: 5px; align-items: center; gap: 3px; }
.day-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--gold-dim); }
.day-dot.high { background: var(--danger); }
.day-dot.done { background: #42546a; }
.today-ring { position: absolute; inset: 5px; border: 1px solid rgba(217, 180, 119, .28); border-radius: 10px; pointer-events: none; }

.day-section { padding: 0 2px; min-width: 0; }
.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.day-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.day-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.add-btn {
  width: 43px; height: 43px; border-radius: 14px; border: 1px solid rgba(217, 180, 119, .55);
  background: linear-gradient(145deg, #e4c286, #cfa568); color: #1a140b;
  display: grid; place-items: center; box-shadow: 0 10px 24px rgba(192, 150, 84, .18);
  transition: transform .16s, filter .16s;
}
.add-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.add-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.task-list { display: grid; gap: 9px; min-width: 0; }
.task-card {
  display: flex;
  min-width: 0; gap: 12px; align-items: flex-start;
  background: linear-gradient(145deg, rgba(21, 35, 51, .94), rgba(14, 24, 37, .96));
  border: 1px solid var(--line-soft); border-radius: var(--radius-md);
  padding: 14px 14px 13px; transition: border-color .18s, transform .18s;
}
.task-card:hover { border-color: #324760; }
.task-card.completed { opacity: .58; }
.task-card.completed .task-title { text-decoration: line-through; text-decoration-color: #718096; }
.check-btn {
  flex: 0 0 auto; width: 23px; height: 23px; border-radius: 50%;
  border: 1.5px solid #71839a; background: transparent; margin-top: 1px;
  display: grid; place-items: center; color: transparent; transition: all .18s;
}
.check-btn:hover { border-color: var(--gold); }
.task-card.completed .check-btn { border-color: var(--green); background: var(--green); color: #0f231c; }
.check-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.task-body { min-width: 0; flex: 1; cursor: pointer; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-title { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.priority-mark { flex: 0 0 auto; font-size: 9px; letter-spacing: .08em; padding: 4px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.priority-mark.high { color: var(--danger-soft); border-color: rgba(217, 122, 109, .3); background: rgba(217, 122, 109, .06); }
.priority-mark.low { color: #98a9bb; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 7px; font-size: 10px; color: var(--muted); }
.task-meta .urgent { color: var(--danger-soft); }
.task-meta .soon { color: var(--gold); }
.task-meta .done { color: var(--green); }
.task-note { margin: 7px 0 0; color: var(--faint); font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.empty-state { text-align: center; padding: 30px 16px; border: 1px dashed #2a3b50; border-radius: var(--radius-md); color: var(--faint); font-size: 12px; line-height: 1.7; }
.empty-state strong { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; color: #53647a; font-size: 9px; letter-spacing: .04em; }
.cloud-badge { border: 1px solid #2b3e54; border-radius: 999px; padding: 4px 8px; color: #6f8299; }

/* Login */
.login-overlay {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 22px;
  background:
    radial-gradient(700px 500px at 50% -15%, rgba(65, 95, 125, .35), transparent 65%),
    #0a111a;
}
.login-card {
  width: min(100%, 390px); background: linear-gradient(155deg, #142335, #0e1925);
  border: 1px solid #27394e; border-radius: 26px; padding: 30px 25px 24px;
  box-shadow: var(--shadow);
}
.login-mark { width: 52px; height: 52px; border-radius: 15px; overflow: hidden; margin-bottom: 21px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
.login-mark img { width: 100%; height: 100%; display: block; }
.eyebrow { margin: 0 0 8px; color: var(--gold-dim); font-size: 9px; letter-spacing: .18em; }
.login-card h1 { margin: 0; font-size: 30px; letter-spacing: .02em; }
.login-copy { color: var(--muted); font-size: 12px; line-height: 1.75; margin: 12px 0 24px; }
label { display: block; color: #a9b6c6; font-size: 11px; margin: 15px 0 8px; }
input, textarea {
  width: 100%; color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 13px; font-size: 14px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input::placeholder, textarea::placeholder { color: #526378; }
input:focus, textarea:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(217, 180, 119, .08); }
textarea { resize: vertical; min-height: 82px; line-height: 1.55; }
.secret-field { position: relative; }
.secret-field input { padding-right: 56px; }
.inline-link { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--gold-dim); font-size: 11px; padding: 6px; }
.primary-btn, .secondary-btn, .danger-btn {
  border-radius: var(--radius-sm); padding: 12px 16px; border: 1px solid transparent; font-weight: 650; font-size: 13px;
  transition: transform .16s, filter .16s, background .16s;
}
.primary-btn { width: 100%; background: linear-gradient(145deg, #e4c286, #cfa568); color: #171107; box-shadow: 0 12px 26px rgba(192, 150, 84, .16); }
.primary-btn:hover { filter: brightness(1.04); }
.primary-btn:active { transform: translateY(1px); }
.secondary-btn { background: transparent; color: var(--gold-bright); border-color: #4a3d2b; }
.secondary-btn:hover { background: #1a2635; }
.danger-btn { background: transparent; color: var(--danger-soft); border-color: rgba(217, 122, 109, .28); }
.form-error { min-height: 16px; margin: 8px 0 0; color: var(--danger-soft); font-size: 11px; line-height: 1.5; }
.login-hint { color: #586a80; font-size: 9.5px; line-height: 1.6; margin: 15px 0 0; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 8, 14, .68); backdrop-filter: blur(3px); }
.sheet {
  position: relative; z-index: 1; width: min(100%, 520px); max-height: 92svh; overflow-y: auto;
  background: linear-gradient(160deg, #152436, #0e1925); border: 1px solid #2a3d53;
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -24px 70px rgba(0, 0, 0, .35); animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(18px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.sheet-grip { width: 34px; height: 4px; border-radius: 999px; background: #33475e; margin: 0 auto 16px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.priority-row { display: flex; gap: 7px; }
.priority-chip { flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 9px; padding: 9px; font-size: 12px; }
.priority-chip.active { border-color: #8a6c43; color: var(--gold-bright); background: rgba(217, 180, 119, .08); }
.optional { color: var(--faint); font-weight: 400; }
.sheet-actions { display: flex; gap: 9px; margin-top: 20px; }
.sheet-actions .primary-btn { flex: 1; }
.sheet-actions .danger-btn { flex: 0 0 auto; }
.status-card { display: flex; gap: 12px; align-items: flex-start; background: #0e1a27; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 14px 0 4px; }
.status-card p { margin: 4px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.status-card strong { font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 5px; flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(217, 180, 119, .08); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(102, 199, 160, .08); }
.field-help { color: #607187; font-size: 9.5px; line-height: 1.5; margin: 7px 0 0; }
.settings-actions { display: flex; gap: 9px; margin-top: 17px; }
.settings-actions .primary-btn { flex: 1; }
.settings-divider { height: 1px; background: var(--line-soft); margin: 22px 0 6px; }
.settings-link { display: block; width: 100%; border: 0; background: transparent; color: #9eacbc; text-align: left; padding: 12px 0; font-size: 12px; }
.danger-text { color: var(--danger-soft); }
.settings-foot { color: #5e7085; font-size: 9.5px; line-height: 1.65; margin: 12px 0 0; }

/* Toast */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 14px); max-width: min(90vw, 380px);
  background: #1b2b3e; border: 1px solid #38506a; color: #e9edf3;
  border-radius: 12px; padding: 10px 14px; font-size: 11.5px; line-height: 1.5;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 14px 35px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(217, 122, 109, .45); color: #ffd2ca; }
.toast.success { border-color: rgba(102, 199, 160, .35); color: #c9f1df; }

@media (min-width: 680px) {
  .app { padding-top: 34px; }
  .content { grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); align-items: start; gap: 26px; }
  .calendar-card { padding: 24px 23px 22px; }
  .day-section { padding-top: 3px; }
  .day-head h2 { font-size: 24px; }
  .modal { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; padding: 12px 24px 25px; }
  .sheet-grip { margin-bottom: 18px; }
}
@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .calendar-card { padding-left: 12px; padding-right: 12px; }
  .month-title strong { font-size: 26px; }
  .task-card { padding: 12px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
