html.web-runtime,
html.web-runtime body {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 100dvh;
}

html.web-runtime body {
  overflow: hidden;
}

html.web-runtime .title-bar,
html.web-runtime .title-bar-drag {
  -webkit-app-region: no-drag;
  user-select: auto;
}

html.web-runtime .title-bar-controls {
  display: none !important;
}

html.web-runtime .title-bar.topbar .topbar-right {
  padding-right: 12px;
}

html.web-runtime .title-bar.topbar .topbar-left {
  padding-left: 16px;
}

html.web-runtime .app-container,
html.web-runtime .main-content,
html.web-runtime .page,
html.web-runtime .editor-container {
  min-width: 0;
}

html.web-runtime .web-chat-float {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 2600;
  width: min(700px, calc(100vw - 40px));
  height: min(590px, calc(100dvh - 94px));
  min-width: 520px;
  min-height: min(420px, calc(100dvh - 94px));
  max-height: calc(100dvh - 82px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(var(--primary-rgb), 0.24);
  border-radius: 8px;
  background: var(--bg-main);
  box-shadow: 0 18px 55px rgba(22, 42, 32, 0.24);
}

html.web-runtime .web-chat-float[hidden] {
  display: none;
}

html.web-runtime .web-chat-float.is-moving,
html.web-runtime .web-chat-float.is-resizing {
  user-select: none;
}

html.web-runtime .web-chat-float.is-moving .web-chat-float-frame,
html.web-runtime .web-chat-float.is-resizing .web-chat-float-frame {
  pointer-events: none;
}

html.web-runtime .web-chat-float-bar {
  height: 42px;
  padding: 0 6px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 42px;
  border-bottom: 1px solid var(--border-muted);
  background: rgba(var(--bg-elevated-rgb), 0.94);
  cursor: move;
  touch-action: none;
}

html.web-runtime .web-chat-float-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
}

html.web-runtime .web-chat-float-mark {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary);
  color: var(--text-on-primary);
  font-size: 13px;
  font-weight: 700;
}

html.web-runtime .web-chat-float-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: var(--text-on-primary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

html.web-runtime .web-chat-float-badge[hidden] {
  display: none;
}

html.web-runtime .web-chat-float.has-new-message .web-chat-float-mark {
  animation: webChatNoticePulse 0.72s ease-out 1;
}

html.web-runtime #topbar-chat-badge.is-notifying {
  animation: webChatBadgePulse 0.72s ease-out 1;
}

@keyframes webChatNoticePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.42); }
  45% { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 10px transparent; }
}

@keyframes webChatBadgePulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.65); }
  100% { transform: scale(1); }
}

html.web-runtime .web-chat-float-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

html.web-runtime .web-chat-float-controls button {
  width: 32px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

html.web-runtime .web-chat-float-controls button:hover {
  background: rgba(var(--primary-rgb), 0.10);
  color: var(--text-primary);
}

html.web-runtime .web-chat-float-controls [data-web-chat-action="close"]:hover {
  background: var(--danger);
  color: var(--text-on-primary);
}

html.web-runtime .web-chat-float-frame {
  width: 100%;
  min-width: 0;
  flex: 1;
  border: 0;
  background: var(--bg-main);
}

html.web-runtime .web-chat-float.is-minimized {
  height: 42px !important;
  min-height: 42px;
}

html.web-runtime .web-chat-float.is-minimized .web-chat-float-frame,
html.web-runtime .web-chat-float.is-minimized .web-chat-float-resize {
  display: none;
}

html.web-runtime .web-chat-float-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
}

html.web-runtime .web-chat-float-resize::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-right: 2px solid rgba(var(--primary-rgb), 0.42);
  border-bottom: 2px solid rgba(var(--primary-rgb), 0.42);
}

@media (prefers-reduced-motion: reduce) {
  html.web-runtime .web-chat-float.has-new-message .web-chat-float-mark,
  html.web-runtime #topbar-chat-badge.is-notifying {
    animation: none;
  }
}

/* Browser workspaces have enough horizontal room for the full navigation.
   Keep it expanded instead of inheriting the theme's icon-rail hover reveal. */
