:root {
  --bg: #faf9f8;
  --sidebar-bg: #f3f2f1;
  --white: #ffffff;
  --text: #323130;
  --muted: #605e5c;
  --accent: #2564cf;
  --accent-hover: #1a56ba;
  --accent-light: #eff6fc;
  --border: #e1dfdd;
  --border-hover: #c8c6c4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.14);
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* App Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; height: 100vh; top: 0; left: 0; }
.main-pane { flex: 1; margin-left: 260px; padding: 24px 32px; max-width: 900px; }

/* Sidebar */
.sidebar-header { padding: 20px 16px; }
.sidebar-header .app-name { font-size: 20px; font-weight: 600; color: var(--accent); }
.user-block { padding: 12px 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-block .avatar { width: 32px; height: 32px; background: var(--accent); color: var(--white); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.user-block .user-info { flex: 1; }
.user-block .display-name { font-weight: 600; font-size: 14px; }
.user-block .username { font-size: 12px; color: var(--muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--text); text-decoration: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-right: 8px; margin-left: 8px; }
.sidebar-link:hover { background: var(--white); text-decoration: none; }
.sidebar-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sidebar-link .icon { font-size: 16px; opacity: 0.7; }
.sidebar-link.active .icon { opacity: 1; }
.sidebar-link .count { margin-left: auto; background: var(--white); padding: 2px 8px; border-radius: 10px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow-sm); }
.sidebar-link.active .count { background: var(--white); color: var(--accent); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* Container for non-sidebar pages */
.container { max-width: 760px; margin: 0 auto; padding: 24px 16px; }

/* Cards */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; margin: 8px 0; box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow); }

/* Page Head */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.page-head h1 { font-size: 28px; margin: 0; font-weight: 600; }
.head-actions { display: flex; gap: 8px; }

/* Buttons */
button { cursor: pointer; font: inherit; border: none; border-radius: var(--radius); padding: 8px 16px; font-size: 14px; transition: all 0.15s ease; }
.btn-primary { background: var(--accent); color: var(--white); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--accent-light); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); }
.btn-ghost.sm { padding: 6px 10px; font-size: 12px; }
.btn-danger { background: #d13438; color: var(--white); }
.btn-danger:hover { background: #a80000; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Inputs */
input[type=text], input[type=password], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); color: var(--text); font: inherit; transition: border-color 0.15s ease; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
label input, label select { margin-top: 4px; color: var(--text); }
.row-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-form input { flex: 1; min-width: 140px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.inline { display: inline; margin: 0; }

/* Login Page */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { width: 360px; padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; color: var(--accent); margin: 0 0 8px; text-align: center; }
.login-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 24px; }
.alert { background: #fde7e9; color: #a80000; padding: 12px; border-radius: var(--radius); margin-bottom: 16px; border-left: 4px solid #a80000; }

/* Lists Grid */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.list-card { display: block; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; color: var(--text); text-decoration: none; transition: all 0.15s ease; box-shadow: var(--shadow-sm); }
.list-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.list-card.shared { border-left: 3px solid #107c10; }
.list-card.mine { border-left: 3px solid var(--accent); }
.lc-name { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.lc-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { font-size: 10px; padding: 3px 8px; border-radius: 10px; background: var(--sidebar-bg); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.tag.shared { background: #dff6dd; color: #107c10; }

/* Task List */
.task-list { list-style: none; padding: 0; margin: 0; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; box-shadow: var(--shadow-sm); transition: all 0.15s ease; }
.task:hover { box-shadow: var(--shadow); border-color: var(--border-hover); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.done { opacity: 0.7; }
.task.dragging { opacity: 0.4; }
.task.drag-over { border-top: 2px solid var(--accent); }
.task.drag-handle { cursor: grab; color: var(--muted); user-select: none; padding: 4px; opacity: 0; transition: opacity 0.15s; }
.task:hover .drag-handle { opacity: 1; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 15px; word-break: break-word; }
.task-notes { font-size: 13px; color: var(--muted); margin-top: 4px; word-break: break-word; }
.task-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.task:hover .task-actions { opacity: 1; }

/* Circular Checkbox */
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); background: transparent; flex-shrink: 0; margin-top: 2px; padding: 0; cursor: pointer; transition: all 0.15s ease; }
.check:hover { border-color: var(--accent); }
.check.checked { background: var(--accent); border-color: var(--accent); }
.check.checked::after { content: ""; width: 8px; height: 4px; border: solid var(--white); border-width: 0 0 2px 2px; transform: rotate(-45deg); display: block; margin: 5px 4px; }

/* Add Task Row */
.add-task-row { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; display: flex; align-items: center; gap: 12px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.add-task-row .add-btn { width: 32px; height: 32px; background: var(--accent); color: var(--white); border-radius: 50%; border: none; font-size: 20px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.add-task-row .add-btn:hover { background: var(--accent-hover); }
.add-task-row input { border: none; padding: 8px 0; background: transparent; }
.add-task-row input:focus { outline: none; border: none; box-shadow: none; }
.add-task-row input::placeholder { color: var(--muted); }

/* Completed Section */
.completed-section details { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); margin-top: 24px; box-shadow: var(--shadow-sm); }
.completed-section summary { padding: 12px 16px; cursor: pointer; font-weight: 600; color: var(--muted); user-select: none; display: flex; align-items: center; gap: 8px; }
.completed-section summary:hover { background: var(--sidebar-bg); }
.completed-section summary::before { content: "▶"; font-size: 10px; transition: transform 0.15s; }
.completed-section details[open] summary::before { transform: rotate(90deg); }
.completed-section .count { background: var(--sidebar-bg); padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.completed-tasks { padding: 8px 0; }

/* AI Box */
.ai-box { border-color: var(--accent); }
.ai-box summary { color: var(--accent); }
.ai-add { display: flex; gap: 10px; margin-top: 12px; }
.ai-add input { flex: 1; }
.ai-cleanup { margin-top: 12px; }
#ai-results { margin-top: 12px; }
.sug-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sug-row .old { text-decoration: line-through; color: var(--muted); }
.sug-row .arrow { color: var(--muted); }

/* Tables */
.members { width: 100%; border-collapse: collapse; margin-top: 8px; }
.members th, .members td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.members th { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: 0.4px; }
.members tr:last-child td { border-bottom: none; }

/* Details elements */
details { cursor: pointer; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] { padding-bottom: 12px; }

/* Dialog */
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--white); color: var(--text); padding: 24px; max-width: 480px; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(0,0,0,0.4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
dialog h3 { margin: 0 0 16px; font-size: 18px; font-weight: 600; }

/* Reconcile */
.reconcile-grid { display: grid; gap: 16px; }
.rc-removed { opacity: 0.6; }
.rc-edited { background: #fff4ce; }
.rc-toggled { background: var(--accent-light); }
.box { width: 16px; height: 16px; border: 1.5px solid var(--border); display: inline-block; border-radius: 3px; }
.box.checked { background: #107c10; border-color: #107c10; }

/* Notes */
.notes { font-size: 12px; color: var(--muted); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); z-index: 100; transition: transform 0.3s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-pane { margin-left: 0; padding: 16px; }
  .container { padding: 16px; }
  .row-form { flex-direction: column; }
  .row-form input, .row-form button { width: 100%; }
  .head-actions { flex-wrap: wrap; }
  .login-card { width: 100%; max-width: 360px; margin: 0 16px; }
  .task-actions { opacity: 1; }
}

/* Empty state */
.empty { padding: 32px; text-align: center; color: var(--muted); font-style: italic; }