:root {
  --v15-fade-width: 30px;
}

html,
body,
#app,
.shell,
.workspace,
.content-column,
.main {
  max-width: 100%;
}

.shell {
  overflow-x: clip;
}

.topbar {
  position: sticky;
  z-index: 90;
  top: 0;
  isolation: isolate;
  box-shadow: 0 5px 22px rgba(4, 40, 72, .22);
}

.content-column {
  min-width: 0;
  min-height: calc(100vh - 67px);
  display: flex;
  flex-direction: column;
}

.content-column .main {
  min-width: 0;
  width: 100%;
  flex: 1 0 auto;
}

.main > *,
.dashboard-page,
#dashboard-result,
#dashboard-result > .stack,
.score-chart-card,
.chart-scroll-shell,
.chart-scroll {
  min-width: 0;
  max-width: 100%;
}

.dashboard-page,
#dashboard-result,
#dashboard-result > .stack {
  width: 100%;
}

.chart-scroll-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 0 0 10px 10px;
}

.chart-scroll-shell::before,
.chart-scroll-shell::after {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 4px;
  width: var(--v15-fade-width);
  opacity: 0;
  pointer-events: none;
  content: "";
  transition: opacity .18s ease;
}

.chart-scroll-shell::before {
  left: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, 0));
}

.chart-scroll-shell::after {
  right: 0;
  background: linear-gradient(270deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, 0));
}

.chart-scroll-shell.can-scroll-left::before,
.chart-scroll-shell.can-scroll-right::after {
  opacity: 1;
}

.chart-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.chart-swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 9px 0 0;
  color: #7c8c9b;
  font-size: 10px;
  line-height: 1.4;
}

.chart-swipe-hint span {
  color: #1682b5;
  font-size: 14px;
}

.formal-edit-modal {
  width: min(760px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.formal-edit-modal *,
.formal-edit-modal #formal-lines,
.formal-edit-modal .detail-block,
.formal-edit-modal .form-grid,
.formal-edit-modal label {
  min-width: 0;
  max-width: 100%;
}

.formal-edit-modal .form-grid {
  grid-template-columns: minmax(0, 1fr);
}

.formal-edit-modal select,
.formal-edit-modal textarea,
.formal-edit-modal input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.formal-edit-modal select {
  text-overflow: ellipsis;
}

.formal-edit-modal textarea,
.formal-edit-modal .sub,
.formal-edit-modal .detail-block {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.formal-edit-modal textarea {
  white-space: pre-wrap;
  resize: vertical;
}

.system-status-footer {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px clamp(16px, 3vw, 38px);
  border-top: 1px solid #dce6ed;
  background: rgba(244, 248, 251, .96);
  color: #6e7f8f;
  font-size: 10px;
  line-height: 1.55;
}

.system-status-footer > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.runtime-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #49657b;
  white-space: nowrap;
}

.runtime-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #19a585;
  box-shadow: 0 0 0 3px rgba(25, 165, 133, .12);
}

@media (max-width: 760px) {
  :root {
    --v15-fade-width: 24px;
  }

  .shell {
    width: 100%;
  }

  .topbar {
    top: 0;
  }

  .content-column {
    width: 100%;
    min-height: calc(100dvh - 62px - env(safe-area-inset-top));
  }

  .main {
    overflow-x: clip;
  }

  .dashboard-page .page-head,
  .dashboard-page .mobile-cycle-card,
  .dashboard-page .metric-grid,
  .dashboard-page .score-chart-card {
    width: 100%;
    max-width: 100%;
  }

  .dashboard-page .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-page .metric {
    min-width: 0;
  }

  .score-chart-card .chart-heading {
    min-width: 0;
    flex-direction: column;
  }

  .score-chart-card .chart-heading > div,
  .score-chart-card .chart-controls,
  .score-chart-card .score-mode-switch {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .score-chart-card .chart-controls {
    align-items: stretch;
  }

  .score-chart-card .chart-controls > .pill {
    width: fit-content;
  }

  .chart-scroll {
    margin: 0;
    padding-bottom: 5px;
  }

  .formal-edit-modal {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .formal-edit-modal .detail-block {
    width: 100%;
    overflow: hidden;
  }

  .system-status-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    font-size: 10px;
  }

  .runtime-line {
    white-space: normal;
  }
}

@media (max-width: 390px) {
  .dashboard-page .metric {
    min-height: 100px;
    padding: 13px;
  }

  .dashboard-page .metric strong {
    font-size: 22px;
  }
}