@media (min-width: 901px) {
  html.web-runtime .app-container {
    --sidebar-width: 220px;
    padding-left: var(--sidebar-width);
  }

  html.web-runtime .app-container > .sidebar,
  html.web-runtime .app-container > .sidebar:hover,
  html.web-runtime .app-container > .sidebar:focus-within {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.08);
    transition: none;
  }

  html.web-runtime .sidebar .logo,
  html.web-runtime .sidebar:hover .logo,
  html.web-runtime .sidebar:focus-within .logo {
    width: 190px;
    margin-inline: auto;
    padding: 0 14px;
    gap: 12px;
    justify-content: flex-start;
    border-radius: 9px;
  }

  html.web-runtime .sidebar .logo-info,
  html.web-runtime .sidebar:hover .logo-info,
  html.web-runtime .sidebar:focus-within .logo-info {
    width: auto;
    opacity: 1;
  }

  html.web-runtime .sidebar .nav-item,
  html.web-runtime .sidebar:hover .nav-item,
  html.web-runtime .sidebar:focus-within .nav-item {
    width: 194px;
  }

  html.web-runtime .sidebar .nav-text,
  html.web-runtime .sidebar:hover .nav-text,
  html.web-runtime .sidebar:focus-within .nav-text {
    opacity: 1;
  }

  html.web-runtime .sidebar .nav-separator,
  html.web-runtime .sidebar:hover .nav-separator,
  html.web-runtime .sidebar:focus-within .nav-separator {
    width: 190px;
  }

  html.web-runtime .sidebar .nav-separator span,
  html.web-runtime .sidebar:hover .nav-separator span,
  html.web-runtime .sidebar:focus-within .nav-separator span {
    opacity: 1;
  }
}

html.web-runtime .login-page .titlebar,
html.web-runtime body.login-page .titlebar,
html.web-runtime .login-titlebar {
  -webkit-app-region: no-drag;
}

/* Keep the desktop login composition compact when the page runs in a browser. */
html.web-runtime body.login-page {
  min-height: 100dvh;
  padding: 0;
  overflow: hidden;
  background: var(--bg-base);
}

html.web-runtime body.login-page > .app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

html.web-runtime body.login-page .window-bar {
  display: none;
}

html.web-runtime body.login-page .container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: clamp(24px, 5vh, 56px) 24px 28px;
  justify-content: flex-start;
}

html.web-runtime body.login-page .brand {
  margin-top: auto;
}

html.web-runtime body.login-page .glass-card,
html.web-runtime body.login-page .brand,
html.web-runtime body.login-page .footer-tip,
html.web-runtime body.login-page .server-panel {
  width: 100%;
}

html.web-runtime body.login-page .footer-tip {
  margin-top: 24px;
  margin-bottom: auto;
  padding-top: 0;
}

@media (max-width: 640px) {
  html.web-runtime body.login-page .container {
    padding: 18px 16px 16px;
  }

  html.web-runtime body.login-page .brand {
    margin-bottom: 12px;
  }

  html.web-runtime body.login-page .footer-tip {
    margin-top: 12px;
    line-height: 1.7;
  }
}

@media (max-height: 520px) {
  html.web-runtime .web-chat-float {
    top: 54px !important;
    right: 8px !important;
    bottom: 8px !important;
    height: auto !important;
    min-height: 0;
    max-height: none;
  }

  html.web-runtime .web-chat-float-resize {
    display: none;
  }
}

@media (max-height: 620px) {
  html.web-runtime body.login-page .container {
    justify-content: flex-start;
    padding-top: 18px;
  }
}

/* Wide browser pages need a shared content line. The Electron window keeps its
   existing fixed three-column layout because these rules are web-only. */
html.web-runtime #page-tools .page-header,
html.web-runtime #page-tools #tools-list {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
}

html.web-runtime #page-tools .page-header h1 {
  font-size: clamp(27px, 1.8vw, 32px);
}

html.web-runtime #tools-list {
  display: block;
  column-count: 3;
  column-gap: 18px;
  column-fill: balance;
}

html.web-runtime #tools-list .tools-category {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  break-inside: avoid;
  break-inside: avoid-column;
  vertical-align: top;
}

html.web-runtime #tools-list .tools-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

html.web-runtime #tools-list .tool-card {
  min-height: 74px;
  padding: 14px 16px;
}

html.web-runtime #tools-list .tool-desc {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* main.css narrows .modal itself below 1200px. In the browser that clips the
   backdrop and shifts every dialog left, so keep the overlay viewport-sized. */
html.web-runtime .modal {
  max-width: none;
}

