.page-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100vh;
  gap: 1.5rem;
  width: min(960px, 100%);
  max-width: 100%;
  margin: 0 auto;
}

.app-shell {
  width: 100%;
  max-width: 960px;
  background: var(--bg-panel);
  border-radius: 28px;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  backdrop-filter: blur(18px);
  box-shadow: 0 25px 60px -24px rgba(14, 20, 40, 0.8);
  color: inherit;
}

.app-header {
  padding: clamp(1.5rem, 3vw + 1rem, 3rem);
  background: linear-gradient(125deg, rgba(79, 123, 255, 0.82), rgba(130, 89, 255, 0.78));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
}

.app-header p {
  color: rgba(247, 249, 255, 0.92);
  font-size: clamp(1rem, 2.3vw, 1.2rem);
  line-height: 1.45;
}

.app-content {
  display: grid;
  gap: clamp(1.5rem, 2vw, 2rem);
  padding: clamp(0.9rem, 3vw, 2.5rem);
}

@media (min-width: 860px) {
  .app-content {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-meta {
  display: grid;
  gap: 0.75rem;
}

.control-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.toolbar-button {
  flex: 1 1 min(180px, 100%);
  min-width: min(180px, 100%);
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(122, 140, 255, 0.35);
  background: rgba(9, 13, 28, 0.65);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.toolbar-button.is-primary {
  background: linear-gradient(135deg, rgba(96, 132, 255, 0.85), rgba(160, 92, 255, 0.75));
  border-color: rgba(170, 190, 255, 0.55);
  box-shadow: 0 12px 28px -18px rgba(116, 142, 255, 0.65);
}

.toolbar-button:hover,
.toolbar-button:focus-visible {
background: rgba(30, 40, 80, 0.85);  
  border-color: rgba(170, 190, 255, 0.5);
  color: #fff;
}

.toolbar-button.is-primary:hover,
.toolbar-button.is-primary:focus-visible {
  background: linear-gradient(135deg, rgba(116, 150, 255, 0.95), rgba(178, 110, 255, 0.85));
}

.toolbar-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.action-message {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.slider-group {
  display: grid;
  gap: 1.1rem;
}

.control-options {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid rgba(122, 140, 255, 0.35);
}

.slider-control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-subtle);
}

.slider-control .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.slider-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(122, 140, 255, 0.25);
  outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(88, 125, 255, 0.45);
  cursor: pointer;
}

.slider-control input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(88, 125, 255, 0.45);
  cursor: pointer;
}

.checkbox-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: rgba(20, 29, 60, 0.65);
  border: 1px solid rgba(88, 125, 255, 0.25);
  color: var(--text-subtle);
  font-weight: 600;
}

.checkbox-control input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}

.tab-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: rgba(12, 18, 38, 0.72);
  border: 1px solid rgba(88, 125, 255, 0.25);
}

.tab {
  flex: 1 1 min(180px, 100%);
  min-width: min(180px, 100%);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: rgba(122, 140, 255, 0.12);
  color: var(--text-subtle);
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-align: center;
}

.tab:hover,
.tab:focus-visible {
  background: rgba(122, 140, 255, 0.22);
  color: #fff;
}

.tab.is-active {
  background: linear-gradient(135deg, rgba(96, 132, 255, 0.85), rgba(160, 92, 255, 0.75));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 26px -18px rgba(116, 142, 255, 0.65);
}

.advanced-toggle {
  align-self: flex-start;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(122, 140, 255, 0.4);
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.advanced-toggle:hover,
.advanced-toggle:focus-visible {
  background: rgba(122, 140, 255, 0.14);
  color: #fff;
}

.advanced-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 18px;
  background: rgba(20, 29, 60, 0.8);
  border: 1px solid rgba(88, 125, 255, 0.35);
}

.select-control {
  display: grid;
  overflow: hidden;
  gap: 0.65rem;
  padding: 1.1rem 1.25rem;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid rgba(122, 140, 255, 0.35);
  color: var(--text-subtle);
  font-weight: 600;
}

