:root {
  color-scheme: light;
  --web-safe-top: env(safe-area-inset-top, 0px);
  --web-safe-right: env(safe-area-inset-right, 0px);
  --web-safe-bottom: env(safe-area-inset-bottom, 0px);
  --web-safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  min-height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

.app-shell {
  box-sizing: border-box;
  min-height: 100dvh;
  padding-top: var(--web-safe-top);
  padding-right: var(--web-safe-right);
  padding-bottom: var(--web-safe-bottom);
  padding-left: var(--web-safe-left);
}

button,
[role="button"],
a {
  touch-action: manipulation;
}

:where(button, input, select, textarea, a):focus-visible {
  outline: 3px solid color-mix(in srgb, #0b6b57 72%, white);
  outline-offset: 2px;
}

#modelSettingsModal,
#openModelSettingsButton,
#balanceSettingsButton,
#openTokenGuideButton {
  display: none !important;
}

.web-auth-gate {
  position: fixed;
  z-index: 20000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(24px, var(--web-safe-top)) max(18px, var(--web-safe-right)) max(24px, var(--web-safe-bottom)) max(18px, var(--web-safe-left));
  background:
    radial-gradient(circle at 18% 16%, rgba(120, 216, 183, 0.3), transparent 36%),
    radial-gradient(circle at 84% 88%, rgba(97, 164, 232, 0.2), transparent 34%),
    linear-gradient(145deg, #effaf6 0%, #f7fbff 48%, #eaf6f2 100%);
}

.web-auth-gate[hidden],
.web-auth-form[hidden],
.web-auth-tabs[hidden] {
  display: none !important;
}

.web-auth-card {
  width: min(440px, 100%);
  box-sizing: border-box;
  padding: 28px;
  border: 1px solid rgba(11, 107, 87, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 80px rgba(18, 68, 56, 0.2);
  color: #173f35;
  backdrop-filter: blur(18px);
}

.web-auth-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 22px;
}

.web-auth-brand img {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(11, 107, 87, 0.16);
}

.web-auth-brand h1 {
  margin: 0 0 4px;
  color: #0d4639;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.2;
}

.web-auth-brand p,
.web-auth-note {
  margin: 0;
  color: #5c756e;
  font-size: 13px;
  line-height: 1.55;
}

.web-auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border-radius: 13px;
  background: #edf6f3;
}

.web-auth-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #587069;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.web-auth-tabs button.active {
  background: #fff;
  color: #0b6b57;
  box-shadow: 0 4px 14px rgba(15, 83, 68, 0.12);
}

.web-auth-form {
  display: grid;
  gap: 14px;
}

.web-auth-form label {
  display: grid;
  gap: 7px;
  color: #294f46;
  font-size: 13px;
  font-weight: 700;
}

.web-auth-form input {
  width: 100%;
  min-height: 46px;
  box-sizing: border-box;
  border: 1px solid #bdd4cd;
  border-radius: 12px;
  padding: 10px 13px;
  background: #fbfefd;
  color: #173f35;
  font: inherit;
  font-size: 16px;
}

.web-auth-form input:focus {
  border-color: #0b8068;
  box-shadow: 0 0 0 4px rgba(11, 128, 104, 0.12);
  outline: 0;
}

.web-auth-primary {
  min-height: 48px;
  margin-top: 2px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #0b8068, #075c4b);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(11, 107, 87, 0.2);
}

.web-auth-primary:hover {
  filter: brightness(1.04);
}

.web-auth-status {
  min-height: 21px;
  margin: 14px 0 8px;
  color: #a3442d;
  font-size: 13px;
  line-height: 1.55;
}

.web-toolbar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 0 auto;
  padding: 5px;
  border: 1px solid rgba(11, 107, 87, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 9px 28px rgba(14, 61, 51, 0.14);
  color: #214b41;
  backdrop-filter: blur(12px);
}

.web-toolbar-user {
  min-width: 0;
  overflow: hidden;
  padding: 0 5px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.web-toolbar button {
  min-height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(11, 107, 87, 0.18);
  border-radius: 9px;
  padding: 6px 10px;
  background: #eff8f5;
  color: #0d5b49;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.topbar:has(#dayimiaoWebToolbar) {
  align-items: flex-start;
}

.topbar:has(#dayimiaoWebToolbar) > .topbar-title {
  flex: 1 1 auto;
  min-width: 0;
}

.web-toolbar button:last-child {
  border-color: rgba(180, 72, 61, 0.22);
  background: #fff7f5;
  color: #a04439;
}

.web-toolbar button:last-child:hover {
  background: #ffebe7;
}

.web-toolbar button:hover {
  background: #e2f3ed;
}

.web-runtime-banner,
.web-offline-banner,
.web-download-toast {
  position: fixed;
  z-index: 10050;
  right: max(16px, var(--web-safe-right));
  bottom: max(16px, var(--web-safe-bottom));
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(11, 107, 87, 0.22);
  border-radius: 14px;
  background: rgba(247, 255, 252, 0.96);
  box-shadow: 0 14px 40px rgba(12, 49, 41, 0.18);
  color: #173f35;
  font-size: 14px;
  line-height: 1.5;
  backdrop-filter: blur(12px);
}

.web-offline-banner[data-state="online"],
.web-runtime-banner[hidden],
.web-download-toast[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .web-auth-gate {
    place-items: start center;
    padding-top: max(14px, var(--web-safe-top));
    padding-bottom: max(14px, var(--web-safe-bottom));
  }

  .web-auth-card {
    margin: auto 0;
    padding: 21px 18px;
    border-radius: 20px;
  }

  .web-auth-brand {
    gap: 12px;
    margin-bottom: 17px;
  }

  .web-auth-brand img {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .web-toolbar {
    width: 100%;
    max-width: none;
    margin-top: 2px;
    justify-content: stretch;
    box-sizing: border-box;
  }

  .web-toolbar-user {
    flex: 1 1 auto;
  }

  .topbar:has(#dayimiaoWebToolbar) {
    flex-wrap: wrap;
  }

  .topbar:has(#dayimiaoWebToolbar) > .topbar-title {
    flex-basis: 100%;
  }

  .web-toolbar button {
    flex: 1 1 auto;
  }

  .web-runtime-banner,
  .web-offline-banner,
  .web-download-toast {
    right: max(10px, var(--web-safe-right));
    bottom: max(10px, var(--web-safe-bottom));
    left: max(10px, var(--web-safe-left));
    max-width: none;
  }

}

@media (display-mode: standalone) {
  body {
    user-select: none;
  }

  :where(input, textarea, [contenteditable="true"], .message-content) {
    user-select: text;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