/* The first creation step uses the extra browser width without turning the
   dialog into a tall stack of full-width controls. */
@media (min-width: 821px) {
  html.web-runtime #create-novel-modal {
    padding: 24px;
    background: rgba(18, 31, 25, 0.42);
    backdrop-filter: blur(10px) saturate(0.82);
    -webkit-backdrop-filter: blur(10px) saturate(0.82);
  }

  html.web-runtime #create-novel-modal .modal-content {
    width: min(880px, calc(100vw - 48px));
    max-width: 880px;
    max-height: min(760px, calc(100dvh - 48px));
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(18, 37, 28, 0.28);
  }

  html.web-runtime #create-novel-modal .modal-header {
    padding: 16px 20px;
    background: rgba(var(--bg-elevated-rgb), 0.72);
  }

  html.web-runtime #create-novel-modal .wizard-steps {
    flex: 0 0 auto;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-muted);
    background: rgba(var(--bg-secondary-rgb), 0.46);
  }

  html.web-runtime #create-novel-modal .modal-body {
    padding: 20px 24px;
  }

  html.web-runtime #create-novel-modal #wizard-page-1.active {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  html.web-runtime #create-novel-modal #wizard-page-1 .form-group {
    min-width: 0;
    margin: 0;
  }

  html.web-runtime #create-novel-modal #wizard-page-1 .form-group:first-child,
  html.web-runtime #create-novel-modal #wizard-page-1 .form-group:last-child {
    grid-column: 1 / -1;
  }

  html.web-runtime #create-novel-modal #wizard-page-1 .form-textarea {
    min-height: 104px;
    height: 104px;
  }

  html.web-runtime #create-novel-modal .modal-footer {
    padding: 14px 20px;
    background: rgba(var(--bg-elevated-rgb), 0.72);
  }

  html.web-runtime #create-novel-modal .modal-footer .btn {
    min-width: 72px;
  }
}

@media (max-width: 1180px) and (min-width: 901px) {
  html.web-runtime #tools-list {
    column-count: 2;
  }
}

@media (max-width: 900px) {
  html.web-runtime #tools-list {
    column-count: 1;
  }
}

html.web-runtime .manga-studio-body,
html.web-runtime .imgst-body,
html.web-runtime .studio-body,
html.web-runtime .wc-body {
  min-height: 100dvh;
}

html.web-runtime .manga-studio,
html.web-runtime .imgst-main,
html.web-runtime .studio-shell,
html.web-runtime .wc-shell {
  min-width: 0;
}

@media (max-width: 900px) {
  html.web-runtime .topbar-theme-switch,
  html.web-runtime .topbar-actions .ta-label {
    display: none;
  }

  html.web-runtime .title-bar.topbar .topbar-center {
    min-width: 0;
  }

  html.web-runtime .topbar-announce {
    max-width: 40vw;
  }

  html.web-runtime .manga-topbar,
  html.web-runtime .studio-topbar {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  html.web-runtime .manga-workflow,
  html.web-runtime .studio-nav {
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  html.web-runtime .web-chat-float {
    inset: 54px 8px 8px !important;
    width: auto !important;
    height: auto !important;
    min-width: 0;
    min-height: 0;
  }

  html.web-runtime .web-chat-float-resize {
    display: none;
  }

  html.web-runtime .title-bar.topbar .topbar-left {
    padding-left: 10px;
  }

  html.web-runtime .topbar-brand {
    max-width: 64px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }

  html.web-runtime .topbar-center {
    display: none;
  }

  html.web-runtime .topbar-actions {
    display: flex;
    gap: 0;
  }

  html.web-runtime .topbar-actions .topbar-action {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
  }

  html.web-runtime .topbar-account {
    padding-inline: 2px;
  }

  html.web-runtime .title-bar.topbar .topbar-right {
    margin-left: auto;
    gap: 2px;
    padding: 0 4px 0 2px;
  }

  html.web-runtime .sidebar {
    flex: 0 0 var(--sidebar-width);
  }

  html.web-runtime .page-header {
    gap: 10px;
  }

  html.web-runtime .page-header-actions {
    max-width: 100%;
    overflow-x: auto;
  }

  html.web-runtime .modal-content {
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  html.web-runtime .manga-studio,
  html.web-runtime .imgst-main,
  html.web-runtime .studio-shell,
  html.web-runtime .wc-shell {
    width: 100%;
  }
}
