:root {
  --app-bg: #f5f7f8;
  --panel-bg: #ffffff;
  --line: #d9dee3;
  --text: #182026;
  --muted: #6d7780;
  --accent: #ad8757;
}

html,
body {
  height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--app-bg);
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
  overscroll-behavior: none;
}

.side-panel {
  border-right: 1px solid var(--line);
  background: var(--panel-bg);
  overflow-y: auto;
  padding: 18px;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-block h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.link-button {
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--text);
}

.brand-block p,
.panel-section p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.status-indicator.loading .status-dot {
  background: #f59e0b;
}

.status-indicator.error .status-dot {
  background: #ef4444;
}

.panel-section {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.section-title {
  margin-bottom: 10px;
  color: #27313a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
}

.toggle-button {
  width: 42px;
  height: 34px;
  border: 1px solid #27313a;
  border-radius: 6px;
  background: #fff;
  color: #27313a;
}

.toggle-button.active {
  background: #171519;
  color: #fff;
}

.week-jump {
  margin-top: 14px;
}

.week-jump-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 8px;
}

.control-grid .btn {
  width: 42px;
  height: 36px;
  padding: 0;
}

.calendar-main {
  min-width: 0;
  overflow: hidden;
  padding: 18px;
  overscroll-behavior: contain;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(245, 247, 248, 0.96);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 16px 50px rgba(18, 24, 30, 0.12);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
}

#calendar {
  height: calc(100vh - 36px);
  min-height: 640px;
  background: #fff;
  border: 1px solid var(--line);
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.fc,
.fc-scroller,
.fc-scroller-liquid-absolute {
  overscroll-behavior: contain;
}

.fc .fc-toolbar.fc-header-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(18, 24, 30, 0.08);
}

.fc .fc-toolbar-title {
  color: #202124;
  font-weight: 800;
}

.fc .fc-button-primary {
  border-color: #2b3744;
  background: #2b3744;
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:focus,
.fc .fc-button-primary:active {
  border-color: #171519;
  background: #171519;
}

.fc .fc-button {
  border-radius: 4px;
}

.fc-timeline-slot[data-date*="T07:00:00"] {
  border-left: 4px solid #111 !important;
}

.fc-timeline-slot[data-date*="T18:00:00"] {
  border-right: 4px solid #111 !important;
}

.fc-event.is-hour {
  border-width: 3px;
}

.fc .fc-event {
  border-radius: 0;
  border-width: 0;
  font-weight: 600;
}

.fc .fc-event.ai-conflict {
  z-index: 4;
  outline: 3px solid #ef4444;
  outline-offset: 1px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 12px rgba(239, 68, 68, 0.75);
  animation: conflict-pulse 1.6s ease-in-out infinite;
}

@keyframes conflict-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 8px rgba(239, 68, 68, 0.55);
  }

  50% {
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 18px rgba(239, 68, 68, 0.95);
  }
}

.fc .fc-timeline-slot.fc-non-business,
.fc .fc-timeline-lane.fc-non-business,
.fc .fc-day-sat,
.fc .fc-day-sun {
  background: #e1e4e8;
}

.fc .fc-event.filter-dimmed {
  opacity: 0.28;
}

.fc .fc-event.ai-conflict {
  opacity: 1;
}

.external-list {
  display: grid;
  gap: 8px;
}

.external-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.external-group summary {
  cursor: pointer;
  padding: 9px 10px;
  color: #27313a;
  font-size: 13px;
  font-weight: 700;
  list-style-position: inside;
}

.external-group-list {
  display: grid;
  gap: 8px;
  padding: 0 8px 8px;
}

.external-event {
  cursor: grab;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  font-size: 13px;
}

.external-event:active {
  cursor: grabbing;
}

.external-event.read-only {
  cursor: default;
}

.read-only-mode .fc-event {
  cursor: pointer;
}

.external-event strong {
  display: block;
  line-height: 1.2;
}

.external-event span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.external-event .external-event-hours {
  margin-top: 4px;
  color: #27313a;
  font-weight: 700;
}

.external-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.event-title-field {
  min-height: 74px;
  resize: vertical;
}

#eventActivity[readonly] {
  background: #f8fafc;
  color: var(--muted);
}

.assistant-panel {
  display: grid;
  gap: 8px;
}

.assistant-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfc;
  font-size: 13px;
}

.assistant-item.warning {
  border-left: 4px solid #b45309;
}

.assistant-item.ok {
  border-left: 4px solid var(--accent);
}

.auth-callback-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f4f6f8;
  color: var(--ink);
}

.auth-callback-panel {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
}

.auth-callback-panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.auth-callback-panel p {
  margin: 0;
  color: var(--muted);
}

.auth-callback-panel .auth-error {
  color: #b42318;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #calendar {
    height: 720px;
  }
}
