/* Bandwidth mode: a deliberate spatial portrait of weekly attention. */
.bandwidth-section {
  --bandwidth-accent: #9fdcff;
  position: fixed;
  inset: 0;
  z-index: 9850;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) clamp(104px, 14vh, 132px);
  gap: clamp(10px, 1.4vh, 14px);
  box-sizing: border-box;
  padding: clamp(16px, 3.2vh, 32px) clamp(20px, 4.8vw, 72px) clamp(12px, 2vh, 20px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.025);
  transition: opacity 0.45s ease, visibility 0.45s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

body.bandwidth-mode-active .bandwidth-section {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

body.bandwidth-mode-active #desktopToolsDock { z-index: 9870 !important; }

body.bandwidth-mode-active .app-wrapper,
body.bandwidth-mode-active #topHeaderZone,
body.bandwidth-mode-active #focusModeTrigger,
body.bandwidth-mode-active #macroFilterTrigger,
body.bandwidth-mode-active .scroll-hint-capsule,
body.bandwidth-mode-active #ef-sys-wrap {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.bandwidth-mode-active #ambientCanvas { opacity: 0.2 !important; }

.bandwidth-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  min-height: 68px;
  pointer-events: none;
}

.bandwidth-heading-wrap { min-width: 0; }
.bandwidth-kicker,
.bandwidth-calibration-label,
.bandwidth-tray-heading,
.bandwidth-card-medium {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.bandwidth-kicker {
  margin-bottom: 3px;
  color: color-mix(in srgb, var(--bandwidth-accent) 72%, rgba(255,255,255,0.45));
  font-size: 9px;
}

.bandwidth-title {
  margin: 0;
  color: var(--bandwidth-accent);
  font-family: 'Caveat', cursive;
  font-size: clamp(38px, min(4.6vw, 6.5vh), 58px);
  font-weight: 700;
  line-height: 0.86;
}

.bandwidth-summary {
  margin: 7px 0 0;
  color: rgba(255,255,255,0.72);
  font-family: 'Neuton', serif;
  font-size: 17px;
  line-height: 1;
}

.bandwidth-summary.is-near { color: #ffe8a8; }
.bandwidth-summary.is-over { color: #ff9e9e; }

.bandwidth-calibration {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: color-mix(in srgb, rgb(var(--circadian-dark, 5,5,8)) 86%, transparent);
  pointer-events: auto;
}

.bandwidth-calibration-label { margin-right: 5px; color: rgba(255,255,255,0.44); font-size: 8px; }
.bandwidth-calibration label { display: flex; align-items: center; gap: 4px; color: rgba(255,255,255,0.65); font-family: 'Noto Sans JP', sans-serif; font-size: 9px; }
.bandwidth-calibration input {
  width: 40px;
  padding: 3px 2px;
  border: 0;
  border-bottom: 1px solid rgba(159,220,255,0.4);
  outline: 0;
  background: transparent;
  color: #fff;
  font: 900 11px 'Noto Sans JP', sans-serif;
  text-align: center;
  user-select: auto;
}
.bandwidth-calibration input:focus { border-color: var(--bandwidth-accent); }
.bandwidth-calibration input::-webkit-inner-spin-button { display: none; }
.bandwidth-calibration-divider { color: rgba(255,255,255,0.22); }

.bandwidth-canvas {
  position: relative;
  min-height: 230px;
  overflow: hidden;
  border-radius: 30px;
  touch-action: none;
  isolation: isolate;
}

.bandwidth-boundary {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(159,220,255,0.24);
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 45%, rgba(159,220,255,0.055), transparent 58%),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: auto, 8.333% 100%, 100% 16.666%;
  box-shadow: inset 0 0 70px rgba(0,0,0,0.28);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.bandwidth-canvas.is-near .bandwidth-boundary { border-color: rgba(255,220,130,0.42); }
.bandwidth-canvas.is-over .bandwidth-boundary {
  border-color: rgba(255,110,110,0.72);
  box-shadow: inset 0 0 80px rgba(255,50,50,0.09);
}
.bandwidth-canvas.is-drop-target .bandwidth-boundary {
  border-color: var(--bandwidth-accent);
  box-shadow: inset 0 0 90px rgba(159,220,255,0.12);
}

.bandwidth-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: rgba(255,255,255,0.38);
  font-family: 'Neuton', serif;
  font-size: clamp(24px, 3vw, 38px);
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.bandwidth-empty small { font: 900 8px 'Noto Sans JP', sans-serif; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255,255,255,0.25); }
.bandwidth-empty.is-hidden { opacity: 0; }
.bandwidth-cards { position: absolute; inset: 0; }
.bandwidth-help { position: absolute; right: 20px; bottom: 13px; z-index: 80; color: rgba(255,255,255,0.25); font: 900 8px 'Noto Sans JP', sans-serif; letter-spacing: 0.09em; text-transform: uppercase; pointer-events: none; }

.bandwidth-card {
  --project-accent: #fff;
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--project-accent) 68%, rgba(255,255,255,0.2));
  border-radius: clamp(14px, 1.7vw, 24px);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--project-accent) 24%, rgba(12,10,18,0.94)), rgba(3,3,7,0.94));
  color: #fff;
  cursor: grab;
  touch-action: none;
  contain: layout paint style;
  box-shadow: inset 0 0 35px color-mix(in srgb, var(--project-accent) 10%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.25s ease, opacity 0.2s ease;
}
.bandwidth-card:hover,
.bandwidth-card:focus-visible {
  border-color: color-mix(in srgb, var(--project-accent) 85%, #fff);
  outline: none;
}
.bandwidth-card.is-moving,
.bandwidth-card.is-resizing { cursor: grabbing; transition: none; z-index: 50 !important; }
.bandwidth-card.is-snapped {
  border-color: color-mix(in srgb, var(--project-accent) 92%, #fff);
  box-shadow: inset 0 0 45px color-mix(in srgb, var(--project-accent) 22%, transparent), 0 0 0 2px color-mix(in srgb, var(--project-accent) 26%, transparent), 0 0 28px color-mix(in srgb, var(--project-accent) 30%, transparent);
}
.bandwidth-card.is-reflowing {
  z-index: 35 !important;
  transition: left 0.28s cubic-bezier(0.16, 1.35, 0.3, 1), top 0.28s cubic-bezier(0.16, 1.35, 0.3, 1), width 0.28s cubic-bezier(0.16, 1.35, 0.3, 1), height 0.28s cubic-bezier(0.16, 1.35, 0.3, 1), box-shadow 0.2s ease;
  box-shadow: inset 0 0 42px color-mix(in srgb, var(--project-accent) 20%, transparent), 0 0 24px color-mix(in srgb, var(--project-accent) 22%, transparent);
}
.bandwidth-card.is-overlapping {
  box-shadow: inset 0 0 45px color-mix(in srgb, var(--project-accent) 17%, transparent), 0 0 22px color-mix(in srgb, var(--project-accent) 18%, transparent);
  border-style: double;
}

.bandwidth-card-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  padding: clamp(13px, 1.7vw, 24px);
  pointer-events: none;
}
.bandwidth-card-copy { min-width: 0; }
.bandwidth-card-medium { overflow: hidden; margin-bottom: 6px; color: color-mix(in srgb, var(--project-accent) 72%, #fff); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.bandwidth-card-title { overflow: hidden; margin: 0; font: 700 clamp(17px, 2vw, 28px)/1.05 'Neuton', serif; text-overflow: ellipsis; }
.bandwidth-project-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  margin-top: clamp(9px, 1.1vw, 14px);
  color: rgba(255,255,255,0.56);
  font: 900 7px 'Noto Sans JP', sans-serif;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.bandwidth-project-progress strong { color: var(--project-accent); font-size: 10px; letter-spacing: 0.03em; }
.bandwidth-project-progress i {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--project-accent) 35%, transparent);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.bandwidth-project-progress b { display: block; height: 100%; border-radius: inherit; background: var(--project-accent); box-shadow: 0 0 10px color-mix(in srgb, var(--project-accent) 60%, transparent); }
.bandwidth-card-metrics { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 9px; font-family: 'Noto Sans JP', sans-serif; }
.bandwidth-percent { color: var(--project-accent); font-size: clamp(16px, 2.2vw, 30px); font-weight: 900; }
.bandwidth-time { color: rgba(255,255,255,0.66); font-size: 9px; font-weight: 700; letter-spacing: 0.05em; white-space: nowrap; }
.bandwidth-card.is-compact .bandwidth-card-medium,
.bandwidth-card.is-compact .bandwidth-days { display: none; }
.bandwidth-card.is-compact .bandwidth-project-progress { margin-top: 6px; }
.bandwidth-card.is-tiny .bandwidth-hours,
.bandwidth-card.is-tiny .bandwidth-card-medium,
.bandwidth-card.is-tiny .bandwidth-project-progress span { display: none; }
.bandwidth-card.is-tiny .bandwidth-project-progress { margin-top: 5px; }

.bandwidth-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--project-accent) 55%, rgba(255,255,255,0.25));
  border-radius: 50%;
  background: rgba(5,5,9,0.68);
  color: rgba(255,255,255,0.72);
  font: 700 15px/1 sans-serif;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.bandwidth-remove:hover,
