/* ============ Student responsive layer ============
   <768px: phone layout from ai.css.
   768-1023px: wide single-column tablet layout.
   >=1024px: desktop rail + full-height content canvas; home also keeps chat visible.
*/

.web-rail { display: none; }

/* Text and flex items must be allowed to shrink before they can wrap. */
.phone,
.s-header,
.s-body,
.s-section,
.between > *,
.sheet-head > *,
.sheet-dock input,
.preview-msg .pm-txt,
.job-card .co,
.me-txt,
.set-txt { min-width: 0; }

.s-name,
.s-tag,
.s-section-title,
.job-card .co,
.job-card .pitch,
.me-txt b,
.me-txt span,
.set-txt b,
.set-txt span,
.preview-msg .pm-txt,
.tool-summary { overflow-wrap: anywhere; }

.btn {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  justify-content: center;
  line-height: 1.35;
}

/* ============ Tablet: unlock the 420px phone preview ============ */
@media (min-width: 768px) and (max-width: 1023px) {
  body.student { align-items: stretch; }

  body.student .phone {
    width: min(100%, 760px);
    max-width: 760px;
    min-height: 100vh;
    box-shadow: none;
  }

  body.student .s-header { padding: 20px 24px 16px; }
  body.student .s-name { font-size: 22px; }
  body.student .s-body { padding: 20px 24px 112px !important; }
  body.student .tabbar,
  body.student.has-chat .dock,
  body.student.has-chat .chat-sheet { max-width: 760px; }

  body.student.web-grid .s-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 18px;
    align-content: start;
  }

  body.student.web-grid .s-body > .s-section:first-child { grid-column: 1 / -1; }
  body.student.web-grid .s-section { margin-bottom: 4px; }
  body.student.web-grid .me-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 96px;
    padding: 16px;
  }
  body.student.web-grid .me-row .me-go { display: none; }
  body.student.web-grid .me-row .me-ico { font-size: 22px; }
}

/* Shared placement for the "Me" card grid on tablet and desktop. */
@media (min-width: 768px) {
  body.student.web-grid .s-body.me-layout {
    grid-template-areas:
      "profile projects"
      "resume projects"
      "ask map"
      "logout settings"
      "reason reason";
    align-items: stretch;
  }
  .me-profile { grid-area: profile; }
  .me-projects { grid-area: projects; }
  .me-resume { grid-area: resume; }
  .me-map { grid-area: map; }
  .me-ask { grid-area: ask; }
  .me-settings { grid-area: settings; }
  .me-logout { grid-area: logout; }
  .me-reason { grid-area: reason; }
  .me-projects .vp-card + .vp-card { margin-top: 8px; }
}

