/* WMU study workspace. Existing markup, controls and print rules live in the base sheets. */
@media screen {
  :root {
    color-scheme: light;
    --bg: #f7f5f1;
    --cream: var(--bg);
    --bg-card: #fffefc;
    --bg-soft: #f3efeb;
    --bg-inset: #f8f5f1;
    --text: #292125;
    --text-soft: #51464a;
    --text-muted: #695e62;
    --ink: var(--text);
    --ink-soft: var(--text-soft);
    --line: #e4dcd6;
    --border: var(--line);
    --border-strong: #cbbeb9;
    --primary-soft: #f3e7e9;
    --primary-line: #d9b9c0;
    --action: #811d35;
    --action-hover: #68162b;
    --accent: #8a501f;
    --accent-soft: #f5e9da;
    --highlight: #f8e7bf;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgb(49 31 34 / 5%);
    --shadow: 0 12px 30px -20px rgb(49 31 34 / 27%), var(--shadow-sm);
    --shadow-lg: 0 28px 68px -36px rgb(67 37 42 / 35%), var(--shadow-sm);
    --ring: 0 0 0 3px rgb(129 29 53 / 18%);
    --serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', SimSun, Georgia, serif;
    --font: 'PingFang SC', 'Microsoft YaHei UI', 'Noto Sans SC', 'Segoe UI', sans-serif;
    --tr: 150ms ease;
  }

  body { background: var(--bg); }
  h1, h2, h3, h4 { letter-spacing: -.015em; }
  .hero-sub, .auth-brand .brand-sub, .chat-welcome p { text-wrap: pretty; }

  :is(a, button, summary):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    box-shadow: none;
  }

  :is(input[type='text'], input[type='password'], input[type='date'], select, textarea) {
    background-color: var(--bg-card);
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
  }

  :is(.search-box, .auth-form, .hist-filter, .adm-filter) :is(input, select):focus,
  #panel-ask .ask-box textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
  ::placeholder { color: var(--text-muted); opacity: 1; }

  .btn-primary {
    background: var(--action);
    color: #fff;
    min-height: 42px;
    box-shadow: none;
    border-radius: var(--radius-sm);
  }

  .btn-primary:not(:disabled):hover { background: var(--action-hover); box-shadow: none; transform: none; }
  .btn-primary:not(:disabled):active { transform: translateY(1px); }
  .btn-primary:disabled { box-shadow: none; }

  .btn-ghost, .btn-icon, .chat-tool {
    background: var(--bg-card);
    color: var(--text-soft);
    border-radius: var(--radius-sm);
  }

  .btn-ghost:not(:disabled):hover, .btn-icon:hover, .chat-tool:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary-line);
  }

  #logoutBtn:hover { color: var(--err); border-color: var(--err); }

  /* The original wordmark and title provide the focal point on the sign-in page. */
  .auth-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: safe center;
    justify-items: center;
    padding: clamp(16px, 5vw, 48px);
    background:
      linear-gradient(90deg, transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px)),
      radial-gradient(ellipse at 50% 0, var(--primary-soft), transparent 52%),
      var(--bg);
  }

  .auth-card {
    position: relative;
    width: 438px;
    max-width: 100%;
    padding: clamp(23px, 6vw, 38px);
    gap: 17px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .auth-card::before {
    content: '';
    position: absolute;
    inset: -1px auto auto 30px;
    width: 54px;
    height: 3px;
    background: var(--action);
    border-radius: 0 0 3px 3px;
  }

  .auth-brand { align-items: flex-start; text-align: left; gap: 8px; }
  .auth-brand h1, .search-hero h2 {
    font-family: var(--serif);
    font-weight: 700;
    line-height: 1.22;
    color: var(--text);
  }

  .auth-brand h1 { margin-top: 9px; font-size: clamp(25px, 6vw, 34px); }
  .auth-card h1::after { color: var(--primary); margin-top: 10px; letter-spacing: .12em; }
  .auth-brand .brand-sub { display: block; white-space: normal; font-size: 13px; }
  .auth-card .brand-logo, .topbar .brand-logo, .chat-avatar--ai {
    background: var(--action);
    color: #fff;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%);
  }

  .auth-card .brand-logo { width: 45px; height: 45px; font-family: var(--serif); font-size: 23px; }
  .auth-tabs { gap: 4px; background: var(--bg-soft); overflow: visible; }
  .auth-tab { min-height: 40px; border: 1px solid transparent; }
  .auth-tab:hover { color: var(--primary); }
  .auth-tab.active { color: var(--primary); background: var(--bg-card); border-color: var(--line); box-shadow: var(--shadow-sm); }
  .auth-form { gap: 12px; }
  .auth-form label { font-weight: 650; }
  .auth-form input, .auth-form .btn-primary { min-height: 45px; }
  .auth-form #authUser::placeholder { font-size: clamp(11px, 3vw, 13px); }
  .auth-form .btn-primary { margin-top: 2px; }
  .auth-msg:empty { min-height: 0; margin-top: -12px; }
  .auth-card .build-tag { padding-top: 11px; border-top: 1px solid var(--line); margin: 0; }

  .wmu-banner {
    background: var(--bg-soft);
    border-color: var(--line);
    padding: 7px clamp(14px, 3vw, 42px);
    gap: 9px;
    font-size: 12px;
  }

  .topbar {
    background: var(--bg-card);
    border-color: var(--line);
    padding: 12px clamp(14px, 3vw, 42px);
    gap: 12px 18px;
    box-shadow: var(--shadow-sm);
  }

  .brand { gap: 10px; }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 17px; }
  .topbar .brand-logo { width: 38px; height: 38px; font-family: var(--serif); }
  .tabs { gap: 4px; }
  .tab {
    color: var(--text-soft);
    border-radius: var(--radius-sm);
    padding: 7px clamp(8px, 1vw, 13px);
    font-size: 13px;
    min-height: 39px;
  }

  .tab.active { color: var(--primary); background: var(--primary-soft); border-color: var(--primary-line); box-shadow: none; }
  .tab:hover { color: var(--primary); }
  .top-right { gap: 7px; }
  .status-pill, .user-badge { font-size: 12px; padding: 4px 9px; }
  .user-badge { overflow: hidden; text-overflow: ellipsis; max-width: min(21vw, 160px); }

  .content { max-width: 1224px; padding: clamp(22px, 3.2vw, 42px) clamp(14px, 3.4vw, 36px) 54px; }
  .search-hero {
    max-width: 900px;
    margin: 0 auto;
    padding: clamp(24px, 4.5vw, 52px);
    text-align: left;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(118deg, var(--bg-card) 54%, var(--bg-soft));
    box-shadow: var(--shadow);
  }

  .search-hero h2 { font-size: clamp(29px, 4vw, 45px); margin-bottom: 10px; }
  .search-hero .hero-sub { margin: 0 0 24px; color: var(--text-soft); }
  .search-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(126px, .33fr) max-content;
    gap: 8px;
    margin: 0;
    max-width: none;
  }

  .search-box > * { width: 100%; min-width: 0; min-height: 48px; }
  .search-box .book-select { max-width: none; }
  .search-box input[type='text'] { padding-inline: 13px; box-shadow: none; }

  .card, .chat-wrap, .result-card, .term-card, .job-card, .book-item, .hist-item,
  .adm-user, .adm-book { border-color: var(--line); box-shadow: var(--shadow-sm); }
  .card:hover, .result-card:hover, .book-item:hover { box-shadow: var(--shadow-sm); transform: none; }
  .result-card:hover, .book-item:hover, .hist-item:hover { border-color: var(--primary-line); }
  .card { padding: clamp(16px, 2.2vw, 24px); }
  .card h3 { font-size: 16px; margin-bottom: 12px; }
  .term-card { border-inline-start: 1px solid var(--line); }
  .result-card { padding: 18px clamp(15px, 3.1vw, 26px); }
  .result-text, .term-body { line-height: 1.85; }
  .result-text mark, mark { background: var(--highlight); color: inherit; }
  .cite { color: var(--primary); }
  .drop-zone { background: var(--bg-inset); border-color: var(--border-strong); }
  .drop-zone:hover, .drop-zone.dragover { background: var(--primary-soft); border-color: var(--primary); }
  .hist-filter, .adm-filter { background: var(--bg-card); border-color: var(--line); }
  .hist-time, .prog-pct, .status-pill, .result-page { font-variant-numeric: tabular-nums; }
  .hist-list .empty-state, .results .empty-state { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); }

  .chat-bar { background: var(--bg-inset); padding: 12px 16px; }
  .chat-bar-name { gap: 4px; }
  .chat-book { min-width: 0; }
  .chat-bar-tools { min-width: 0; }
  .chat-welcome h3 { font-family: var(--serif); font-size: clamp(21px, 3vw, 28px); }
  .chat-welcome-ic { border-radius: 14px; box-shadow: none; }
  .chat-sample { border-radius: var(--radius-sm); }
  .chat-sample:hover { transform: none; }
  #panel-ask .msg-body { line-height: 1.85; }
  #panel-ask .msg-user .msg-body { background: var(--action); color: #fff; box-shadow: none; }
  #panel-ask .msg-assistant .msg-body { background: var(--bg-inset); box-shadow: none; }
  .msg-actions:focus-within { opacity: 1; }
  #panel-ask .ask-box textarea { min-width: 0; min-height: 42px; border-radius: var(--radius-sm); }
  #panel-ask .ask-attach { min-width: 42px; min-height: 42px; }

  @media (max-width: 720px) {
    .topbar { gap: 7px 10px; padding: 9px 14px; }
    .topbar .brand-logo { width: 34px; height: 34px; }
    .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; padding: 0; }
    .tab { min-height: 44px; padding-inline: 3px; }
    .top-right { gap: 5px; justify-content: flex-start; }
    #logoutBtn { margin-inline-start: auto; }
    .user-badge { max-width: 34vw; }
    .content { padding-top: 15px; }
    .search-box { grid-template-columns: minmax(0, 1fr) minmax(90px, max-content); }
    .search-box input { grid-column: 1 / -1; }
    .chat-bar { padding: 8px 12px; }
    .chat-bar-tools { flex-wrap: wrap; }
    .chat-tool, .chat-book { min-height: 36px; }
    #panel-ask .ask-attach, #panel-ask .ask-send { min-height: 44px; }
    #panel-ask .ask-send { padding-inline: 12px; }
    #panel-ask .ask-box textarea { min-height: 55px; }
    #panel-ask .ask-box textarea::placeholder { font-size: 12px; }
    .hist-filter :is(input, select, button), .adm-filter :is(input, select, button) { min-height: 44px; }
  }

  @media (prefers-color-scheme: dark) {
    :root {
      color-scheme: dark;
      --bg: #211b1d;
      --bg-card: #292225;
      --bg-soft: #2d2528;
      --bg-inset: #251e21;
      --text: #f3eeec;
      --text-soft: #e1d6d6;
      --text-muted: #c0b1b3;
      --line: #493c41;
      --border-strong: #6c575e;
      --primary: #f2bbc9;
      --primary-soft: #422c34;
      --primary-line: #76515e;
      --action: #9c2946;
      --action-hover: #ac3251;
      --accent: #eab484;
      --accent-soft: #442f27;
      --highlight: #5e4827;
      --shadow-sm: none;
      --shadow: 0 10px 28px -20px rgb(0 0 0 / 70%);
      --shadow-lg: 0 28px 68px -36px rgb(0 0 0 / 73%);
      --ring: 0 0 0 3px rgb(242 187 201 / 26%);
    }

    .wmu-banner .wmu-ctx { color: var(--text-muted); }
    .chat-avatar--me { background: var(--primary-soft); color: var(--primary); }
    .chat-bar .chat-avatar--ai { background: var(--action); color: #fff; }
  }

  @media (prefers-reduced-motion: reduce) {
    .panel, .chat-welcome, #panel-ask .msg, .chat-tobottom { animation: none; }
    #panel-ask .chat-log { scroll-behavior: auto; }
    :root { --tr: 0s; }
  }
}
