/* Vision Study X — Responsive Multi-Device Layout & Tactile Navigation */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  background-color: var(--bg-solid);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.45;
  transition: background-color 0.22s ease, color 0.22s ease;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

input {
  font-family: inherit;
  color: inherit;
}

.app-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

/* Desktop & Tablet Left Icon Rail */
.side-rail {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: var(--rail-width);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  gap: 8px;
  z-index: 40;
}

.rail-logo {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  box-shadow: var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring);
}

.rail-logo:hover {
  transform: scale(1.06) rotate(-2deg);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  flex: 1;
}

.rail-btn {
  width: 100%;
  padding: 9px 4px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  transition: transform 0.18s var(--ease-spring), background-color 0.16s ease, color 0.16s ease;
}

.rail-icon-wrap {
  width: 36px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  transition: background-color 0.18s ease, transform 0.18s var(--ease-spring), box-shadow 0.18s ease;
}

.rail-btn:hover {
  color: var(--text);
  transform: scale(1.04);
}

.rail-btn:hover .rail-icon-wrap {
  background: var(--surface-muted);
  transform: scale(1.08);
}

.rail-btn:active {
  transform: scale(0.93);
}

.rail-btn.active {
  color: var(--brand);
  font-weight: 700;
}

.rail-btn.active .rail-icon-wrap {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.rail-btn.mode-pill {
  margin: 4px 0;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.rail-btn.mode-pill.is-kgs {
  background: var(--emerald-soft);
  border-color: rgba(5, 150, 105, 0.45);
  color: var(--emerald);
}

.rail-btn.mode-pill.is-kgs .rail-icon-wrap {
  background: var(--emerald-gradient);
  color: #fff;
}

/* Main Workspace Area */
.workspace {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  margin-left: calc(var(--rail-width) + 24px);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 22px 44px;
}

.view-animate {
  animation: viewEnter 0.22s var(--ease-snappy);
}

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sticky Top Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-solid);
  border-bottom: 1px solid var(--border);
  padding: 10px 22px;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-badge-mobile {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand);
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Responsive Grids */
.grid-collections {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.grid-batches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-socials {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1023px) {
  :root {
    --rail-width: 74px;
  }
  .container { padding: 12px 16px 36px; }
  .topbar { padding: 10px 16px; }
  .grid-collections, .grid-socials { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-batches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
  .side-rail {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--safe-bottom));
    width: auto;
    height: 68px;
    flex-direction: row;
    padding: 6px 8px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
  }
  .rail-logo { display: none; }
  .rail-nav {
    flex-direction: row;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
  }
  .rail-btn {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 5px 2px;
    font-size: 10px;
    gap: 3px;
    border-radius: 12px;
  }
  .rail-icon-wrap {
    width: 34px;
    height: 26px;
    border-radius: 9px;
  }
  .rail-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .rail-btn.mode-pill { margin: 0; }
  .workspace {
    margin-left: 0;
    padding-bottom: calc(88px + var(--safe-bottom));
  }
  .topbar { padding: 10px 14px; }
  .container { padding: 12px 14px 24px; }
  .brand-badge-mobile { display: grid; }
  .hide-mobile { display: none !important; }
  .grid-collections { grid-template-columns: 1fr; gap: 10px; }
  .grid-batches { grid-template-columns: 1fr; gap: 12px; }
  .grid-socials { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
