*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  height: 100%;
  background: #0f1117;
}

body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: transparent;
  color: #e8eaed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.5;
}

@media (orientation: portrait) {
  body::before { background-image: url("/background1.jpg"); }
}

@media (orientation: landscape) {
  body::before { background-image: url("/background2.jpg"); }
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body:not(.is-authenticated) #app {
  display: none !important;
}

body.is-authenticated #login-screen {
  display: none !important;
}

#change-password-screen {
  display: none;
}

body.must-change-password #login-screen {
  display: none !important;
}

body.must-change-password #change-password-screen {
  display: flex !important;
}

body.is-authenticated #app {
  display: flex !important;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  border-bottom: 1px solid #2a2f3a;
  background: #151820;
  flex-shrink: 0;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.6rem 0.5rem;
  border: none;
  background: transparent;
  color: #8b919a;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  border-bottom-color: #e53935;
}

/* Tab-switching state: block interaction, dim inactive tabs, pulse active */
.tab-bar--switching .tab {
  pointer-events: none;
  opacity: 0.35;
}

@keyframes tab-switching-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.tab-bar--switching .tab.active {
  opacity: 1;
  animation: tab-switching-pulse 0.8s ease-in-out infinite;
}

.tab-bar--switching .tab.tab--waiting {
  opacity: 1;
  color: #e8eaed;
}


.tab-panels {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.panel.active {
  display: flex;
}

.scroll-area {
  overflow-y: auto;
  touch-action: pan-y;
  cursor: grab;
}

.scroll-area.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.tab-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: #8b919a;
  border-bottom: 1px solid #2a2f3a;
  flex-shrink: 0;
}

.tab-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.tab-toolbar .reverse {
  margin-left: auto;
}

.tab-loading,
.tab-empty,
.tab-error {
  padding: 1.5rem;
  color: #8b919a;
}

.tab-error {
  color: #ef5350;
}

.tts-btn {
  border: none;
  background: #2a3140;
  color: #e8eaed;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.tts-btn:disabled {
  opacity: 0.5;
}

.status {
  margin: 0;
  min-height: 1.2rem;
  font-size: 0.8rem;
  color: #8b919a;
}

.status.error {
  color: #ef5350;
}

.usage-cost {
  color: #66bb6a;
  font-weight: 600;
  white-space: nowrap;
}
