:root {
  color-scheme: dark;
  --bg: #151515;
  --sidebar: #202020;
  --panel: #252525;
  --panel-2: #303030;
  --text: #e7e7e7;
  --muted: #9c9c9c;
  --line: #414141;
  --blue: #22a7d6;
  --green: #62b85a;
  --gray: #a3a3a3;
  --red: #e55b55;
  --yellow: #e5a83d;
  --violet: #b36bd4;
  --shadow: 0 12px 34px rgba(0, 0, 0, .42);
}

body.light {
  color-scheme: light;
  --bg: #e8ebed;
  --sidebar: #f6f7f8;
  --panel: #ffffff;
  --panel-2: #e4e8eb;
  --text: #202428;
  --muted: #646b70;
  --line: #c5ccd1;
  --shadow: 0 18px 45px rgba(24, 34, 44, .13);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, .012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .012) 1px, transparent 1px);
  background-size: 64px 64px, 64px 64px, 16px 16px, 16px 16px;
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  user-select: none;
}
button, input, textarea, select { font: inherit; }
button, .file-button { cursor: pointer; }
button { border: 0; }
input, textarea, select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  user-select: text;
}
textarea { min-height: 92px; resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--blue); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 27px; }
h2 { margin-bottom: 0; font-size: 19px; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.6; }
.small { font-size: 12px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; }

