:root {
  color-scheme: light;
  font-family: "IBM Plex Sans", "SF Pro Text", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #dfe6ef;
  --accent: #2563eb;
  --pill: #eef2ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #ffffff 0%, var(--bg) 45%, #eef2f7 100%);
  color: var(--ink);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  min-height: 100vh;
}

.sidebar {
  background: #f8fafc;
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  overflow-y: auto;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 18px;
  color: #0f172a;
}

.mini-cal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  margin: 6px 0;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.tag-selected {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.35);
}

.tag-label {
  flex: 1 1 auto;
}

.tag-remove {
  border: 0;
  background: #fee2e2;
  color: #991b1b;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.content {
  padding: 16px 20px 24px 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.week-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.week-header {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  font-size: 13px;
  color: var(--muted);
}

.week-header div {
  padding: 12px 8px;
  border-right: 1px solid var(--line);
  font-weight: 600;
  text-align: center;
}

.week-header div:last-child { border-right: none; }

.grid-body {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
}

.time-col {
  border-right: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  background: #fbfdff;
}

.time-slot {
  height: 48px;
  padding: 6px 6px 0 8px;
  border-bottom: 1px solid var(--line);
}

.day-col {
  position: relative;
  border-right: 1px solid var(--line);
  min-height: 56px;
  background: #fff;
}

.day-col:last-child { border-right: none; }

.day-col .cell {
  height: 48px;
  border-bottom: 1px solid var(--line);
}

.event {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  color: #0f172a;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  border-left: 4px solid rgba(15, 23, 42, 0.25);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.event:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.18);
}

.event strong {
  display: -webkit-box;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event .event-time {
  display: block;
  font-size: 11px;
  color: #0f172a;
  opacity: 0.85;
  margin-top: 2px;
}

.ai-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 20px 18px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-panel h2 {
  margin: 0 0 6px 0;
  font-size: 18px;
  letter-spacing: 0.1px;
}

.ai-panel p {
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

textarea, input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
  margin-bottom: 10px;
  background: #fff;
}

textarea {
  min-height: 110px;
  line-height: 1.4;
}

button {
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: none;
}

.ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 4px;
}

.section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.section strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
}

.section .small {
  display: block;
  margin-bottom: 10px;
  line-height: 1.35;
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.repeat-days {
  margin-bottom: 8px;
}

.day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}

.day-pill input {
  accent-color: #2563eb;
}

@media (max-width: 1200px) {
  .app { grid-template-columns: 220px 1fr; }
  .ai-panel { grid-column: 1 / -1; border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 12px 12px 16px 12px; }
  .week-grid { border-radius: 14px; }
  .ai-panel { padding: 14px; }
  .ai-actions { flex-wrap: wrap; }
  .ai-actions button { flex: 1 1 140px; }
}

@media (max-width: 720px) {
  .topbar h1 { font-size: 18px; }
  .week-grid { overflow-x: auto; }
  .week-header, .grid-body { min-width: 720px; }
  .week-header { font-size: 12px; }
  .grid-body { font-size: 12px; }
  .time-col { font-size: 11px; }
  .event { font-size: 11px; }
  .event .event-time { font-size: 10px; }
}

@media (max-width: 480px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 4px; }
  textarea, input, select { font-size: 13px; }
  button { width: 100%; }
  .ai-actions { gap: 6px; }
  .ai-actions button { flex: 1 1 100%; }
}

@media print {
  body { background: #fff; }
  .sidebar, .ai-panel { display: none !important; }
  .content { padding: 0; }
  .week-grid { box-shadow: none; border: 1px solid #cbd5e1; }
  .topbar { margin-bottom: 6px; }
}
.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.cat-panel {
  margin-top: 8px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#cat-color {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  cursor: pointer;
}

.swatch-selected {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.tag-color {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  margin-right: 6px;
}

.small-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  box-shadow: none;
}

.hidden {
  display: none !important;
}
