:root {
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-main: #1a1a1a;
  --text-sec: #666666;
  --primary: #0066ff;
  --primary-light: rgba(0, 102, 255, 0.1);
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --border: #e1e4e8;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --sidebar-w: 200px;
  --sidebar-icon-w: 60px;
}

[data-theme="dark"] {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-main: #e0e0e0;
  --text-sec: #a0a0a0;
  --primary: #3391ff;
  --primary-light: rgba(51, 145, 255, 0.15);
  --border: #333333;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: "PingFang SC", -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.3s;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s, min-width 0.25s;
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-icon-w);
  min-width: var(--sidebar-icon-w);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  min-height: 60px;
}

.sidebar-logo i {
  font-size: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text-main);
  transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-sec);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}

.nav-item i {
  font-size: 20px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.nav-item-label {
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-item-label { opacity: 0; width: 0; }

.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }

.sidebar-bottom {
  padding: 8px 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  position: relative;
}

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }

/* ── Calendar Page ── */
.cal-page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  height: fit-content;
}

@media (min-width: 600px) { .card { padding: 28px; } }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-sec);
}
.section-title i { color: var(--primary); font-size: 18px; }

/* ── Large Calendar ── */
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.cal-nav { display: flex; gap: 8px; }
.cal-nav button {
  background: var(--bg-color); border: none; width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; color: var(--primary); font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
#cal-lbl-text { font-size: 20px; font-weight: 700; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-lbl { text-align: center; color: var(--text-sec); font-size: 15px; padding-bottom: 10px; font-weight: 700; }

.cal-day {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; position: relative;
  background: var(--bg-color); cursor: pointer; transition: 0.15s;
  font-size: 18px;
}

.cal-day:hover { background: var(--primary-light); }
.day-rest, .day-holiday { color: var(--danger); }
.day-muted { opacity: 0.25; cursor: default; }

.day-w6 { background: #fff7e6 !important; border: 2px solid #ffa940 !important; }
[data-theme="dark"] .day-w6 { background: #2b2111 !important; border-color: #d48806 !important; }
.day-w15 { background: #e6f7ff !important; border: 2px solid #40a9ff !important; }
[data-theme="dark"] .day-w15 { background: #111d2c !important; border-color: #096dd9 !important; }

.day-today { background: var(--primary) !important; color: white !important; font-weight: bold; border: 2px solid var(--primary) !important; }
.badge { font-size: 12px; opacity: 0.75; margin-top: 1px; font-weight: 700; }

.holiday-name { position: absolute; top: 3px; right: 4px; font-size: 9px; font-weight: bold; }

.note-dot {
  position: absolute; bottom: 3px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--primary);
}

/* ── Stats ── */
.stats-container { display: flex; flex-direction: column; gap: 16px; }

.progress-item { margin-bottom: 16px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 15px; font-weight: 600; }
.progress-bar { height: 12px; background: var(--bg-color); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0; transition: width 1s; }
.progress-fill.success { background: var(--success); }

.summary-text { font-size: 14px; color: var(--text-sec); margin-top: 6px; }

.counter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.counter-item { display: flex; flex-direction: column; gap: 2px; }
.counter-item .label { font-size: 13px; color: var(--text-sec); text-transform: uppercase; letter-spacing: 0.5px; }
.counter-item .val { font-size: 26px; font-weight: 700; color: var(--text-main); }

/* ── Holiday Cards ── */
.tip-card {
  border-left: 4px solid var(--primary);
  padding: 12px; background: var(--primary-light);
  border-radius: 10px; margin-bottom: 12px;
}
.tip-title { font-weight: 700; font-size: 16px; margin-bottom: 2px; display: flex; justify-content: space-between; }
.tip-desc { font-size: 14px; color: var(--text-sec); line-height: 1.5; }
.countdown-tag { font-size: 14px; color: var(--primary); font-weight: 700; }

/* ── Memo Page ── */
.memo-page-wrapper {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: 1fr;
  overflow: hidden;
}

.memo-left-container {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-color);
}
.memo-nav-top {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  gap: 16px;
  flex-shrink: 0;
  position: relative;
}
.memo-date-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--primary);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.memo-date-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.memo-today-btn {
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-sec);
  transition: all 0.15s;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.memo-today-btn:hover { border-color: var(--primary); color: var(--primary); }
.memo-save-status {
  position: absolute;
  right: 24px;
  font-size: 12px;
  color: var(--text-sec);
  font-weight: bold;
}

.memo-cols-wrap {
  display: flex;
  flex-direction: row;
  flex: 1;
  gap: 16px;
  padding: 10px 20px 30px 20px;
  overflow: hidden;
}
.memo-col {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s;
}
.memo-col.prev-day { flex: 1; opacity: 0.85; margin: 30px 0; }
.memo-col.curr-day { flex: 1.3; border: 2px solid var(--primary); box-shadow: var(--shadow); transform: scale(1.02); z-index: 10; margin: 10px 4px; }
.memo-col.next-day { flex: 1; opacity: 0.85; margin: 30px 0; }
.memo-col:hover { opacity: 1; }

.memo-col-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-color);
  text-align: center;
}
.curr-day .memo-col-header { background: var(--primary-light); }
.memo-col-title { font-size: 16px; font-weight: 700; color: var(--text-main); }
.curr-day .memo-col-title { color: var(--primary); font-size: 18px; }
.memo-col-sub { font-size: 12px; color: var(--text-sec); }

