/* Responsive Web shell. Scoped so the macOS app at / keeps its native layout. */
html.kimflow-web,
html.kimflow-web body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: #070a0f;
}

html.kimflow-web body {
  overscroll-behavior-y: none;
}

html.kimflow-web .auth-screen,
html.kimflow-web .auth-screen * {
  box-sizing: border-box;
}

html.kimflow-web .auth-visual,
html.kimflow-web .auth-card {
  min-width: 0;
  max-width: 100%;
}

html.kimflow-web .auth-visual {
  width: min(720px, 100%);
}

html.kimflow-web .auth-card {
  width: min(440px, 100%);
}

html.kimflow-web .auth-card,
html.kimflow-web .auth-tabs,
html.kimflow-web .auth-card label,
html.kimflow-web .auth-card input,
html.kimflow-web .auth-card button,
html.kimflow-web .auth-card small {
  min-width: 0;
  max-width: 100%;
}

html.kimflow-web .auth-tabs,
html.kimflow-web .auth-card label,
html.kimflow-web .auth-card input,
html.kimflow-web .auth-card > button,
html.kimflow-web .auth-card small {
  width: 100%;
}

html.kimflow-web .auth-card small {
  overflow-wrap: anywhere;
}

html.kimflow-web #authDecryptedLine {
  width: min(620px, 100%);
  max-width: 100%;
  min-height: 1.3em;
  overflow: visible;
  white-space: normal;
  font-size: 0 !important;
  line-height: 1.3;
}

html.kimflow-web #authDecryptedLine > * {
  display: none !important;
}

html.kimflow-web #authDecryptedLine::after {
  content: "Discipline is the edge in every market.";
  display: block;
  color: #a7adb8;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.3;
}

html.kimflow-web .workspace {
  min-width: 0;
}

html.kimflow-web .panel,
html.kimflow-web .topbar,
html.kimflow-web .window-bar {
  max-width: 100%;
}

html.kimflow-web .web-mobile-only {
  display: none;
}

@media (max-width: 1180px) {
  html.kimflow-web body {
    overflow-y: auto;
  }

  html.kimflow-web .shell,
  html.kimflow-web .shell.rail-collapsed {
    display: block;
    min-height: 100vh;
  }

  html.kimflow-web .workspace,
  html.kimflow-web .shell.rail-collapsed .workspace {
    width: 100%;
    min-height: 100vh;
    padding: 12px;
    overflow: visible;
  }

  html.kimflow-web .grid {
    position: static !important;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    min-height: 0 !important;
  }

  html.kimflow-web .grid > [data-module] {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 360px !important;
    margin: 0 !important;
    transform: none !important;
  }

  html.kimflow-web .grid > [data-module="chart"] {
    order: 10;
    min-height: 520px !important;
  }

  html.kimflow-web .grid > [data-module="orderbook"] {
    order: 20;
  }

  html.kimflow-web .grid > [data-module="movers"] {
    order: 30;
  }

  html.kimflow-web .grid > [data-module="watch"] {
    order: 40;
    min-height: 520px !important;
  }

  html.kimflow-web .grid > [data-module="ai"] { order: 50; }
  html.kimflow-web .grid > [data-module="strategy"] { order: 60; }
  html.kimflow-web .grid > [data-module="guruAi"] { order: 70; }
  html.kimflow-web .grid > [data-module="review"] { order: 80; }
  html.kimflow-web .grid > [data-module="marketIntel"] { order: 90; }
  html.kimflow-web .grid > [data-module="heatmap"] { order: 100; }
  html.kimflow-web .grid > [data-module="momIndex"] { order: 110; }

  html.kimflow-web .resize-handle {
    display: none !important;
  }

  html.kimflow-web .panel-body,
  html.kimflow-web .watch-list,
  html.kimflow-web .movers-list,
  html.kimflow-web .orderbook-body {
    max-height: none;
  }

  html.kimflow-web #chart {
    width: 100% !important;
    height: 380px !important;
    min-height: 380px !important;
  }

  html.kimflow-web .rail {
    position: fixed;
    z-index: 120;
    left: 0;
    top: 0;
    bottom: 0;
    width: 76px;
    min-width: 76px;
    padding: 12px 8px;
    border-right: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(7, 10, 15, 0.94);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  html.kimflow-web .workspace {
    padding-left: 88px;
  }

  html.kimflow-web .rail .brand-copy,
  html.kimflow-web .rail .rail-label,
  html.kimflow-web .rail nav button small {
    display: none !important;
  }

  html.kimflow-web .rail .brand {
    justify-content: center;
  }

  html.kimflow-web .rail .kimflow-mark {
    width: 42px;
    height: 42px;
  }

  html.kimflow-web .rail-toggle {
    display: none;
  }

  html.kimflow-web .rail nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  html.kimflow-web .rail nav button {
    display: grid;
    place-items: center;
    width: 56px;
    min-width: 56px;
    height: 52px;
    padding: 0;
  }

  html.kimflow-web .rail-icon {
    margin: 0;
    font-size: 21px;
  }

  html.kimflow-web .topbar {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
  }

  html.kimflow-web .topbar > * {
    min-width: 0;
  }

  html.kimflow-web .topbar .search-wrap,
  html.kimflow-web .topbar form {
    width: 100%;
    min-width: 0;
  }

  html.kimflow-web .index-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  html.kimflow-web .index-card {
    scroll-snap-align: start;
  }

  html.kimflow-web .review-drawer,
  html.kimflow-web .drawer,
  html.kimflow-web .settings-panel,
  html.kimflow-web .admin-panel {
    max-width: min(100vw, 560px);
  }
}

