:root {
  --office: #2e7d32;
  --remote: #1565c0;
  --other: #b26a00;
  --border: #ddd;
  --bg: #f7f7f5;
}

* { box-sizing: border-box; }

/* `hidden` must always win, even over id/class selectors that set `display`
   (e.g. #login-view, .modal, .popover). Without this, those rules out-specify
   the browser default `[hidden] { display: none }` and the element stays shown. */
[hidden] { display: none !important; }

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

header {
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls .spacer { flex: 1; }

select, button, input[type="text"] {
  font: inherit;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

button { cursor: pointer; }
button:hover { background: #f0f0f0; }
button.primary {
  background: #1565c0;
  border-color: #1565c0;
  color: #fff;
}
button.primary:hover { background: #0d4f9e; }

#board {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

.day {
  flex: 1 0 9.5rem;
  max-width: 13rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.day.today { border-color: #1565c0; box-shadow: 0 0 0 2px #1565c033; }
.day.past { opacity: 0.55; }

.day-header {
  padding: 0.5rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.day.today .day-header { background: #e8f1fc; }

.day-header .weekday { font-weight: 600; }
.day-header .date { font-size: 0.8rem; color: #666; }

.section {
  padding: 0.4rem 0.5rem 0.6rem;
  min-height: 4.4rem;
  cursor: pointer;
}

.section + .section { border-top: 1px dashed var(--border); }
.section:hover { background: #f5f9ff; }

.section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 0.3rem;
}

.section[data-section="office"] .section-label { color: var(--office); }
.section[data-section="remote"] .section-label { color: var(--remote); }
.section[data-section="other"] .section-label { color: var(--other); }

.avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.avatar {
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.avatar.me { outline: 2px solid #222; outline-offset: 1px; }

.avatar .badge {
  position: absolute;
  bottom: -0.25rem;
  right: -0.3rem;
  font-size: 0.7rem;
  text-shadow: 0 0 2px #fff;
}

.avatar .comment-mark {
  position: absolute;
  top: -0.45rem;
  right: -0.4rem;
  font-size: 0.75rem;
  filter: drop-shadow(0 0 1px #fff);
}

.avatar .remove {
  position: absolute;
  top: -0.5rem;
  right: -0.45rem;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #444;
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1; /* covers the comment mark while hovering */
}

.avatar .remove:hover { background: #c62828; }
.avatar.me:hover .remove { display: flex; }

.peek {
  position: absolute;
  z-index: 11;
  max-width: 16rem;
  background: #2b2b2b;
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.peek .peek-name { font-weight: 600; }
.peek .peek-comment { margin-top: 0.2rem; color: #e8e8e8; }

.popover {
  position: absolute;
  z-index: 10;
  width: 17rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.popover-title { font-weight: 600; font-size: 0.9rem; }

.popover-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.popover-tags button { font-size: 0.8rem; padding: 0.2rem 0.45rem; }
.popover-tags button.selected {
  border-color: var(--other);
  background: #fff4e0;
}

.popover-actions { display: flex; gap: 0.4rem; }
.popover-actions button { flex: 1; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  width: 22rem;
  max-width: calc(100vw - 2rem);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-title { font-weight: 600; font-size: 1.05rem; }
.modal-hint { font-size: 0.8rem; color: #777; }

.me-editor-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#me-preview {
  width: 3.2rem;
  height: 3.2rem;
  font-size: 1.1rem;
  flex: 0 0 auto;
}

.me-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.me-fields label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.me-fields input[type="text"] { flex: 1; }
.me-fields input[type="color"] {
  width: 3rem;
  height: 2rem;
  padding: 0.1rem;
}

.modal-actions { display: flex; gap: 0.4rem; }
.modal-actions button { flex: 1; }

/* Login */
#login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card { width: 20rem; }
.login-card input[type="text"] { width: 100%; }
.login-error { color: #c62828; font-size: 0.85rem; }

.me-line { color: #555; }
.me-line strong { color: #222; }

/* Admin: manage people */
.admin-card { width: 28rem; }

.admin-add { display: flex; gap: 0.4rem; }
.admin-add input { flex: 1; }

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
}

.admin-list li + li { border-top: 1px solid var(--border); }
.admin-name { font-size: 0.95rem; }
.admin-actions { display: flex; gap: 0.35rem; }
.admin-actions button { font-size: 0.8rem; padding: 0.2rem 0.5rem; }

button.danger { color: #c62828; border-color: #e0a0a0; }
button.danger:hover { background: #fde8e8; }

.token-box {
  background: #fff8e1;
  border: 1px solid #f0d890;
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.85rem;
}

.token-box-label { margin-bottom: 0.4rem; }
.token-row { display: flex; gap: 0.4rem; }
.token-row input { flex: 1; font-family: monospace; }