.memo-textarea {
  flex: 1;
  width: 100%;
  border: none;
  padding: 16px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: none;
  line-height: 1.8;
}
.memo-textarea::placeholder { color: var(--text-sec); opacity: 0.5; }

/* Right panel */
.memo-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card-bg);
  width: 280px;
  min-width: 280px;
}

/* Mini cal */
.mini-cal-wrap {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 260px;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mini-cal-lbl { font-size: 14px; font-weight: 700; }

.mini-cal-nav button {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.mini-cal-nav button:hover { background: var(--primary-light); }
.mini-cal-nav { display: flex; gap: 4px; }

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cal-day-lbl {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sec);
  padding-bottom: 4px;
}

.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  min-height: 28px;
}
.mini-cal-day:hover { background: var(--primary-light); }
.mini-cal-day.muted { opacity: 0.3; cursor: default; }
.mini-cal-day.today { background: var(--primary); color: white; font-weight: 700; }
.mini-cal-day.selected { outline: 2px solid var(--primary); }
.mini-cal-day.today.selected { outline: none; }
.mini-cal-day.rest { color: var(--danger); }
.mini-cal-day .mini-note-dot {
  position: absolute; bottom: 1px;
  width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary);
}
.mini-cal-day.today .mini-note-dot { background: white; }

/* TODO */
.todo-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px 16px;
}

.todo-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.todo-header i { color: var(--primary); font-size: 16px; }

.todo-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.todo-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--bg-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.todo-input:focus { border-color: var(--primary); }

.todo-add-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.todo-add-btn:hover { opacity: 0.85; }

.todo-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.todo-item:hover { background: var(--bg-color); }

.todo-item.done { opacity: 0.45; }
.todo-item.done .todo-text { text-decoration: line-through; }

.todo-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 10px;
  color: white;
}
.todo-item.done .todo-check {
  background: var(--success);
  border-color: var(--success);
}

.todo-text {
  font-size: 12px;
  line-height: 1.6;
  flex: 1;
  color: var(--text-main);
  word-break: break-all;
}

.todo-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-sec);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0 2px;
  flex-shrink: 0;
}
.todo-item:hover .todo-del { opacity: 1; }
.todo-del:hover { color: var(--danger); }

/* ── Mobile responsive ── */
@media (max-width: 700px) {
  .sidebar { width: var(--sidebar-icon-w); min-width: var(--sidebar-icon-w); }
  .sidebar .sidebar-logo-text, .sidebar .nav-item-label { opacity: 0; width: 0; }

  .memo-page-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .memo-cols-wrap {
    flex-direction: column;
    overflow-y: auto;
    gap: 12px;
  }
  .memo-col { transform: none !important; margin: 0 !important; flex: none; height: 260px; }
  .memo-right {
    flex-direction: row;
    border-top: 1px solid var(--border);
    height: 220px;
  }
  .mini-cal-wrap {
    flex: 1;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .todo-wrap { flex: 1; }
}