/* ============ Desktop ============ */
@media (min-width: 1024px) {
  html { background: var(--bg-canvas); }

  body.student {
    --rail-width: clamp(200px, 15.3vw, 220px);
    --chat-width: clamp(348px, 26.4vw, 380px);
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
    background: var(--bg-canvas);
    justify-content: stretch;
    align-items: stretch;
  }
  body.student.has-chat {
    grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--chat-width);
  }

  /* Left navigation rail. */
  .web-rail {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
  }
  .wr-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
  .wr-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--ai-grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; box-shadow: 0 4px 12px rgba(168,85,247,.35); flex-shrink: 0; }
  .wr-brand-txt { min-width: 0; }
  .wr-name { font-weight: 700; font-size: 15px; }
  .wr-sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
  .wr-nav { display: flex; flex-direction: column; gap: 2px; }
  .wr-sec { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 14px 10px 6px; }
  .wr-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13.5px; font-weight: 500; transition: all .1s; }
  .wr-item:hover { background: var(--bg-hover); color: var(--text); }
  .wr-item.active { background: var(--primary-soft); color: var(--primary); }
  .wr-item .ico { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
  .wr-foot { margin-top: auto; padding: 12px 8px 4px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--border); }
  .wr-ava { width: 32px; height: 32px; border-radius: 50%; background: var(--ai-grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
  .wr-who { flex: 1; min-width: 0; }
  .wr-who > div { overflow-wrap: anywhere; }
  .wr-who > div:first-child { font-size: 13.5px; font-weight: 600; }
  .wr-out { color: var(--text-3); font-size: 16px; padding: 4px 6px; border-radius: 7px; flex-shrink: 0; }
  .wr-out:hover { background: var(--bg-hover); color: var(--danger); }

  /* Every authenticated page becomes a real desktop canvas. */
  body.student .phone {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    margin: 0;
    box-shadow: none;
    background: var(--bg-canvas);
  }
  body.student .s-header { padding: 20px 36px 16px; background: var(--bg); }
  body.student .s-name { font-size: 24px; }
  body.student .s-body {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 18px 36px 48px !important;
  }

  body.student .tabbar { display: none !important; }
  body.student.has-chat .dock { display: none !important; }

  /* Home: central cockpit + persistent companion chat. */
  body.student.has-chat .s-body { max-width: 760px; }
  body.student.has-chat .chat-sheet {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    width: 100%;
    max-width: none !important;
    height: 100vh;
    margin: 0 !important;
    box-shadow: none !important;
    border-left: 1px solid var(--border);
    border-top: none;
    animation: none !important;
  }
  body.student.has-chat .chat-sheet.show { animation: none !important; }
  body.student.has-chat .sheet-head { padding: 16px 18px; }
  body.student.has-chat .sheet-head .close { display: none; }
  body.student.has-chat .sheet-dock input { min-width: 0; }

  /* Progress and Me: two-column content grids. */
  body.student.web-grid .s-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 24px;
    align-content: start;
    max-width: 980px;
  }
  body.student.web-grid .s-body > .s-section:first-child { grid-column: 1 / -1; }
  body.student.web-grid .s-section { margin-bottom: 4px; }
  body.student.web-grid .me-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 96px;
    padding: 16px;
  }
  body.student.web-grid .me-row .me-go { display: none; }
  body.student.web-grid .me-row .me-ico { font-size: 22px; }
  body.student.web-grid .me-badge,
  body.student.web-grid .me-pro { flex-shrink: 0; }
  body.student.web-grid .vp-card { margin-bottom: 0; }

  /* Resume: stay single-column at the 1024px edge, split when space is real. */
  body.student.web-split .s-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-content: start;
    max-width: 820px;
  }
  body.student.web-split .r-side { margin-top: 0; position: static; align-self: start; }

  /* Interview stage. */
  body.student.web-stage .s-body { max-width: 820px; padding-bottom: 120px !important; }
  body.student.web-stage .iv-mic-dock {
    position: static;
    left: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    padding: 14px 36px calc(16px + env(safe-area-inset-bottom));
    transform: none;
  }

  /* Jobs: dense two-column list and readable card headers. */
  body.student.web-jobs .s-body { max-width: 1100px; padding-top: 16px !important; }
  body.student.web-jobs .job-filter { position: sticky; top: 0; z-index: 5; padding: 6px 0 10px; background: var(--bg-canvas); }
  body.student.web-jobs .jobs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  body.student.web-jobs .job-card .between { align-items: flex-start; gap: 12px; }
  body.student.web-jobs .job-card .badge { flex-shrink: 0; }

  /* Remaining student pages now use the desktop canvas instead of a phone preview. */
  body.student.web-ask .s-body { max-width: 860px; }
  body.student.web-settings .s-body { max-width: 780px; }

  body.student.web-project .s-body {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(280px, .82fr);
    grid-template-areas:
      "hero hero"
      "current sample"
      "current pro";
    gap: 18px 24px;
    align-content: start;
    max-width: 1100px;
  }
  body.student.web-project .trust-hero { grid-area: hero; }
  body.student.web-project .project-current { grid-area: current; }
  body.student.web-project .project-sample { grid-area: sample; }
  body.student.web-project .project-pro { grid-area: pro; }
  body.student.web-project .s-section { margin-bottom: 0; min-width: 0; }
  body.student.web-project .project-pro .pro-card { height: 100%; }

  body.student.web-map .s-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
    align-content: start;
    max-width: 1100px;
  }
  body.student.web-map .hero,
  body.student.web-map .map-steps,
  body.student.web-map .lock-note { grid-column: 1 / -1; }
  body.student.web-map .map-panel { min-width: 0; }
  body.student.web-map .map-panel .map-card { height: calc(100% - 28px); }
}

@media (min-width: 1200px) {
  body.student.web-split .s-body {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 28px;
    max-width: 1120px;
  }
  body.student.web-split .r-side { position: sticky; top: 18px; }
}

/* Keep very large displays composed instead of stretching indefinitely. */
@media (min-width: 1440px) {
  body.student { max-width: 1440px; margin: 0 auto; }
}
