:root {
  --plum: #4F3D6B;
  --accent: #4F3D6B;
  --ink: #1e1a26;
  --muted: #6b647a;
  --bg: #f7f5fa;
  --card: #ffffff;
  --line: #e3ddec;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 96px; }

.shell-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--plum); color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.school-logo { height: 28px; margin-left: auto; background: #fff; border-radius: 4px; padding: 2px 6px; }
.school-name { margin-left: auto; font-weight: 600; color: #fff !important; opacity: .9; font-size: .9rem; }
.logout-form { margin: 0; }
.link-btn { background: none; border: none; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 10px; min-height: 44px; }

.ask-bar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 16px; }
#ask-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 720px; margin: 0 auto; }
#ask-input { flex: 1 1 200px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.ask-scope { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }
#ask-form button[type="submit"] { min-height: 44px; padding: 8px 16px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.ask-answer { max-width: 720px; margin: 8px auto 0; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; }
.ask-answer .sources { margin-top: 8px; font-size: .8rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px 0; max-width: 720px; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.tab { flex: 0 0 auto; min-height: 44px; display: flex; align-items: center; padding: 8px 14px; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--muted); background: transparent; font-weight: 600; font-size: .9rem; }
.tab.active { color: var(--accent); background: var(--card); border: 1px solid var(--line); border-bottom-color: var(--card); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.card h2 { margin: 0 0 8px; font-size: 1.05rem; color: var(--accent); }
.card h3 { margin: 12px 0 6px; font-size: .95rem; }
.muted { color: var(--muted); font-size: .9rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: none; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }

form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; }
textarea { width: 100%; min-height: 88px; }
button { font: inherit; }
button.primary, form button[type="submit"] { min-height: 44px; padding: 8px 16px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }

.login-wrap { max-width: 360px; margin: 10vh auto; padding: 0 16px; }
.login-wrap form { display: flex; flex-direction: column; gap: 12px; }
.error { color: #a02040; font-size: .9rem; }

.upload-zone { border: 1.5px dashed var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; }
.upload-zone strong { display: block; margin-bottom: 4px; }
.upload-zone input[type="file"] { min-height: auto; border: none; padding: 4px 0; width: 100%; }

.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.status-pill.done { color: #1c6b3a; border-color: #bfe3cd; background: #ecf8f0; }
.status-pill.failed { color: #a02040; border-color: #eccad4; background: #fdf0f4; }

.help-btn { position: fixed; right: 16px; bottom: 16px; min-width: 64px; min-height: 48px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; font-size: 1rem; box-shadow: 0 4px 12px rgba(0,0,0,.25); cursor: pointer; }
dialog { border: 1px solid var(--line); border-radius: 12px; width: min(480px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(30,26,38,.5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