.select-control label {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.select-control select,
.select-control__field {
  padding: 0.75rem 1rem;
  max-width: 98%;
  border-radius: 14px;
  border: 1px solid rgba(170, 190, 255, 0.45);
  background: linear-gradient(135deg, rgba(24, 32, 62, 0.95), rgba(14, 22, 44, 0.9));
  color: #fff;
  box-shadow: 0 16px 34px -24px rgba(12, 18, 38, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-control select:focus-visible,
.select-control__field:focus-visible {
  border-color: rgba(170, 190, 255, 0.75);
  box-shadow: 0 18px 40px -24px rgba(122, 140, 255, 0.6);
}

.select-control select:disabled,
.select-control__field:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

 .select-control__field option {
background: darkblue;
}

.summary-panel {
  display: grid;
  gap: 1.2rem;
}

.summary-card {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 22px;
  background: var(--bg-surface);
  border: 1px solid rgba(88, 125, 255, 0.35);
}

.summary-card h2 {
  font-size: 1.4rem;
}

.summary-subtitle {
  margin: 0;
  color: var(--text-subtle);
  font-weight: 600;
}

.metrics {
  display: grid;
  gap: 0.85rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.metric .label {
  color: var(--text-subtle);
  font-weight: 600;
}

.metric .value {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: right;
}

.timeline-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 1rem;
}

.site-footer {
  width: 100%;
  max-width: 960px;
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.95rem;
  margin-top: auto;
}

.site-footer__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.site-footer__link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.site-footer__link:hover,
.site-footer__link:focus-visible {
  color: #fff;
  border-color: rgba(170, 190, 255, 0.6);
}

.share-button {
  flex: 0 0 auto;
  min-width: 0;
  margin-top: -0.3rem;
}

.save-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding-top: 0.75rem;
}

.save-footer .toolbar-button {
  flex: 0 1 auto;
  min-width: min(220px, 100%);
}

.timeline-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  width: 100%;
}

.timeline-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(88, 125, 255, 0.25);
  background: rgba(16, 24, 48, 0.8);
  display: grid;
  gap: 0.5rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
  min-width: 0;
  word-break: break-word;
}

.timeline-card.is-optimal {
  border-color: var(--success);
  box-shadow: 0 8px 20px -14px var(--success);
  transform: translateY(-4px);
}

.timeline-card .hour {
  font-weight: 600;
  color: #fff;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.timeline-card .detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-subtle);
}

.timeline-card .detail-label {
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
}

.timeline-card .detail-value {
  font-weight: 600;
  color: #fff;
  text-align: right;
  justify-self: end;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 430px) {
  .timeline-card .detail-row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.25rem;
  }

  .timeline-card .detail-value {
    justify-self: start;
    text-align: left;
  }
}

.timeline-card .detail-value.is-muted {
  color: rgba(198, 206, 236, 0.75);
  font-weight: 500;
}

.placeholder {
  color: var(--text-subtle);
  font-size: 1.1rem;
  line-height: 1.5;
}

.error {
  color: #ff9393;
  font-weight: 600;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(122, 140, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 40;
}

.dialog-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 1rem;
  padding: 1.75rem;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid rgba(122, 140, 255, 0.35);
  box-shadow: 0 24px 60px -28px rgba(12, 18, 38, 0.9);
}

.dialog-panel h3 {
  margin: 0;
  font-size: 1.35rem;
}

.dialog-panel p {
  margin: 0;
  color: var(--text-subtle);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.dialog-button {
  padding: 0.6rem 1.4rem;
  border-radius: 12px;
  border: 1px solid rgba(170, 190, 255, 0.45);
  background: linear-gradient(135deg, rgba(96, 132, 255, 0.88), rgba(160, 92, 255, 0.78));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.dialog-button:hover,
.dialog-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -18px rgba(116, 142, 255, 0.7);
}

.dialog-button:focus-visible {
  outline: none;
  border-color: rgba(198, 210, 255, 0.8);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 599px) {
  .summary-card {
    padding: 1.25rem;
  }

  .slider-control {
    padding: 1rem;
  }

  .timeline-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