.primary-button, .secondary-button, .danger-button, .text-button, .file-button {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 6px;
  color: var(--text);
  text-align: center;
}
.primary-button { background: #117da3; color: white; border: 1px solid #35bde9; }
.secondary-button, .file-button { border: 1px solid var(--line); background: var(--panel-2); }
.danger-button { border: 1px solid rgba(239, 98, 98, .42); background: rgba(239, 98, 98, .1); color: var(--red); }
.text-button { background: transparent; color: var(--blue); }
.compact { min-height: 34px; padding: 6px 10px; }
.icon-button {
  width: 38px; height: 38px; border-radius: 6px;
  background: var(--panel-2); color: var(--text); font-size: 24px;
}

.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.lock-panel {
  width: min(430px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--blue);
}
.lock-panel h1 { margin: 12px 0 10px; font-size: 34px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 4px; background: #126f91; border: 1px solid #35bde9; color: white; font-weight: 800;
}
.brand-mark.large { width: 52px; height: 52px; font-size: 22px; }
.profile-avatar {
  width: 48px; aspect-ratio: 1; flex: 0 0 auto; object-fit: cover; object-position: center;
  border: 1px solid #35bde9; border-radius: 4px; background: var(--panel-2);
}
.profile-avatar.large { width: 72px; }
.profile-avatar.preview { width: 112px; grid-row: span 3; }
.stack, .field, .form-grid { display: grid; gap: 8px; }
.stack { gap: 14px; margin-top: 22px; }
.field > span, .filterbar label { color: var(--muted); font-size: 12px; }
.message { min-height: 20px; margin: 12px 0 0; color: var(--yellow); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 235px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px;
  display: flex; flex-direction: column; gap: 24px;
  border-right: 1px solid #080808; background: var(--sidebar);
  box-shadow: inset -1px 0 #353535;
}
.brand-row { display: flex; align-items: center; gap: 11px; }
.nav-list, .sidebar-footer { display: grid; gap: 7px; }
.nav-item {
  min-height: 42px; padding: 9px 11px; display: flex; align-items: center; gap: 10px;
  border-radius: 3px; background: transparent; color: var(--muted); text-align: left;
}
.nav-item.active { background: #143d4b; color: #dff7ff; box-shadow: inset 3px 0 var(--blue); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { margin-top: auto; }
#importFile, #avatarFile { display: none; }

.workspace { min-width: 0; padding: 22px 28px 36px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.search-field {
  width: min(360px, 34vw); display: flex; align-items: center; gap: 8px;
  padding-left: 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
.search-field input { border: 0; background: transparent; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 20px 0 12px; }
.summary-grid.large { margin-top: 0; }
.summary-card {
  min-height: 82px; padding: 14px; border: 1px solid var(--line);
  border-radius: 4px; background: var(--panel); box-shadow: inset 0 1px #383838;
}
.summary-card:nth-child(1) { border-top: 2px solid var(--blue); }
.summary-card:nth-child(2) { border-top: 2px solid var(--red); }
.summary-card:nth-child(3) { border-top: 2px solid var(--yellow); }
.summary-card:nth-child(4) { border-top: 2px solid var(--green); }
.summary-card strong { display: block; margin-top: 6px; font-size: 23px; }
.reminder-panel {
  margin-bottom: 12px; padding: 13px 15px; border: 1px solid rgba(227, 173, 79, .4);
  border-radius: 8px; background: rgba(227, 173, 79, .08);
}
.filterbar {
  margin-bottom: 18px; display: flex; gap: 10px; align-items: end;
  padding: 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); box-shadow: inset 0 1px #383838;
}
.filterbar label { display: grid; gap: 5px; }
.filterbar select { min-width: 130px; min-height: 34px; padding: 5px 9px; }

.view { display: none; }
.active-view { display: block; }
.section-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.segmented button { min-height: 32px; padding: 5px 13px; border-radius: 4px; background: transparent; color: var(--muted); }
.segmented button.active { background: #16536a; color: #e8faff; box-shadow: inset 0 -2px var(--blue); }
.calendar-nav { display: flex; gap: 8px; align-items: center; }
.calendar-nav strong { min-width: 120px; text-align: center; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays span { padding: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.calendar-grid { gap: 7px; }
.calendar-day {
  min-height: 108px; padding: 8px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 3px; background: rgba(37, 37, 37, .94); color: var(--text); text-align: left;
  box-shadow: inset 0 1px #373737;
}
.calendar-day.outside { opacity: .38; }
.calendar-day.selected { outline: 2px solid #38bce9; outline-offset: -2px; background: #1e3037; }
.calendar-day.today .day-number { background: var(--blue); color: white; }
.day-number { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; }
.day-dots { display: grid; gap: 4px; margin-top: 7px; }
.calendar-item {
  padding: 4px 6px; overflow: hidden; border-left: 3px solid var(--blue);
  border-radius: 2px; background: rgba(34, 167, 214, .15); font-size: 11px;
  text-overflow: ellipsis; white-space: nowrap;
}
.calendar-item.done { opacity: .45; text-decoration: line-through; border-color: var(--gray); }
.day-agenda { margin-top: 22px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.item-list, .card-grid { display: grid; gap: 9px; }
.card-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.item-card {
  position: relative; padding: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  border: 1px solid #090909; border-left: 4px solid var(--blue); border-radius: 4px; background: var(--panel);
  box-shadow: inset 0 1px #3a3a3a, 0 3px 10px rgba(0, 0, 0, .28);
}
.item-card.plan { border-left-color: var(--green); display: block; }
.item-card.todo { border-left-color: var(--gray); }
.item-card.overdue { border-color: rgba(239, 98, 98, .62); border-left-color: var(--red); }
.item-card.completed { opacity: .58; filter: grayscale(.55); }
.item-card.completed h3 { text-decoration: line-through; }
.item-card.priority-high::after {
  content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red);
}
.check-button { padding-top: 2px; }
.check-button input { cursor: pointer; }
.item-main h3 { margin: 0 0 5px; font-size: 16px; }
.item-meta { color: var(--muted); font-size: 12px; line-height: 1.65; }
.item-note { margin: 6px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.item-actions button { min-height: 31px; padding: 5px 8px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 999px; color: white; font-size: 11px; }
.archive-section { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(25, 25, 25, .78); }
.archive-section summary { cursor: pointer; color: var(--muted); }
.archive-section .item-list, .archive-section .card-grid { margin-top: 10px; }
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }

.progress-track { height: 8px; margin: 12px 0 7px; overflow: hidden; border-radius: 99px; background: var(--panel-2); }
.progress-bar { height: 100%; background: var(--green); }
.subtask-list { display: grid; gap: 7px; margin-top: 12px; }
.subtask-row { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.subtask-row.done { text-decoration: line-through; opacity: .6; }
.tag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.tag-card { padding: 14px; display: flex; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.tag-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 7px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.profile-settings { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center; margin-top: 16px; }
.profile-settings .field { align-self: stretch; }
.profile-settings .secondary-button { align-self: stretch; display: grid; place-items: center; }
.study-history { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.study-history summary { cursor: pointer; }
.study-session-list { display: grid; gap: 6px; margin-top: 8px; }
.study-session-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 8px; background: var(--panel-2); }
.study-session-row button { min-height: 28px; white-space: nowrap; color: var(--red); }
.panel-section { padding: 17px; border: 1px solid #090909; border-radius: 4px; background: var(--panel); box-shadow: inset 0 1px #3a3a3a; }
.setting-row { min-height: 48px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.setting-row input { width: 18px; }
.bar-chart { min-height: 240px; display: grid; grid-template-columns: repeat(31, minmax(5px, 1fr)); gap: 4px; align-items: end; }
.bar-column { min-height: 8px; border-radius: 3px 3px 0 0; background: var(--blue); position: relative; }
.bar-column:hover::after { content: attr(data-label); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 4px 6px; background: var(--panel-2); white-space: nowrap; font-size: 11px; }

.modal {
  width: min(720px, calc(100% - 26px)); max-height: calc(100vh - 30px); overflow: auto;
  padding: 0; border: 1px solid #080808; border-radius: 4px; background: var(--panel); color: var(--text); box-shadow: var(--shadow);
  border-top: 3px solid var(--blue);
}
.modal::backdrop { background: rgba(0, 0, 0, .68); }
.modal form { padding: 20px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.form-grid { gap: 13px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-chip { padding: 7px 9px; display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 6px; }
.checkbox-chip input { width: 16px; min-height: 16px; }
.modal-actions { margin-top: 20px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 9px; align-items: center; }

.privacy-watermark::after {
  content: "PRIVATE";
  position: fixed; inset: 0; z-index: 100; pointer-events: none;
  display: grid; place-items: center; color: rgba(130, 142, 151, .055);
  font-size: min(16vw, 160px); font-weight: 900; transform: rotate(-20deg);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { grid-template-columns: repeat(3, 1fr); }
  .sidebar-footer { grid-template-columns: repeat(3, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-day { min-height: 92px; }
}

@media (max-width: 680px) {
  .workspace, .sidebar { padding: 15px; }
  .topbar, .top-actions, .section-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .filterbar { display: grid; grid-template-columns: 1fr 1fr; }
  .filterbar label:last-child { grid-column: 1 / -1; }
  .nav-list { grid-template-columns: repeat(2, 1fr); }
  .sidebar-footer { grid-template-columns: 1fr; }
  .calendar-grid { gap: 3px; }
  .calendar-day { min-height: 70px; padding: 5px; }
  .calendar-item { font-size: 0; height: 7px; padding: 0; }
  .item-card { grid-template-columns: auto minmax(0, 1fr); }
  .item-actions { grid-column: 2; justify-content: flex-start; }
  .form-row, .settings-grid { grid-template-columns: 1fr; }
  .profile-settings { grid-template-columns: 1fr; }
  .profile-avatar.preview { grid-row: auto; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
