:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --accent: #2563eb;
  --ok: #16a34a;
  --error: #dc2626;
  --warn: #d97706;
  --border: #e5e7eb;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header h1 { margin: 0; font-size: 20px; }

.sync-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-info.error { color: var(--error); }
.sync-info.ok { color: var(--ok); }

.inline-form { display: inline; }
.inline-form button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}
.inline-form button:hover { background: var(--bg); }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex-shrink: 0;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tab.active {
  background: #eef2ff;
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.tab .count {
  opacity: 0.7;
  font-size: 11px;
  margin-left: 2px;
}

main {
  max-width: 720px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar a { color: var(--accent); text-decoration: none; }
.toolbar a:hover { text-decoration: underline; }
.ics-link { margin-left: auto; }

.empty { color: var(--muted); text-align: center; margin-top: 48px; }

.items { list-style: none; padding: 0; margin: 0; }

.item {
  display: flex;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.item.due-overdue { border-left-color: var(--error); }
.item.due-today { border-left-color: var(--warn); }
.item.due-soon { border-left-color: #f59e0b; }

.item.done { opacity: 0.5; }
.item.done .item-text,
.item.done .item-text-details summary { text-decoration: line-through; }

.check-form { margin: 0; flex-shrink: 0; }

.checkbox {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  color: var(--ok);
  font-weight: bold;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.checkbox:hover { border-color: var(--accent); }

.item-body { flex: 1; min-width: 0; }

.item-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.badge {
  background: #eef2ff;
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
  font-size: 11px;
}

.cat-badge-homework { background: #ecfdf5; color: #059669; }
.cat-badge-exam { background: #fef2f2; color: #dc2626; }
.cat-badge-payment { background: #fffbeb; color: #d97706; }
.cat-badge-event { background: #f5f3ff; color: #7c3aed; }
.cat-badge-grade { background: #eff6ff; color: #2563eb; }
.cat-badge-announcement { background: #f3f4f6; color: #4b5563; }

.due-badge {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
}
.due-badge.due-overdue { background: #fef2f2; color: var(--error); }
.due-badge.due-today { background: #fffbeb; color: var(--warn); }
.due-badge.due-soon { background: #fff7ed; color: #ea580c; }

.item-text {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-text-details summary {
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  color: var(--text);
  list-style: none;
}
.item-text-details summary::-webkit-details-marker { display: none; }
.item-text-details summary::after {
  content: " ▾ zobraziť viac";
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.item-text-details[open] summary::after {
  content: " ▴ zobraziť menej";
}
.item-text-full {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
}

@media (max-width: 480px) {
  header { padding: 12px 14px; }
  header h1 { font-size: 18px; }
  main { padding: 0 10px 32px; margin-top: 14px; }
  .item { padding: 10px 12px; }
}