@media (max-width: 760px) {
  html.kimflow-web {
    --web-bottom-nav: 72px;
  }

  html.kimflow-web body {
    padding-bottom: var(--web-bottom-nav);
  }

  html.kimflow-web .workspace,
  html.kimflow-web .shell.rail-collapsed .workspace {
    padding: 8px 8px calc(var(--web-bottom-nav) + 14px);
  }

  html.kimflow-web .rail {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 0;
    height: var(--web-bottom-nav);
    padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    border-right: 0;
  }

  html.kimflow-web .rail-header,
  html.kimflow-web .rail-footer {
    display: none !important;
  }

  html.kimflow-web .rail nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    height: 100%;
  }

  html.kimflow-web .rail nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 54px;
    gap: 2px;
    padding: 4px;
    border-radius: 6px;
  }

  html.kimflow-web .rail .rail-label {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1;
  }

  html.kimflow-web .rail-icon {
    font-size: 18px;
    line-height: 1;
  }

  html.kimflow-web .window-bar {
    display: none;
  }

  html.kimflow-web .topbar {
    position: sticky;
    z-index: 40;
    top: 0;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(7, 10, 15, 0.9);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  html.kimflow-web .topbar-actions,
  html.kimflow-web .topbar-controls {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  html.kimflow-web button,
  html.kimflow-web input,
  html.kimflow-web select {
    min-height: 44px;
  }

  html.kimflow-web .index-strip {
    grid-auto-columns: 78vw;
  }

  html.kimflow-web .grid {
    gap: 10px;
  }

  html.kimflow-web .grid > [data-module] {
    min-height: 420px !important;
    padding: 12px !important;
    border-radius: 8px !important;
  }

  html.kimflow-web .grid > [data-module="chart"] {
    min-height: 500px !important;
  }

  html.kimflow-web #chart {
    height: 330px !important;
    min-height: 330px !important;
  }

  html.kimflow-web .panel-head {
    align-items: flex-start;
    gap: 8px;
  }

  html.kimflow-web .panel-head > div:last-child {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  html.kimflow-web .modal,
  html.kimflow-web .dialog,
  html.kimflow-web .review-drawer,
  html.kimflow-web .drawer,
  html.kimflow-web .settings-panel,
  html.kimflow-web .admin-panel {
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  html.kimflow-web .auth-screen {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100vw;
    max-width: 100vw;
    padding: 28px 16px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  html.kimflow-web .auth-visual {
    width: 100%;
    min-height: 0;
    text-align: center;
  }

  html.kimflow-web .auth-visual strong {
    max-width: 100%;
    font-size: 52px;
    line-height: 1;
    overflow-wrap: anywhere;
  }

  html.kimflow-web #authDecryptedLine::after {
    font-size: 16px;
  }

  html.kimflow-web .auth-visual p {
    max-width: 100%;
    font-size: 15px;
  }

  html.kimflow-web .auth-card {
    width: min(480px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 18px;
    border-radius: 8px;
  }

  html.kimflow-web .market-intel-summary,
  html.kimflow-web .admin-form-grid,
  html.kimflow-web .settings-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 420px) {
  html.kimflow-web .auth-screen {
    padding: 22px 12px;
  }

  html.kimflow-web .auth-card {
    width: calc(100vw - 24px);
    padding: 16px;
  }

  html.kimflow-web .auth-visual strong {
    font-size: 46px;
  }

  html.kimflow-web #authDecryptedLine::after {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.kimflow-web *,
  html.kimflow-web *::before,
  html.kimflow-web *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Web beta mobile auth hardening */
html.kimflow-web,
html.kimflow-web body {
  min-width: 0 !important;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 760px) {
  html.kimflow-web .auth-screen {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    min-width: 0;
  }

  html.kimflow-web .auth-visual,
  html.kimflow-web .auth-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 480px;
    transform: none !important;
    left: auto !important;
    right: auto !important;
  }

  html.kimflow-web .auth-card {
    max-width: calc(100vw - 32px);
    overflow: hidden;
  }

  html.kimflow-web .auth-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  html.kimflow-web .auth-card input {
    min-width: 0 !important;
    width: 100% !important;
  }
}

@media (max-width: 420px) {
  html.kimflow-web .auth-card {
    max-width: calc(100vw - 24px);
  }
}