.bandwidth-remove:focus-visible { opacity: 1; background: var(--project-accent); color: #050508; outline: none; }

.bandwidth-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: 32px;
  height: 32px;
  cursor: nwse-resize;
  pointer-events: auto;
  border: 0;
  background: transparent;
  padding: 0;
}
.bandwidth-resize-handle::after {
  content: '';
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--project-accent);
  border-bottom: 2px solid var(--project-accent);
  border-radius: 1px;
}

.bandwidth-tray-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 3px 3px 0;
  isolation: isolate;
}
.bandwidth-tray-wrap::before,
.bandwidth-tray-wrap::after {
  content: '';
  position: absolute;
  z-index: 3;
  top: 24px;
  bottom: 6px;
  width: clamp(24px, 4vw, 64px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.bandwidth-tray-wrap::before { left: 0; background: linear-gradient(90deg, rgb(var(--circadian-dark, 5,5,8)), transparent); }
.bandwidth-tray-wrap::after { right: 0; background: linear-gradient(270deg, rgb(var(--circadian-dark, 5,5,8)), transparent); }
.bandwidth-tray-wrap.can-scroll-left::before,
.bandwidth-tray-wrap.can-scroll-right::after { opacity: 0.94; }
.bandwidth-tray-heading { display: flex; align-items: center; justify-content: space-between; min-height: 20px; margin-bottom: 5px; color: rgba(255,255,255,0.42); font-size: 8px; }
.bandwidth-tray-heading small { color: rgba(255,255,255,0.25); font: 700 8px 'Noto Sans JP', sans-serif; letter-spacing: 0.08em; }
.bandwidth-tray-controls { display: flex; align-items: center; gap: 7px; }
.bandwidth-tray-nav {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  padding: 0 0 2px;
  border: 1px solid rgba(159,220,255,0.2);
  border-radius: 50%;
  background: rgba(5,5,9,0.42);
  color: rgba(159,220,255,0.72);
  font: 400 18px/1 'Neuton', serif;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.bandwidth-tray-nav:hover,
.bandwidth-tray-nav:focus-visible { border-color: rgba(159,220,255,0.58); background: rgba(159,220,255,0.12); color: #fff; outline: none; }
.bandwidth-tray-nav:disabled { opacity: 0.2; cursor: default; }
.bandwidth-tray {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 7px 9px;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  height: calc(100% - 25px);
  padding: 1px 5px 7px;
  box-sizing: border-box;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(159,220,255,0.24) transparent;
}
.bandwidth-tray:focus-visible { outline: 1px solid rgba(159,220,255,0.2); outline-offset: 3px; border-radius: 12px; }
.bandwidth-tray::-webkit-scrollbar { height: 5px; }
.bandwidth-tray::-webkit-scrollbar-thumb { border-radius: 99px; background: rgba(159,220,255,0.24); }
.bandwidth-capsule {
  --project-accent: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  max-width: min(330px, 48vw);
  padding: 9px 16px;
  border: 1px solid color-mix(in srgb, var(--project-accent) 58%, rgba(255,255,255,0.22));
  border-radius: 999px;
  background: color-mix(in srgb, var(--project-accent) 12%, rgba(5,5,9,0.72));
  color: color-mix(in srgb, var(--project-accent) 82%, #fff);
  font: 900 9px 'Noto Sans JP', sans-serif;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: grab;
  scroll-snap-align: start;
  touch-action: none;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.bandwidth-capsule > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bandwidth-capsule-meta {
  flex: 0 0 auto;
  padding-left: 8px;
  border-left: 1px solid color-mix(in srgb, var(--project-accent) 42%, transparent);
  color: color-mix(in srgb, var(--project-accent) 62%, rgba(255,255,255,0.7));
  font-size: 7px;
  letter-spacing: 0.05em;
  text-transform: none;
  white-space: nowrap;
}
.bandwidth-capsule:hover,
.bandwidth-capsule:focus-visible { background: var(--project-accent); color: #050508; outline: none; transform: translateY(-2px); }
.bandwidth-capsule.is-dragging { opacity: 0.35; }
.bandwidth-tray-empty { align-self: center; color: rgba(255,255,255,0.32); font: italic 15px 'Neuton', serif; }

.bandwidth-drag-ghost {
  position: fixed;
  z-index: 9999;
  max-width: 240px;
  padding: 10px 17px;
  border: 1px solid var(--ghost-accent, #fff);
  border-radius: 999px;
  background: rgba(5,5,9,0.92);
  color: var(--ghost-accent, #fff);
  font: 900 9px 'Noto Sans JP', sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

body.lite-mode .bandwidth-card,
body.lite-mode .bandwidth-calibration,
body.lite-mode .bandwidth-capsule { backdrop-filter: none !important; box-shadow: none !important; }

@media (max-width: 760px) {
  .bandwidth-section { grid-template-rows: auto minmax(230px, 1fr) 104px; gap: 10px; padding: 16px 14px 10px; }
  .bandwidth-header { align-items: flex-start; min-height: 95px; }
  .bandwidth-title { font-size: 40px; }
  .bandwidth-summary { max-width: 53vw; font-size: 14px; line-height: 1.1; }
  .bandwidth-calibration { flex-wrap: wrap; justify-content: flex-end; max-width: 155px; border-radius: 17px; }
  .bandwidth-calibration-label { width: 100%; margin: 0; text-align: right; }
  .bandwidth-canvas { border-radius: 22px; }
  .bandwidth-card-title { font-size: 16px; }
  .bandwidth-card-content { padding: 13px; }
  .bandwidth-remove { opacity: 0.85; }
  .bandwidth-tray-wrap { min-height: 0; }
  .bandwidth-help { display: none; }
}

@media (max-height: 720px) and (min-width: 761px) {
  .bandwidth-section { grid-template-rows: auto minmax(230px, 1fr) 96px; padding-top: 14px; padding-bottom: 10px; }
  .bandwidth-header { min-height: 56px; }
  .bandwidth-title { font-size: 42px; }
  .bandwidth-summary { margin-top: 4px; font-size: 15px; }
  .bandwidth-tray { grid-template-rows: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .bandwidth-section,
  .bandwidth-card,
  .bandwidth-capsule,
  .bandwidth-boundary { transition-duration: 0.01ms !important; }
}
