:root {
  /* Nike-inspired dark: near-black grounds, off-white ink, neutral grays,
     with a single turquoise accent. */
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --accent: #26d9c7;
  --accent-dim: #1ba99b;
  --accent-ink: #06231f;   /* text on accent */
  --danger: #f2555a;
  --hour-h: 44px;      /* pixels per hour */
  --start-hour: 0;
  --end-hour: 24;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: none; font-size: 18px; line-height: 1; padding: 6px 10px; }
.schedule-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.schedule-controls label { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-state { color: var(--muted); font-size: 12px; min-width: 70px; }
.save-state.dirty { color: #ffcf5c; }

.main { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 300px; flex-shrink: 0; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 12px; display: flex; flex-direction: column; gap: 14px;
}
.panel { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.panel.hint ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }

.category-list { display: flex; flex-direction: column; gap: 6px; }
.category-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.category-item:hover { background: rgba(255,255,255,.05); border-color: var(--border); }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.25); }
.category-item .cat-name { flex: 1; }
.category-item .cat-count { color: var(--muted); font-size: 12px; }

.target-list { display: flex; flex-direction: column; gap: 10px; }
.target-item .target-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.target-item .target-label { display: flex; align-items: center; gap: 6px; }
.target-item .target-nums { color: var(--muted); font-size: 12px; }
.progress { height: 8px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 5px; transition: width .2s; }
.target-item .target-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.target-empty { color: var(--muted); font-size: 12px; }

/* Grid */
.grid-wrap { flex: 1; overflow: auto; padding: 0; }
.grid {
  position: relative;
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(120px, 1fr));
  min-width: 900px;
}
.grid .corner, .grid .day-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel); border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  height: 34px; display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--text);
}
.grid .corner { left: 0; z-index: 6; }

.time-col { border-right: 1px solid var(--border); position: sticky; left: 0; background: var(--bg); z-index: 4; }
.time-slot {
  height: var(--hour-h); position: relative; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px;
}
.time-slot span { position: relative; top: -7px; }

.day-col {
  position: relative; border-right: 1px solid var(--border);
  background: repeating-linear-gradient(
    to bottom,
    transparent, transparent calc(var(--hour-h) - 1px),
    var(--border) calc(var(--hour-h) - 1px), var(--border) var(--hour-h)
  );
}
.day-col.dragover { background-color: rgba(38,217,199,.07); }

.block {
  position: absolute; left: 3px; right: 3px; border-radius: 6px;
  padding: 4px 6px; overflow: hidden; cursor: grab; color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.4); font-size: 12px;
  border: 1px solid rgba(255,255,255,.18); user-select: none;
  touch-action: none;   /* let us drive move/resize on touch instead of scrolling */
}
.block:active { cursor: grabbing; }
.block .b-name { font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block .b-time { font-size: 10px; opacity: .9; margin-top: 2px; }
.block .b-note { position: absolute; top: 3px; right: 4px; font-size: 10px; opacity: .85; }
.block .resize {
  position: absolute; left: 0; right: 0; height: 9px; cursor: ns-resize;
  touch-action: none;
}
.block .resize.top { top: 0; }
.block .resize.bottom { bottom: 0; }
/* Bigger grab targets for fingers */
@media (pointer: coarse) { .block .resize { height: 14px; } }

.block.preview { opacity: .55; pointer-events: none; border-style: dashed; }
.block.copying { outline: 2px dashed #fff; }

/* Buttons & inputs */
button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px;
}
button:hover { background: #242424; border-color: #3a3a3a; }
button.small { padding: 3px 8px; font-size: 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: rgba(255,92,92,.12); }

select, input, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 13px; font-family: inherit;
}
input[type="color"] { padding: 2px; height: 34px; width: 60px; }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.overlay.hidden { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; width: 420px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.modal h3 { margin: 0 0 14px; }
.modal label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.modal label input, .modal label select, .modal label textarea { color: var(--text); }
.modal .row { display: flex; gap: 10px; }
.modal .row label { flex: 1; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.modal-actions .spacer { flex: 1; }

/* Lightweight in-app dialog (replaces native prompt/confirm/alert) */
.dialog { width: 380px; }
.dialog h3 { margin-bottom: 8px; }
.dialog-msg { white-space: pre-wrap; color: var(--text); margin: 0 0 14px; line-height: 1.5; }
.dialog-input { width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Sidebar backdrop (mobile drawer) */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 55; }
.sidebar-backdrop.hidden { display: none; }

/* Mobile: sidebar becomes a slide-in drawer instead of eating the screen */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar h1 { font-size: 15px; }
  .icon-btn { display: inline-flex; }
  .schedule-controls { gap: 6px; }
  .schedule-controls label { font-size: 12px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(84vw, 320px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 60; box-shadow: 2px 0 22px rgba(0,0,0,.55);
  }
  .sidebar.open { transform: translateX(0); }
  .grid { min-width: 640px; }
}

/* On wider screens the drawer bits never apply */
@media (min-width: 761px) {
  .sidebar-backdrop { display: none !important; }
  .sidebar { transform: none !important; }
}
