*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f0f13; --surface: #1a1a24; --surface2: #24243a; --border: #2a2a40;
  --text: #e8e8f0; --text2: #9898b0; --accent: #6c63ff; --accent2: #8b83ff;
  --green: #4ade80; --red: #f87171; --yellow: #fbbf24; --blue: #60a5fa;
  --radius: 12px; --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent2); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* Layout */
.app { max-width: 1000px; margin: 0 auto; padding: 16px; }
header { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
header h1 { font-size: 1.5rem; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav button { background: var(--surface); color: var(--text2); padding: 8px 16px; border-radius: 8px; font-size: .85rem; font-weight: 500; transition: all .2s; }
nav button:hover, nav button.active { background: var(--accent); color: #fff; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 1.1rem; margin-bottom: 12px; color: var(--text); }
.card h3 { font-size: .95rem; color: var(--text2); margin-bottom: 8px; }

/* Task/Chore items */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface2); border-radius: 10px; margin-bottom: 8px; transition: all .2s; }
.item:hover { background: #2e2e4a; }
.item-overdue { border-left: 3px solid var(--red); }
.item-done { opacity: 0.7; }
.item .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.item .check:hover { border-color: var(--green); }
.item .check.done { background: var(--green); border-color: var(--green); }
.item .check.done::after { content: '✓'; color: #000; font-size: 13px; font-weight: 700; }
.item .info { flex: 1; }
.item .info .title { font-weight: 500; }
.item .info .meta { font-size: .8rem; color: var(--text2); margin-top: 2px; }
.item .done-text { text-decoration: line-through; color: var(--text2); }
.item .actions { display: flex; gap: 6px; }
.item .actions button { background: none; color: var(--text2); font-size: .8rem; padding: 4px 8px; border-radius: 6px; }
.item .actions button:hover { background: var(--surface); color: var(--text); }
.del-btn:hover { color: var(--red) !important; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.badge-daily { background: #1a3a2a; color: var(--green); }
.badge-weekly { background: #3a2a1a; color: var(--yellow); }
.badge-monthly { background: #1a2a3a; color: var(--blue); }
.badge-diff { background: var(--surface); color: var(--accent2); }
.badge-user { background: #2a1a3a; color: #c084fc; }

/* Buttons */
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: .9rem; transition: all .2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* Forms */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row > * { flex: 1; }
label { display: block; font-size: .85rem; color: var(--text2); margin-bottom: 4px; font-weight: 500; }

/* User tabs */
.user-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.user-tab { padding: 10px 24px; border-radius: 10px; background: var(--surface); color: var(--text2); font-weight: 600; transition: all .2s; }
.user-tab:hover { background: var(--surface2); }
.user-tab.active { background: var(--accent); color: #fff; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 90%; max-width: 500px; }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ══════════════════════════════════════════
   CALENDAR
   ══════════════════════════════════════════ */

.calendar-card { padding: 16px; }
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.calendar-header h2 { font-size: 1.2rem; margin: 0; }
.calendar-nav { display: flex; gap: 6px; }
.calendar-views { display: flex; gap: 4px; }
.cal-view-btn { background: var(--surface2); color: var(--text2); }
.cal-view-btn.active { background: var(--accent); color: #fff; }

/* Month grid */
.calendar-grid { }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header-row { margin-bottom: 4px; }
.cal-day-name { text-align: center; font-size: .75rem; font-weight: 600; color: var(--text2); padding: 8px 4px; text-transform: uppercase; letter-spacing: .5px; }
.cal-cell { min-height: 80px; background: var(--surface2); border-radius: 8px; padding: 6px; cursor: pointer; transition: all .15s; overflow: hidden; }
.cal-cell:hover { background: #2e2e4a; }
.cal-empty { background: transparent; cursor: default; }
.cal-empty:hover { background: transparent; }
.cal-today { border: 2px solid var(--accent); }
.cal-selected { background: #2a2a50 !important; }
.cal-day-num { font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.cal-today .cal-day-num { color: var(--accent); }

/* Calendar dots/items in month view */
.cal-dots { display: flex; flex-direction: column; gap: 2px; }
.cal-dot { font-size: .65rem; padding: 1px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-dot-task { background: #1a2a3a; color: var(--blue); }
.cal-dot-chore { background: #2a1a3a; color: #c084fc; }
.cal-dot-done { background: #1a3a2a; color: var(--green); opacity: .7; }
.cal-dot-overdue { background: #3a1a1a; color: var(--red); }
.cal-dot-more { background: var(--surface); color: var(--text2); font-style: italic; }

/* Week view */
.cal-week-view { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-week-day { background: var(--surface2); border-radius: 10px; padding: 10px; min-height: 200px; cursor: pointer; transition: all .15s; }
.cal-week-day:hover { background: #2e2e4a; }
.cal-week-day.cal-today { border: 2px solid var(--accent); }
.cal-week-day.cal-selected { background: #2a2a50; }
.cal-week-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.cal-week-dayname { font-size: .75rem; color: var(--text2); font-weight: 600; text-transform: uppercase; }
.cal-week-items { display: flex; flex-direction: column; gap: 4px; }
.cal-item { font-size: .75rem; padding: 4px 6px; border-radius: 6px; cursor: pointer; transition: all .15s; }
.cal-item:hover { filter: brightness(1.2); }
.cal-item-task { background: #1a2a3a; color: var(--blue); }
.cal-item-chore { background: #2a1a3a; color: #c084fc; }
.cal-item-done { background: #1a3a2a; color: var(--green); opacity: .7; text-decoration: line-through; }
.cal-item-overdue { background: #3a1a1a; color: var(--red); }
.cal-item small { opacity: .7; }

/* Day view */
.cal-day-view { }
.cal-day-section { margin-bottom: 16px; }
.cal-day-section h3 { margin-bottom: 10px; }
.cal-day-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; }
.cal-day-item.cal-item-task { background: #1a2a3a; }
.cal-day-item.cal-item-chore { background: #2a1a3a; }
.cal-day-item.cal-item-done { background: #1a3a2a; text-decoration: line-through; opacity: .7; }
.cal-day-item.cal-item-overdue { background: #3a1a1a; }
.cal-day-item .check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cal-day-item .check.done { background: var(--green); border-color: var(--green); }
.cal-day-item .check.done::after { content: '✓'; color: #000; font-size: 12px; font-weight: 700; }
.cal-day-item-title { flex: 1; font-size: .9rem; }
.cal-day-item-user { font-size: .75rem; color: #c084fc; background: #2a1a3a; padding: 2px 8px; border-radius: 6px; }
.cal-day-edit { background: none; border: none; cursor: pointer; font-size: .85rem; color: var(--text2); padding: 4px; }
.cal-day-edit:hover { color: var(--text); }
.cal-empty-msg { color: var(--text2); font-size: .9rem; padding: 8px 0; }

/* ══════════════════════════════════════════
   SCHEDULING
   ══════════════════════════════════════════ */

.schedule-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.schedule-item { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: var(--surface2); border-radius: 10px; }
.schedule-user { font-weight: 600; font-size: 1rem; min-width: 140px; }
.schedule-info { font-size: .85rem; color: var(--text2); }
.schedule-info div { margin-bottom: 2px; }
.schedule-info strong { color: var(--text); }
.schedule-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.success-msg { color: var(--green); background: #1a3a2a; padding: 10px 16px; border-radius: 8px; font-size: .9rem; }
.info-msg { color: var(--blue); background: #1a2a3a; padding: 10px 16px; border-radius: 8px; font-size: .9rem; }
.digest-preview { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 12px; font-size: .85rem; color: var(--text); white-space: pre-wrap; font-family: var(--font); max-height: 300px; overflow-y: auto; }

/* Responsive */
@media (max-width: 768px) {
  .cal-week-view { grid-template-columns: 1fr; }
  .cal-week-day { min-height: auto; }
  .cal-cell { min-height: 60px; }
  .cal-dot { font-size: .6rem; }
  .schedule-item { flex-direction: column; align-items: flex-start; gap: 4px; }
}
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  header { flex-direction: column; gap: 12px; }
  nav { flex-wrap: wrap; justify-content: center; }
  .calendar-header { flex-direction: column; align-items: flex-start; }
  .cal-cell { min-height: 50px; padding: 4px; }
  .cal-day-num { font-size: .75rem; }
  .cal-dot { font-size: .55rem; }
}
