@font-face {
  font-family: "Source Han Sans SC";
  src: url("/static/fonts/SourceHanSansSC-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Han Sans SC";
  src: url("/static/fonts/SourceHanSansSC-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  font-family: "Source Han Sans SC", sans-serif;
  color: #252b36;
  background: #fff;
  --border: #e8eaee;
  --muted: #717986;
  --accent: #315ed0;
}

* { box-sizing: border-box; }
body { margin: 0; font-size: 16px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.header { display: flex; align-items: center; height: 64px; padding: 0 28px; border-bottom: 1px solid var(--border); }
.brand { color: inherit; text-decoration: none; font-size: 20px; font-weight: 700; }
.layout { display: grid; grid-template-columns: 188px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { padding: 24px 16px; border-right: 1px solid var(--border); }
.sidebar-title { margin: 0 12px 12px; color: var(--muted); font-size: 14px; font-weight: 400; }
.topic-list { display: flex; flex-direction: column; gap: 4px; }
.topic-button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 12px; border: 0; border-radius: 4px; background: transparent; text-align: left; }
.topic-button:hover { background: #f6f7f9; }
.topic-button.is-active { color: var(--accent); background: #eef3ff; }
.topic-count { color: var(--muted); font-size: 14px; }
.main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 32px 40px; }
.content-heading { display: flex; align-items: baseline; gap: 16px; margin-bottom: 24px; }
h1 { margin: 0; font-size: 20px; font-weight: 700; }
.result-count { color: var(--muted); font-size: 14px; }
.filters { display: grid; grid-template-columns: minmax(180px, 1fr) 156px 116px; gap: 12px; margin-bottom: 24px; }
.search { position: relative; }
.search svg { position: absolute; width: 18px; height: 18px; left: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }
input, select, textarea { min-width: 0; min-height: 40px; padding: 8px 12px; border: 1px solid #dce0e6; border-radius: 4px; background: #fff; font-size: 14px; }
input::placeholder { color: #8c939d; }
select { width: 100%; appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23717986' stroke-width='1.5'%3E%3Cpath d='m3 5 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.list-columns, .question-card { display: grid; grid-template-columns: 108px 104px minmax(0, 1fr) 116px; align-items: center; column-gap: 20px; }
.list-columns { padding: 10px 16px; color: var(--muted); background: #f6f7f9; border-bottom: 1px solid var(--border); font-size: 14px; }
.question-card { width: 100%; min-height: 80px; padding: 16px; border: 0; border-bottom: 1px solid var(--border); background: #fff; text-align: left; }
.question-card:hover { background: #f8faff; }
.question-year, .question-number { color: var(--muted); font-size: 14px; }
.question-kind { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.question-number { white-space: nowrap; }
.type-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border: 1px solid #e2e5ea; border-radius: 5px; color: #596270; background: #f3f4f6; font-size: 14px; font-weight: 400; line-height: 1.5; white-space: nowrap; }
.type-badge[data-type="choice"] { color: #a33161; background: #fce7f0; border-color: #f5cedf; }
.type-badge[data-type="fill_blank"] { color: #7350a5; background: #f0eafa; border-color: #e2d6f4; }
.type-badge[data-type="true_false"] { color: #9a5a1b; background: #fff0df; border-color: #f6dfc2; }
.type-badge[data-type="application"] { color: #236e6a; background: #e3f4f1; border-color: #c8e7e1; }
.type-badge[data-type="code"] { color: #345fa3; background: #e8effc; border-color: #d0def5; }
.question-stem { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.katex { margin-inline: .08em; font-size: 1.04em; white-space: normal; }
.katex-display { margin: 16px 0; overflow-x: auto; overflow-y: hidden; }
.question-stem .katex-display { display: inline-block; max-width: 100%; margin: 0; vertical-align: middle; }
.tag-list { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.tag { color: #4a63a0; font-size: 14px; }
.button { min-height: 36px; padding: 7px 16px; border: 1px solid transparent; border-radius: 4px; font-size: 14px; white-space: nowrap; }
.button-outline { border-color: #dce0e6; background: #fff; }
.button-outline:hover:not(:disabled) { background: #f6f7f9; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: #264fb5; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 24px; }
#page-label { color: var(--muted); font-size: 14px; }
.empty-state { padding: 80px 16px; text-align: center; color: var(--muted); }

.drawer { width: min(720px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--border); background: #fff; overflow-y: auto; }
.drawer::backdrop { background: rgb(25 35 50 / 20%); }
html:has(.drawer[open]) { overflow: hidden; }
.drawer-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 28px; border-bottom: 1px solid var(--border); background: #fff; }
.drawer-header h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-width: 0; margin: 0; font-size: 18px; font-weight: 700; }
.drawer-actions { display: flex; flex-shrink: 0; align-items: center; gap: 12px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; color: var(--muted); background: transparent; }
.icon-button:hover { background: #f3f4f6; }
.icon-button svg { width: 20px; height: 20px; }
.drawer-body { padding: 24px 28px 32px; }
.detail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.detail-topics { margin-bottom: 24px; }
.detail-stem, .answer-text { line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-figures { display: grid; gap: 20px; margin-top: 20px; }
.detail-figure { max-width: 100%; margin: 0; overflow-x: auto; }
.detail-figure img { display: block; width: 664px; max-width: 100%; height: auto; }
.detail-options { display: grid; gap: 12px; margin-top: 24px; }
.option-row { display: flex; align-items: baseline; gap: 12px; min-height: 32px; line-height: 1.8; }
.option-key { flex: 0 0 22px; }
.option-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.answer-section h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.answer-text { margin-top: 8px; }
.edit-form { display: grid; gap: 20px; }
.field, .option-field { display: grid; gap: 8px; font-size: 14px; }
.field input, .field textarea, .option-field textarea { width: 100%; font-size: 16px; }
textarea { resize: vertical; line-height: 1.8; }
#edit-options { display: grid; gap: 16px; }
#edit-options:empty { display: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 4px; }
.notice { position: fixed; bottom: 24px; left: 50%; z-index: 5; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 4px; background: #283348; color: #fff; font-size: 14px; }
.drawer .notice { right: 24px; left: auto; transform: none; }

@media (max-width: 1100px) {
  .main { padding: 24px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .list-columns, .question-card { grid-template-columns: 94px 96px minmax(0, 1fr) 86px; column-gap: 14px; }
}
@media (max-width: 680px) {
  .header { height: 60px; padding: 0 20px; }
  .brand { font-size: 18px; }
  .layout { display: block; }
  .sidebar { padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-title { display: none; }
  .topic-list { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: thin; }
  .topic-button { flex: 0 0 auto; width: auto; padding: 7px 10px; white-space: nowrap; }
  .main { padding: 24px 16px; }
  .content-heading { margin-bottom: 20px; }
  .filters { gap: 8px; margin-bottom: 12px; }
  select { padding: 8px 28px 8px 8px; }
  .list-columns { display: none; }
  .question-card { grid-template-columns: auto 1fr; gap: 10px 20px; padding: 18px 4px; }
  .question-kind { flex-direction: row; align-items: center; gap: 10px; }
  .question-stem, .question-card .tag-list { grid-column: 1 / -1; }
  .drawer-header { padding: 18px 20px; }
  .drawer-header h2 { font-size: 16px; }
  .drawer-body { padding: 20px; }
  .detail-figure img { max-width: none; }
}
