:root {
  --primary: #1a73e8;
  --primary-dark: #1765cc;
  --primary-soft: #e8f0fe;
  --primary-soft-text: #1967d2;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #626f81;
  --border: #dde1e6;
  --border-light: #eceff2;
  --ring-track: #e8eaed;
  --green: #34a853;
  --green-soft: #e6f4ea;
  --green-text: #137333;
  --warn-bg: #fef7e0;
  --warn-text: #b06000;
  --error: #d93025;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 18px;
  --shadow-1: 0 1px 2px rgba(60,64,67,0.12), 0 1px 4px rgba(60,64,67,0.08);
  --shadow-2: 0 2px 6px rgba(60,64,67,0.15), 0 6px 16px rgba(60,64,67,0.10);
  --tap: 44px;
  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-text: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-hero: clamp(25px, 4vw, 32px);
  --lh-tight: 1.35;
  --lh-ui: 1.45;
  --lh-body: 1.7;
  --tracking-tight: -.01em;
  --tracking-label: .04em;
}

html, body { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: var(--lh-body);
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Long-form copy and math keep proportional spacing off */
textarea,
.katex,
.katex * {
  font-feature-settings: "palt" 0;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 20px calc(56px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xl);
  flex: none;
  box-shadow: var(--shadow-1);
}
.brand { display: grid; line-height: 1.3; min-width: 0; }
.title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: var(--tracking-tight); }
.subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.account-bar { position: relative; flex: none; }
.icon-btn {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  font: inherit;
  padding: 0;
}
.icon-btn i { color: var(--primary); font-size: var(--fs-xl); }
.icon-btn:hover { background: #f8fbff; border-color: #d2e3fc; }
.theme-toggle { flex: none; }
.theme-toggle[data-theme-preference="dark"] i { color: #8ab4f8; }
.theme-toggle[data-theme-preference="light"] i { color: #b06000; }
.account-chip {
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-text);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px 0 10px;
  cursor: pointer;
  touch-action: manipulation;
  max-width: 220px;
}
.account-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip i { color: var(--primary); font-size: var(--fs-lg); flex: none; }
.account-chip .chev { color: var(--text-muted); font-size: var(--fs-base); }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.account-menu-head { display: grid; gap: 6px; justify-items: start; }
.account-menu-head p {
  margin: 0;
  font-size: var(--fs-text);
  color: var(--text-secondary);
  line-height: 1.6;
}
.account-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f3f4;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.account-badge.free { background: var(--primary-soft); color: var(--primary-soft-text); }
.account-badge.paid { background: var(--green-soft); color: var(--green-text); }
.account-meter { display: grid; gap: 6px; }
.meter-track {
  height: 8px;
  border-radius: 999px;
  background: var(--ring-track);
  overflow: hidden;
}
.meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}
.meter-fill.paid { background: var(--green); }
.quota-text { font-size: var(--fs-sm); color: var(--text-secondary); }
.account-menu-actions { display: grid; gap: 8px; }
.account-primary-btn, .account-secondary-btn {
  min-height: var(--tap);
  border-radius: 999px;
  font: inherit;
  font-size: var(--fs-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.account-primary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}
.account-primary-btn i { color: inherit; font-size: var(--fs-md); }
.account-secondary-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: #3c4043;
}
.account-secondary-btn i { color: var(--primary); font-size: var(--fs-md); }
.account-primary-btn:disabled, .account-secondary-btn:disabled { opacity: 0.65; cursor: wait; }
.referral-dialog { border: 0; padding: 0; border-radius: 18px; width: min(520px, calc(100% - 32px)); box-shadow: 0 24px 70px #17213b40; }
.referral-dialog::backdrop { background: #17213b80; }
.image-preview-dialog { width: min(760px, calc(100% - 24px)); max-width: none; padding: 0; border: 0; border-radius: 18px; background: var(--surface); box-shadow: 0 24px 70px #17213b80; }
.image-preview-dialog::backdrop { background: rgba(23,33,59,.72); }
.image-preview-dialog-card { display: grid; gap: 14px; padding: 16px; }
.image-preview-dialog-head, .image-preview-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.image-preview-dialog-head strong { font-size: var(--fs-base); }
.image-preview-edit-actions { display: flex; align-items: center; gap: 8px; }
.image-preview-rotate-btn { color: var(--primary); }
.image-preview-rotate-btn:disabled, .image-preview-delete-btn:disabled { opacity: .55; cursor: wait; }
.image-preview-stage { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; min-height: min(62vh, 560px); }
.image-preview-stage img { display: block; width: 100%; max-height: min(62vh, 560px); object-fit: contain; border-radius: 10px; background: #f1f3f4; }
.image-preview-nav { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-secondary); font: inherit; cursor: pointer; }
.image-preview-nav:hover:not(:disabled) { border-color: #9fc0f2; color: var(--primary); background: #f8fbff; }
.image-preview-nav:disabled { opacity: .35; cursor: default; }
.image-preview-delete-btn { color: var(--danger); }
@media (max-width: 520px) {
  .image-preview-dialog { width: calc(100% - 12px); border-radius: 14px; }
  .image-preview-dialog-card { padding: 12px; }
  .image-preview-stage { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 4px; min-height: 48vh; }
  .image-preview-stage img { max-height: 48vh; }
  .image-preview-nav { width: 44px; height: 44px; }
  .image-preview-dialog-actions { align-items: stretch; flex-direction: column; }
  .image-preview-edit-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-preview-edit-actions .secondary-btn, .image-preview-dialog-actions .account-primary-btn { width: 100%; }
}
.referral-card { display: grid; gap: 16px; padding: 24px; }
.referral-head { display: flex; align-items: center; justify-content: space-between; }
.referral-head h2 { margin: 0; font-size: var(--fs-xl); }
.referral-url { width: 100%; box-sizing: border-box; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.referral-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.referral-actions button { flex: 1 1 120px; }
.referral-status, .referral-rewards { color: var(--text-muted); font-size: var(--fs-base); }
.payment-intro { margin: -6px 0 0; color: var(--text-muted); font-size: var(--fs-base); }
.payment-choice { min-height: 72px; padding: 12px 16px; text-align: left; justify-content: flex-start; }
.payment-choice > i { flex: 0 0 auto; font-size: var(--fs-xl); }
.payment-choice > span { display: grid; gap: 3px; }
.payment-choice strong { font-size: var(--fs-base); font-weight: 600; }
.payment-choice small { color: inherit; font-size: var(--fs-sm); font-weight: 400; opacity: .82; }
.email-password-account { display: flex; align-items: center; gap: 7px; margin: -4px 0 0; color: var(--text-secondary); font-size: var(--fs-text); overflow-wrap: anywhere; }
.email-password-account i { color: var(--primary); }
.dialog-field { display: grid; gap: 6px; color: var(--text-secondary); font-size: var(--fs-text); }
.dialog-field input { width: 100%; box-sizing: border-box; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; color: var(--text); background: var(--surface); }
.dialog-field input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* ---------- notices ---------- */
.billing-notice {
  border: 1px solid #d2e3fc;
  background: #f8fbff;
  color: #174ea6;
  border-radius: var(--radius-s);
  padding: 10px 12px;
  font-size: var(--fs-text);
  margin-bottom: 12px;
}
.billing-notice.warn {
  border-color: #fdd663;
  background: #fff8e1;
  color: #8a4b00;
}

/* ---------- login banner ---------- */
.login-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 850px;
  box-sizing: border-box;
  background: #fff6dc;
  border: 1px solid #f5ce63;
  border-left: 4px solid #f9ab00;
  border-radius: var(--radius-m);
  padding: 14px 16px;
  margin: 0 auto 16px;
  box-shadow: 0 3px 10px rgba(176,96,0,.12);
}
.login-banner > i { font-size: var(--fs-hero); color: #b06000; flex: none; }
.login-banner-copy { display: grid; min-width: 0; flex: 1; line-height: 1.5; }
.login-banner-copy strong { font-size: var(--fs-base); font-weight: 700; color: #5f3b00; }
.login-banner-copy span { font-size: var(--fs-sm); color: var(--text-secondary); }
.banner-login-btn {
  flex: none;
  min-height: var(--tap);
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.banner-login-btn i { font-size: var(--fs-md); }

/* ---------- history (topbar dropdown) ---------- */
.history-bar { position: relative; flex: none; }
.history-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}
.history-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 55;
  width: min(360px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.history-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-menu-title {
  display: block;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text);
}
.history-count { font-size: var(--fs-sm); color: var(--text-muted); }
.history-list {
  display: grid;
  gap: 8px;
  max-height: min(360px, 50vh);
  overflow: auto;
}
.history-empty {
  margin: 0;
  padding: 16px 8px;
  text-align: center;
  font-size: var(--fs-text);
  color: var(--text-muted);
}
.history-item {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 10px 11px;
  text-align: left;
  font: inherit;
  touch-action: manipulation;
  box-sizing: border-box;
}
.history-item:hover { background: #f8fbff; border-color: #d2e3fc; }
.history-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.history-title {
  font-size: var(--fs-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-query {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.history-meta span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ---------- mode toggle ---------- */
.mode-toggle {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  background: #e9edf1;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
  overflow: hidden;
  min-height: 44px;
}
.mode-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  border-radius: 999px;
  color: var(--text-secondary);
  touch-action: manipulation;
  padding: 0 6px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1.2;
}
.mode-btn i {
  font-size: var(--fs-lg);
  flex: none;
  color: inherit;
  opacity: 0.85;
}
.mode-btn.active i { opacity: 1; }
.mode-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.mode-from { font-size: var(--fs-sm); }
.mode-btn.active { color: var(--primary); font-weight: 500; }
.panel.hidden { display: none; }

/* ---------- inputs ---------- */
.input-grid { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.field-block { flex: 1 1 100%; min-width: 0; }
.field-label { display: block; font-size: var(--fs-text); color: var(--text-secondary); margin-bottom: 7px; font-weight: 500; }
.optional { color: var(--text-muted); font-weight: 400; }
.field-hint {
  margin: -8px 0 16px;
  font-size: var(--fs-text);
  line-height: 1.5;
  color: var(--text-muted);
}
textarea {
  width: 100%;
  min-height: 100px;
  height: 100px;
  resize: vertical;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--fs-md);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.description-field { margin-bottom: 12px; }
.description-examples {
  display: grid;
  gap: 7px;
  margin: 0 0 10px;
}
.description-examples-label {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.description-example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.description-example-chip {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}
.description-example-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}
.description-example-chip:focus-visible {
  outline: 3px solid rgba(26, 115, 232, .25);
  outline-offset: 2px;
}
.description-textarea-wrap { position: relative; }
#descriptionText {
  min-height: 112px;
  max-height: 240px;
  height: auto;
  resize: none;
  overflow-y: hidden;
  padding: 12px 66px 32px 14px;
  line-height: 1.55;
}
.description-clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.description-clear-btn:hover { border-color: var(--border); color: var(--text); }
.description-counter {
  position: absolute;
  right: 12px;
  bottom: 9px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.description-counter.is-over-limit { color: var(--danger); font-weight: 700; }
/* ---------- dropzone ---------- */
.image-input-grid { align-items: stretch; gap: 16px; transition: opacity .2s, filter .2s; }
.image-input-grid[aria-disabled="true"] { opacity: .48; filter: grayscale(.18); pointer-events: none; user-select: none; }
.image-field-block {
  padding: 15px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: #fbfcfe;
  box-shadow: 0 1px 2px rgba(32,33,36,.04);
}
.image-field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.image-field-head .field-label { margin-bottom: 0; }
.required-note {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin: 0 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.optional-note {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin: 0 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f1f3f4;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.image-clear-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.image-clear-all:hover { text-decoration: underline; }
.solution-image-toggle { display: none; }
.solution-image-content { display: block; }
.dropzone {
  position: relative;
  border: 0;
  border-radius: 14px;
  padding: 0;
  text-align: center;
  background: transparent;
  color: var(--text-secondary);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  touch-action: manipulation;
}
.dropzone:hover, .dropzone.dragover { background: transparent; box-shadow: none; }
.dropzone:not(.has-image) .dropzone-select {
  border: 1.5px dashed #a9c7f5;
  background: linear-gradient(145deg, #fff 0%, #f5f9ff 100%);
}
.dropzone:not(.has-image):hover .dropzone-select,
.dropzone:not(.has-image).dragover .dropzone-select { border-color: var(--primary); background: #f2f7ff; box-shadow: 0 0 0 3px rgba(26,115,232,.08); }
.dropzone.has-image { border: 0; background: transparent; }
.dropzone-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 112px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.dropzone-select:hover:not(:disabled) { background: #f8fbff; }
.dropzone-select:focus-visible, .dropzone-preview-open:focus-visible, .dropzone-add-card:focus-visible, .image-rotate-btn:focus-visible, .image-remove-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dropzone-select:disabled { cursor: default; }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); }
.dropzone-icon.muted { background: #f1f3f4; color: var(--text-muted); }
.dropzone-icon i { font-size: var(--fs-hero); }
.dropzone-label { display: block; font-size: var(--fs-text); font-weight: 500; color: #3c4043; overflow-wrap: anywhere; }
.dropzone-hint { display: block; font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 2px; min-height: 1em; }
.dropzone-format { display: block; margin-top: 5px; color: var(--text-muted); font-size: var(--fs-xs); }
.dropzone.has-image .dropzone-select {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  padding: 6px 8px;
  text-align: left;
}
.dropzone.has-image .dropzone-icon { display: none; }
.dropzone.has-image .dropzone-label { grid-column: 1; grid-row: 1; }
.dropzone.has-image .dropzone-hint { grid-column: 1; grid-row: 2; margin: 0; }
.dropzone.has-image .dropzone-format { grid-column: 2; grid-row: 1 / 3; margin: 0 0 0 8px; text-align: right; }
.dropzone-previews {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  padding: 4px 2px 8px;
  margin-top: 0;
  text-align: left;
  scrollbar-width: thin;
}
.dropzone-preview-card {
  position: relative;
  flex: 0 0 156px;
  min-width: 156px;
  padding: 6px;
  border: 1px solid var(--border-light);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(32,33,36,.08);
  scroll-snap-align: start;
  transition: border-color .18s, box-shadow .18s, transform .18s, opacity .18s;
}
.dropzone-preview-card[draggable="true"] { cursor: grab; }
.dropzone-preview-card[draggable="true"]:active { cursor: grabbing; }
.dropzone-preview-card.dragging { opacity: .48; border-color: var(--primary); }
.dropzone-preview-card.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,.14); }
.dropzone-preview-card.is-error { border-color: #f5b7b1; background: #fff8f7; }
.dropzone-add-card {
  flex: 0 0 156px;
  min-width: 156px;
  min-height: 178px;
  padding: 8px;
  border: 1px dashed #9fc0f2;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff 0%, #f5f9ff 100%);
  color: var(--primary);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: start;
}
.dropzone-add-card:hover { background: #eef5ff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.08); }
.dropzone-add-card i { display: block; font-size: var(--fs-hero); margin-bottom: 7px; }
.dropzone-preview-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.dropzone-preview-media { position: relative; }
.dropzone-preview {
  display: block;
  width: 100%;
  height: 104px;
  border-radius: 9px;
  object-fit: contain;
  background: #eef2f7;
}
.dropzone-preview-placeholder {
  display: grid;
  place-items: center;
  height: 104px;
  border-radius: 9px;
  background: #f1f3f4;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
}
.dropzone-preview-placeholder i { display: block; margin-bottom: 4px; font-size: var(--fs-lg); }
.dropzone-preview-error { display: grid; place-items: center; min-height: 104px; padding: 12px 8px; color: var(--danger); font-size: var(--fs-xs); line-height: 1.45; text-align: center; }
.dropzone-preview-meta { display: block; min-height: 1.35em; margin-top: 5px; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.35; text-align: center; font-variant-numeric: tabular-nums; }
.dropzone-preview-order {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(32,33,36,.78);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.dropzone-preview-actions { display: flex; justify-content: center; gap: 6px; margin-top: 5px; }
.image-order-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  cursor: pointer;
}
.image-order-btn:hover:not(:disabled) { border-color: #9fc0f2; color: var(--primary); background: #f8fbff; }
.image-order-btn:disabled { opacity: .38; cursor: default; }
.image-rotate-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 14px;
  background: rgba(20,30,48,.76);
  box-shadow: 0 5px 16px rgba(15,23,42,.28), inset 0 1px 0 rgba(255,255,255,.16);
  color: #fff;
  font-size: var(--fs-xl);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.image-rotate-btn:hover {
  transform: translateY(-1px);
  background: rgba(26,115,232,.9);
  box-shadow: 0 7px 18px rgba(26,115,232,.3), inset 0 1px 0 rgba(255,255,255,.2);
}
.image-rotate-btn:active { transform: scale(.94); }
.image-rotate-btn i { transition: transform .24s ease; }
.image-rotate-btn:hover i { transform: rotate(24deg); }
.image-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  box-shadow: 0 1px 4px rgba(32,33,36,.24);
  color: var(--danger);
  font-size: var(--fs-lg);
  cursor: pointer;
}
.image-remove-btn:hover { background: #fff3f1; }
.image-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 5px;
  border: 1px solid #9fc0f2;
  border-radius: 10px;
  background: #f8fbff;
  color: var(--primary);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.dropzone-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.pick-btn {
  width: min(100%, 240px);
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: #3c4043;
  font: inherit;
  font-size: var(--fs-text);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.pick-btn i { font-size: var(--fs-lg); color: var(--primary); }
.pick-btn:active { background: #f1f3f4; }
.pick-btn:disabled { opacity: .45; cursor: default; }

/* ---------- chips & actions ---------- */
#searchScreen.search-locked-state .mode-toggle,
#searchScreen.search-locked-state .panel:not(.hidden),
#searchScreen.search-locked-state .search-mode-row,
#searchScreen.search-locked-state .toolbar {
  opacity: 0.52;
  filter: grayscale(0.12);
  transition: opacity 0.2s ease, filter 0.2s ease;
}
#searchScreen.search-locked-state.guest-mode #imagePanel { opacity: 1; filter: none; }
#searchScreen.search-locked-state .search-mode-row > .field-label::after {
  content: "要ログイン";
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff8e6;
  color: #8a4b00;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.search-mode-row { margin-bottom: 12px; }
.search-mode-row .field-label { display: block; margin-bottom: 7px; }
.action-row { margin: 16px 0 20px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; }
.search-action-bar { margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(232, 234, 237, 0.62);
}
.chip-group-label {
  padding: 0 4px 0 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.chip-group-options { gap: 4px; }
.chip {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-text);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #3c4043;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
.chip-group .chip {
  min-height: 34px;
  padding: 0 12px;
  background: var(--surface);
}
.chip.on { background: var(--primary-soft); color: var(--primary-soft-text); border-color: transparent; font-weight: 500; }
.primary-btn, .secondary-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
}
.primary-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  font-size: var(--fs-md);
  font-weight: 500;
  min-height: 50px;
  padding: 0 24px;
  box-shadow: var(--shadow-1);
}
.primary-btn:hover:not(:disabled) { background: var(--primary-dark); }
.primary-btn:disabled { cursor: wait; }
.primary-btn.search-locked {
  background: #e8eaed;
  color: #80868b;
  box-shadow: none;
  cursor: not-allowed;
}
.primary-btn.search-locked i { color: #9aa0a6; }
.primary-btn.search-locked:hover { background: #e8eaed; }
.primary-btn.search-trial {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(52,168,83,0.24);
}
.primary-btn.search-trial:hover:not(:disabled) { background: var(--green-text); }
.primary-btn.searching { cursor: wait; }
.secondary-btn {
  width: 100%;
  background: #eef1f4;
  color: #3c4043;
  font-size: var(--fs-base);
  min-height: var(--tap);
  padding: 0 16px;
}

/* ---------- corpus tab panel ---------- */
.corpus-intro {
  margin: 0 0 14px;
  font-size: var(--fs-text);
  line-height: 1.55;
  color: var(--green-text);
  background: var(--green-soft);
  border-radius: var(--radius-s);
  padding: 10px 12px;
}
.corpus-intro strong { font-weight: 600; }
#corpusPanel .picker-row { display: grid; gap: 12px; margin-bottom: 0; }
#corpusPanel .picker-row input,
#corpusPanel .picker-row select {
  font: inherit;
  font-size: var(--fs-md);
  padding: 10px 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
}
#corpusPanel .picker-row select {
  min-height: 180px;
}

/* ---------- results ---------- */
.results-header { display: flex; align-items: baseline; gap: 8px; margin: 20px 0 12px; flex-wrap: wrap; }
.results-title { font-size: var(--fs-md); font-weight: 700; flex: 1 1 auto; min-width: 0; }
.results-count, .results-sort { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.results-sort { margin-left: auto; }
.search-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  border-radius: var(--radius-s);
  padding: 11px 14px;
  font-size: var(--fs-base);
  margin-bottom: 12px;
}
.search-progress i { font-size: var(--fs-lg); flex: none; }
.progress-elapsed { margin-left: auto; font-size: var(--fs-sm); color: var(--primary); font-variant-numeric: tabular-nums; }
.search-progress.progress-enter { animation: progressEnter 0.22s ease-out; }
@keyframes progressEnter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
#progressStage.stage-fade, #progressElapsed.stage-fade { animation: stageFade 0.22s ease-out; }
@keyframes stageFade {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}
.result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-l);
  padding: 14px 12px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  touch-action: manipulation;
  box-sizing: border-box;
  box-shadow: var(--shadow-1);
}
.result-card:active { transform: scale(0.99); background: #f8f9fa; }
.result-card:hover { box-shadow: var(--shadow-2); border-color: transparent; transform: translateY(-1px); }
.result-card.card-enter { animation: cardIn 0.28s ease-out both; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.result-card > .ti-chevron-right { color: var(--text-muted); }
.sim-ring { position: relative; width: 48px; height: 48px; flex: none; display: flex; align-items: center; justify-content: center; font-size: var(--fs-base); font-weight: 500; color: var(--primary); }
.sim-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.result-main { flex: 1; min-width: 0; }
.result-title { font-size: var(--fs-md); font-weight: 500; }
.result-qno { font-size: var(--fs-text); color: var(--text-secondary); margin-left: 8px; font-weight: 400; }
.tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: var(--fs-sm); padding: 2px 10px; border-radius: 6px; line-height: 1.7; font-variant-numeric: tabular-nums; }
.tag.blue { background: var(--primary-soft); color: var(--primary-soft-text); }
.tag.gray { background: #f1f3f4; color: var(--text-secondary); }
.skeleton .bar { height: 88px; border: 1px solid var(--border-light); border-radius: var(--radius-l); margin-bottom: 10px; background: linear-gradient(100deg, #eceff2 40%, #f7f9fa 50%, #eceff2 60%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.result-skeleton-card { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 12px; padding: 14px 12px; box-sizing: border-box; }
.result-skeleton-badge { width: 44px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.62); }
.result-skeleton-copy { display: grid; gap: 12px; min-width: 0; }
.result-skeleton-title { width: min(72%, 360px); height: 13px; border-radius: 999px; background: rgba(255,255,255,.68); }
.result-skeleton-tags { display: flex; gap: 7px; }
.result-skeleton-tags span { width: 64px; height: 18px; border-radius: 6px; background: rgba(255,255,255,.58); }
.result-skeleton-tags span:nth-child(2) { width: 88px; }
.result-skeleton-tags span:nth-child(3) { width: 52px; }
.notice, .error { font-size: var(--fs-sm); color: var(--text-muted); margin: 16px 4px 2px; }
.error {
  color: var(--error);
  background: #fce8e6;
  border-radius: var(--radius-s);
  padding: 10px 12px;
  font-size: var(--fs-text);
  margin: 0 0 12px;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- detail ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 10px;
  margin-bottom: 18px;
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-base);
  color: var(--text-secondary);
  touch-action: manipulation;
  min-height: var(--tap);
}
.back-btn:hover { background: #eceff2; }
.detail-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-bottom: 22px; }
.detail-heading-copy { min-width: 0; }
.detail-head h2 { margin: 0; font-size: var(--fs-xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); word-break: break-word; overflow-wrap: anywhere; font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-l); padding: 15px 17px; box-shadow: var(--shadow-1); }
.card.warn { background: var(--warn-bg); border-color: transparent; }
.card-title { font-size: var(--fs-text); font-weight: 500; color: var(--primary); margin-bottom: 6px; }
.card-title.warn { color: var(--warn-text); }
.section-title { font-size: var(--fs-md); font-weight: 700; margin: 22px 2px 14px; }
.steps { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-l); padding: 16px; box-shadow: var(--shadow-1); }
.step { display: flex; gap: 16px; margin-bottom: 12px; }
.step:last-child { margin-bottom: 0; }
.step-no { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: var(--fs-text); font-weight: 500; flex: none; }
.step-action { font-size: var(--fs-base); font-weight: 500; }
.step-purpose { font-size: var(--fs-text); color: var(--text-secondary); }
.card .katex-display { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.card, .step-action, .step-purpose { overflow-wrap: anywhere; word-break: break-word; }
.detail-footer { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); color: var(--text-muted); border-top: 1px solid var(--border-light); padding-top: 14px; margin-top: 16px; flex-wrap: wrap; }
#detailSimilarBtn { width: fit-content; min-height: 48px; margin-top: 12px; padding: 0 22px; background: var(--primary); border: 0; color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(26, 115, 232, .22); transition: background .16s ease, box-shadow .16s ease, transform .16s ease; }
#detailSimilarBtn:hover { background: var(--primary-dark); box-shadow: 0 5px 14px rgba(26, 115, 232, .28); transform: translateY(-1px); }
#detailSimilarBtn i { font-size: var(--fs-lg); }
.feedback-panel { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; margin-left: auto; }
.feedback-actions { display: flex; align-items: center; gap: 5px; }
.feedback-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid #dce2e8; border-radius: 50%; background: rgba(255, 255, 255, .7); color: #84909e; opacity: 1; font: inherit; cursor: pointer; box-shadow: 0 1px 2px rgba(60, 64, 67, .06); transition: color 90ms ease-out, border-color 90ms ease-out, background 90ms ease-out, box-shadow 90ms ease-out, transform 70ms ease-out; }
.feedback-btn:hover { color: #536477; border-color: #b8c3cf; background: #fff; box-shadow: 0 2px 5px rgba(60, 64, 67, .1); transform: translateY(-1px); }
.feedback-btn:active { transform: scale(.92); }
.feedback-btn[aria-pressed="true"] { border-color: #8ab4e8; background: var(--primary-soft); color: var(--primary-soft-text); box-shadow: 0 1px 4px rgba(26, 115, 232, .14); }
#feedbackUnhelpful[aria-pressed="true"] { border-color: #e7a29d; background: #fce8e6; color: #c5221f; box-shadow: 0 1px 4px rgba(217, 48, 37, .14); }
.feedback-btn:disabled { cursor: wait; opacity: 1; }
.feedback-btn i { font-size: var(--fs-lg); }
.feedback-error { flex-basis: 100%; margin: 7px 0 0; color: var(--danger, #b42318); font-size: var(--fs-sm); text-align: right; }

@media (max-width: 480px) {
  .detail-head { align-items: start; }
  .detail-head .detail-actions { grid-column: 2 / -1; justify-self: end; margin-top: 4px; }
}

/* ---------- screen transition ---------- */
.screen-enter { animation: screenIn 0.22s ease-out; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen-enter { animation: none; }
}

/* ---------- desktop ---------- */
@media (min-width: 641px) {
  .mode-btn {
    font-size: var(--fs-text);
    padding: 0 8px;
  }
  .mode-btn i { font-size: var(--fs-lg); }
  .field-block { flex: 1; min-width: 240px; }
  .action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0 26px;
  }
  .toolbar { flex: 1 1 auto; }
  .search-action-bar { flex: 0 0 auto; }
  .primary-btn { width: auto; font-size: var(--fs-base); min-height: 44px; }
  .secondary-btn { width: auto; font-size: var(--fs-text); }
  .dropzone:not(.has-image) .dropzone-hint::after { content: "／ドラッグ＆ドロップ対応"; }
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .page { padding-top: 8px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .topbar { gap: 10px; margin-bottom: 12px; }
  .subtitle { display: none; }
  .account-chip { max-width: 46vw; }
  .mode-toggle { margin-bottom: 16px; }
  .mode-btn { font-size: var(--fs-xs); padding: 0 4px; gap: 4px; }
  .mode-from { display: none; }
  .mode-btn i { font-size: var(--fs-lg); }
  .image-input-grid { display: block; }
  .image-field-block + .image-field-block { margin-top: 12px; }
  .solution-image-content { display: block; }
  .solution-field-label { display: flex; }
  .dropzone { padding: 10px; }
  .dropzone-actions { flex-direction: row; }
  .pick-btn { max-width: none; }
  .pick-btn-camera { min-height: 48px; border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 600; }
  .pick-btn-camera i { color: #fff; }
  .pick-btn-camera:active { background: var(--primary-dark); }
  .search-mode-row .chips { gap: 6px; }
  .search-mode-row .chip { font-size: var(--fs-text); padding: 0 12px; }
  .chip-group {
    width: 100%;
    justify-content: space-between;
    border-radius: var(--radius-s);
    padding: 6px;
  }
  .chip-group-options { justify-content: flex-end; }
  .chip-group .chip { flex: 0 0 auto; }
  .results-sort { display: none; }
  .result-title { font-size: var(--fs-base); }
  .result-qno { display: block; margin-left: 0; margin-top: 2px; }
  .sim-ring { width: 44px; height: 44px; font-size: var(--fs-text); }
  .sim-ring svg { width: 44px; height: 44px; }
  .detail-grid { grid-template-columns: 1fr; }
  .notice { font-size: var(--fs-xs); line-height: 1.6; }
  .login-banner { flex-wrap: wrap; }
  .login-banner-copy { flex: 1 1 60%; }
  .banner-login-btn { margin-left: auto; }
  .search-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 0 0 16px;
    width: 100%;
    padding: 10px 4px calc(10px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    background: var(--bg);
  }
  .search-action-bar .primary-btn {
    width: 100%;
    box-shadow: 0 2px 8px rgba(26,115,232,0.28);
    min-height: 50px;
    font-size: var(--fs-md);
  }
  .search-action-bar .primary-btn.search-locked {
    box-shadow: none;
  }
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

@media (max-width: 380px) {
  .mode-label { display: none; }
}

/* ---------- UX redesign ---------- */
body {
  min-height: 100vh;
  background: var(--bg);
}
.page { max-width: 960px; padding-top: 14px; }
.brand-link { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
main { display: block; }
.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  box-sizing: border-box;
  width: 100%;
  max-width: 800px;
  margin: 20px auto 16px;
  text-align: left;
}
.eyebrow { display: inline-block; color: var(--primary-soft-text); font-size: var(--fs-sm); font-weight: 700; letter-spacing: var(--tracking-label); }
.hero-copy h1 { margin: 0; color: var(--text); font-size: var(--fs-xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); overflow-wrap: anywhere; }
.results-hero h1, .detail-head h1 { margin: 8px 0 8px; color: var(--text); font-size: var(--fs-hero); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); overflow-wrap: anywhere; }
.hero-copy .eyebrow { color: var(--text-muted); font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }
@media (min-width: 701px) {
  .hero-copy {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
  }
  .hero-copy .eyebrow { flex: 0 1 auto; text-align: right; }
}
.search-card { max-width: 800px; margin: 0 auto; padding: 24px; border: 1px solid rgba(221,225,230,.88); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 12px 36px rgba(60,64,67,.10); }
.mode-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.mode-heading h2 { margin: 2px 0 0; font-size: var(--fs-lg); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); }
.step-label { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; letter-spacing: var(--tracking-label); }
.trial-note { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-text); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.mode-toggle { border: 1px solid var(--border-light); background: #edf1f4; margin-bottom: 20px; }
.mode-btn { font-size: var(--fs-text); }
.panel { min-height: 160px; }
.panel-intro { display: grid; gap: 2px; margin-bottom: 16px; padding: 11px 13px; border-radius: var(--radius-s); background: #f7f9fb; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.55; }
.panel-intro strong { color: var(--text); font-size: var(--fs-base); }
.panel-intro.trial { background: var(--green-soft); }
.panel-intro.trial strong { color: var(--green-text); }
.optional { display: inline-flex; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: #f1f3f4; font-size: var(--fs-xs); }
#searchScreen.search-locked-state .mode-toggle,
#searchScreen.search-locked-state .panel:not(.hidden),
#searchScreen.search-locked-state .search-mode-row,
#searchScreen.search-locked-state .toolbar { opacity: 1; filter: none; }
#searchScreen.search-locked-state .search-mode-row > .field-label::after { display: none; content: none; }
.primary-btn.search-locked { background: var(--primary); color: #fff; box-shadow: var(--shadow-1); cursor: pointer; }
.primary-btn.search-locked i { color: inherit; }
.primary-btn.search-locked:hover { background: var(--primary-dark); }
.primary-btn:disabled { cursor: not-allowed; opacity: .58; }
.search-action-bar { display: grid; justify-items: stretch; width: 100%; gap: 7px; }
.action-row { margin: 20px 0 0; }
.action-hint { color: var(--text-muted); font-size: var(--fs-sm); text-align: center; }

.advanced-options { margin-top: 18px; border: 1px solid var(--border-light); border-radius: var(--radius-m); background: #fbfcfd; overflow: hidden; }
.advanced-options.corpus-advanced-options { margin-top: 12px; }
.advanced-options summary { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 14px; color: var(--text-secondary); font-size: var(--fs-text); font-weight: 500; cursor: pointer; list-style: none; }
.advanced-options summary::-webkit-details-marker { display: none; }
.advanced-options summary::after { content: "＋"; margin-left: auto; color: var(--text-muted); font-size: var(--fs-lg); font-weight: 400; }
.advanced-options[open] summary::after { content: "−"; }
.advanced-options summary i { color: var(--primary); font-size: var(--fs-lg); }
.advanced-body { display: grid; gap: 14px; padding: 14px; border-top: 1px solid var(--border-light); }
.advanced-body .search-mode-row { margin: 0; }
.university-filter-field { min-width: 0; gap: 7px; }
.select-wrap { position: relative; display: flex; align-items: center; width: min(100%, 360px); min-width: 0; max-width: 100%; }
.select-wrap > i:first-child { position: absolute; left: 13px; z-index: 1; color: var(--primary); font-size: var(--fs-lg); pointer-events: none; }
.select-wrap > i:last-child { position: absolute; right: 13px; color: var(--text-muted); font-size: var(--fs-lg); pointer-events: none; }
.select-wrap select { width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 0 42px; appearance: none; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base); cursor: pointer; }
.select-wrap select:hover { border-color: #a9c5ee; background: #fbfdff; }
.select-wrap select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.14); outline: none; }
.option-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-soft-text); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

.corpus-search-field { margin-bottom: 12px; }
.corpus-filter-grid { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 12px; align-items: start; margin-bottom: 12px; }
.corpus-filter-grid > .field-block { width: 100%; min-width: 0; }
.corpus-filter-grid .corpus-search-field { margin-bottom: 0; }
.corpus-year-field select { display: block; width: 100%; max-width: 100%; min-height: 48px; box-sizing: border-box; padding: 0 38px 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md); cursor: pointer; }
.corpus-year-field select:hover { border-color: #a9c5ee; background: #fbfdff; }
.corpus-year-field select:focus,
.corpus-year-field select:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.14);
  outline: none;
}
.search-input-wrap { position: relative; display: block; }
.search-input-wrap i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: var(--fs-lg); pointer-events: none; }
.search-input-wrap input { width: 100%; min-height: 48px; box-sizing: border-box; padding: 0 14px 0 42px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md); }
.field-help { display: block; margin: 6px 2px 0; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.5; }
.corpus-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.corpus-option { position: relative; display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 11px 42px 11px 13px; box-sizing: border-box; border: 1px solid var(--border-light); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color .18s, background .18s, box-shadow .18s; }
.corpus-option:hover { border-color: #b8cdf2; background: #fbfdff; }
.corpus-option.selected { border-color: #8ab4f8; background: var(--primary-soft); box-shadow: inset 0 0 0 1px #8ab4f8; }
.corpus-option input { position: absolute; opacity: 0; pointer-events: none; }
.corpus-option-body { display: grid; min-width: 0; line-height: 1.45; }
.corpus-option-body strong { overflow: hidden; color: var(--text); font-size: var(--fs-base); text-overflow: ellipsis; white-space: nowrap; }
.corpus-option-body span { color: var(--text-secondary); font-size: var(--fs-sm); }
.corpus-option-check { position: absolute; right: 13px; color: transparent; font-size: var(--fs-xl); }
.corpus-option.selected .corpus-option-check { color: var(--primary); }
.corpus-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; border-radius: 12px; background: #f7f9fb; color: var(--text-secondary); text-align: center; font-size: var(--fs-text); }
.corpus-more { margin: 9px 2px 0; color: var(--text-muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.corpus-selected { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 13px; border: 1px solid #b7d6f7; border-radius: 11px; background: var(--primary-soft); }
.corpus-selected-copy { display: grid; gap: 3px; min-width: 0; }
.corpus-selected-copy small { color: var(--primary-soft-text); font-size: var(--fs-xs); font-weight: 700; }
.corpus-selected-copy strong { color: var(--text); font-size: var(--fs-base); line-height: 1.45; overflow-wrap: anywhere; }
.corpus-change-btn { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 5px; min-height: 40px; padding: 0 11px; border: 1px solid #8ab4f8; border-radius: 8px; background: var(--surface); color: var(--primary-soft-text); font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer; }
.corpus-change-btn:hover { background: #f8fbff; }
.corpus-analysis { display: grid; gap: 14px; margin-top: 16px; padding: 16px; border: 1px solid #b7d6f7; border-radius: 14px; background: #f8fbff; overflow: hidden; }
.corpus-analysis:focus { outline: none; }
.corpus-analysis-head { display: grid; gap: 4px; min-width: 0; }
.corpus-analysis-head > span { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-soft-text); font-size: var(--fs-sm); font-weight: 700; }
.corpus-analysis-head > strong { color: var(--text); font-size: var(--fs-md); line-height: 1.5; overflow-wrap: anywhere; }
.corpus-analysis-status { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 86px; color: var(--text-secondary); font-size: var(--fs-text); text-align: center; }
.corpus-analysis-status.error { flex-direction: column; color: var(--danger); }
.corpus-analysis-status .corpus-analysis-retry { min-height: 40px; }
.corpus-analysis-summary { margin: 0; }
.corpus-search-scope { min-width: 0; margin: 0; padding: 0; border: 0; }
.corpus-search-scope legend, .corpus-search-scope h3 { margin: 0; padding: 0; color: var(--text); font-size: var(--fs-md); font-weight: 700; }
.corpus-chart-links h3 { display: flex; align-items: center; gap: 6px; }
.corpus-chart-links h3 i { color: var(--primary); font-size: var(--fs-lg); }
.corpus-search-scope-help { margin: 5px 0 10px; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.6; }
.corpus-scope-list { display: grid; gap: 8px; }
.corpus-chart-flow { display: block; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.corpus-scope-list.scrollable { max-height: min(320px, 42vh); padding-right: 4px; overflow-y: auto; overscroll-behavior: auto; scrollbar-gutter: stable; }
.corpus-scope-option { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) 22px; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 66px; padding: 10px 11px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .18s, background .18s, box-shadow .18s; }
.corpus-scope-option:hover { border-color: #9fc0f2; background: #fff; }
.corpus-scope-option.selected { border-color: #8ab4f8; background: var(--primary-soft); box-shadow: inset 0 0 0 1px #8ab4f8; }
.corpus-scope-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.corpus-scope-no { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: #eef1f4; color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 700; }
.corpus-scope-option.selected .corpus-scope-no { background: #d2e3fc; color: var(--primary-soft-text); }
.corpus-scope-main { display: grid; gap: 3px; min-width: 0; }
.corpus-scope-main strong { color: var(--text); font-size: var(--fs-text); line-height: 1.5; overflow-wrap: anywhere; }
.corpus-scope-main span { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.corpus-scope-check { color: transparent; font-size: var(--fs-xl); }
.corpus-scope-option.selected .corpus-scope-check { color: var(--primary); }
.corpus-chart-step { position: relative; min-width: 0; margin: 0; padding: 14px 16px; box-sizing: border-box; list-style: none; background: transparent; color: var(--text); cursor: default; }
.corpus-chart-step:not(:last-child) { border-bottom: 1px solid var(--border-light); }
.corpus-chart-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 30px;
  top: 29px;
  bottom: -30px;
  z-index: 0;
  width: 2px;
  border-radius: 999px;
  background: #8ab4f8;
}
.corpus-chart-step .corpus-scope-no {
  position: relative;
  z-index: 1;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--surface);
}
.corpus-chart-step-main { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: start; gap: 10px; min-width: 0; }
.corpus-chart-step-content { display: grid; gap: 10px; min-width: 0; }
.corpus-chart-step-copy { display: grid; gap: 6px; min-width: 0; }
.corpus-chart-step-copy strong { color: var(--text); font-size: var(--fs-base); line-height: 1.55; overflow-wrap: anywhere; }
.corpus-chart-purpose { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 7px; min-width: 0; }
.corpus-chart-purpose-label { display: inline-flex; align-items: center; justify-content: center; min-height: 20px; padding: 1px 6px; box-sizing: border-box; border-radius: 999px; background: #eef1f4; color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 700; line-height: 1.4; }
.corpus-chart-purpose-text { min-width: 0; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.55; overflow-wrap: anywhere; }
.corpus-chart-match { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; min-width: 0; padding: 8px 10px; border: 1px solid #d3e2f7; border-radius: 8px; background: #f5f9ff; }
.corpus-chart-match-label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.corpus-chart-match-label i { color: var(--primary); font-size: var(--fs-base); }
.corpus-chart-step .corpus-chart-example { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; min-height: 30px; padding: 4px 9px; box-sizing: border-box; border: 1px solid #aac8f3; border-radius: 999px; background: var(--surface); color: var(--primary-soft-text); font-size: var(--fs-text); font-weight: 800; line-height: 1.45; overflow-wrap: anywhere; }
.corpus-chart-step .corpus-chart-example i { flex: none; color: var(--primary); font-size: var(--fs-md); }
.corpus-chart-example-copy { display: grid; min-width: 0; gap: 1px; }
.corpus-chart-example-copy small { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; line-height: 1.35; }
.corpus-chart-match.unavailable { border-style: dashed; border-color: var(--border); background: #fafbfc; }
.corpus-chart-match.unavailable .corpus-chart-example { border: 0; background: transparent; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.corpus-flow-empty { margin: 0; padding: 18px 16px; list-style: none; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; text-align: center; }
.nearby-search-action { display: grid; gap: 7px; width: 100%; }
.nearby-search-action .primary-btn { width: 100%; min-height: 50px; }
.solution-analysis-details, .corpus-chart-details { border: 1px solid var(--border); border-radius: 9px; background: var(--surface); overflow: hidden; }
.solution-analysis-heading { display: flex; align-items: center; min-height: 46px; margin: 0; padding: 0 13px; color: var(--text-secondary); font-size: var(--fs-text); font-weight: 700; }
.solution-analysis-heading span { display: inline-flex; align-items: center; gap: 6px; }
.solution-analysis-heading i { color: var(--primary); font-size: var(--fs-lg); }
.solution-analysis-details summary, .corpus-chart-details summary { display: flex; align-items: center; min-height: 46px; padding: 0 13px; color: var(--text-secondary); font-size: var(--fs-text); font-weight: 700; cursor: pointer; list-style: none; }
.solution-analysis-details summary::-webkit-details-marker, .corpus-chart-details summary::-webkit-details-marker { display: none; }
.solution-analysis-details summary span, .corpus-chart-details summary span { display: inline-flex; align-items: center; gap: 6px; }
.solution-analysis-details summary i, .corpus-chart-details summary i { color: var(--primary); font-size: var(--fs-lg); }
.solution-analysis-details summary::after, .corpus-chart-details summary::after { content: "＋"; margin-left: auto; color: var(--text-muted); font-size: var(--fs-lg); font-weight: 400; }
.solution-analysis-details[open] summary::after, .corpus-chart-details[open] summary::after { content: "−"; }
.solution-analysis-details-body, .corpus-chart-details-body { padding: 13px; border-top: 1px solid var(--border-light); }
.corpus-chart-details-body .corpus-search-scope-help { margin-top: 0; }

#resultsView { max-width: 880px; margin: 20px auto 0; }
.results-hero { margin: 2px 0 22px; padding: 20px 22px; border: 1px solid var(--border-light); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1); }
.results-hero h1 { margin-top: 4px; font-size: var(--fs-hero); }
.results-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.results-hero-actions { display: inline-flex; align-items: center; gap: 8px; }
.results-share-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-secondary); font: inherit; font-size: var(--fs-text); font-weight: 600; cursor: pointer; }
.results-share-btn i { color: var(--primary); font-size: var(--fs-lg); }
.results-share-btn:hover { border-color: #b8cdf2; background: #f8fbff; color: var(--primary-soft-text); }
.results-share-btn:disabled { opacity: .55; cursor: wait; }
.results-query-label { margin: 0; color: var(--text-secondary); font-size: var(--fs-base); line-height: 1.65; overflow-wrap: anywhere; }
.results-query-content { min-width: 0; }
.results-query-label.is-description { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; background: var(--bg); overflow: hidden; }
.results-query-label.is-description .results-query-content { display: grid; gap: 10px; padding: 11px 12px; }
.results-query-row { display: grid; grid-template-columns: 126px minmax(0, 1fr); align-items: start; gap: 10px; min-width: 0; }
.results-query-key { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; }
.results-query-key i { color: var(--primary); font-size: var(--fs-base); }
.results-query-value { min-width: 0; margin: 0; color: var(--text); font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.results-query-condition { justify-self: start; max-width: 100%; min-height: 28px; padding: 3px 10px; color: var(--primary-soft-text); font-size: var(--fs-sm); line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.results-interpret-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border-light); background: var(--surface); }
.results-interpret-copy { display: grid; gap: 1px; min-width: 0; }
.results-interpret-copy strong { color: var(--text); font-size: var(--fs-sm); line-height: 1.4; }
.results-interpret-copy small { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.45; }
.results-interpret-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-height: 40px; padding: 0 12px; border: 1px solid var(--primary); border-radius: 9px; background: var(--primary-soft); color: var(--primary-soft-text); font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer; }
.results-interpret-btn i { color: var(--primary); font-size: var(--fs-md); }
.results-interpret-btn:hover { background: color-mix(in srgb, var(--primary-soft) 72%, var(--surface)); }

#interpretView {
  width: 100%;
  max-width: 720px;
  min-width: 0;
  margin: 20px auto 0;
}
#interpretView,
#interpretView *,
#interpretView *::before,
#interpretView *::after { box-sizing: border-box; }
#interpretView > *,
#interpretChoiceRegion,
#interpretChoiceContent { min-width: 0; }
#interpretChoiceContent { overflow-x: clip; }
#interpretView .back-btn { margin-bottom: 8px; }

.interpret-hero { margin: 2px 0 12px; padding: 0 2px; }
.interpret-stepper { display: flex; align-items: center; gap: 8px; min-height: 24px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; }
.interpret-stepper-dots { display: inline-flex; align-items: center; gap: 6px; }
.interpret-step-dot { width: 8px; height: 8px; border: 1.5px solid var(--border); border-radius: 50%; background: transparent; transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease; }
.interpret-step-dot.is-complete,
.interpret-step-dot.is-active { border-color: var(--primary); background: var(--primary); }
.interpret-step-dot.is-active { box-shadow: 0 0 0 3px var(--primary-soft); }
.interpret-stepper-label { color: var(--primary-soft-text); }
.interpret-stepper-count { margin-left: -3px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.interpret-hero h1 { margin: 3px 0 5px; font-size: var(--fs-lg); line-height: 1.4; }
.interpret-lead { margin: 0 0 10px; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.55; }
.interpret-keyboard-hint { display: none; }
.interpret-base {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  background: var(--surface);
}
.interpret-base-label { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; line-height: 1.4; }
.interpret-base-label i { font-size: var(--fs-text); color: var(--primary); }
.interpret-base-text { margin: 0; color: var(--text); font-size: var(--fs-text); font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.interpret-clues { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin: 1px 0 0; }
.interpret-clues-label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; line-height: 1.4; }
.interpret-clue {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.interpret-selected-label { margin: 7px 0 0; color: var(--primary-soft-text); font-size: var(--fs-sm); font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }

.interpret-add-label { display: flex; align-items: center; gap: 5px; margin: 0 0 7px; padding: 0 2px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; line-height: 1.4; }
.interpret-add-label i { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-soft-text); font-size: var(--fs-xs); }
.interpret-option-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-right: 6px;
  color: var(--primary-soft-text);
  font-weight: 700;
}
.interpret-options {
  width: 100%;
  min-width: 0;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.interpret-cards { display: block; width: 100%; min-width: 0; }
.interpret-option,
.interpret-card {
  width: 100%;
  min-width: 0;
  border-top: 1px solid var(--border-light);
  background: transparent;
  transition: background-color .15s ease;
}
.interpret-options > .interpret-option:first-child { border-top: 0; }
.interpret-option.selected { background: color-mix(in srgb, var(--primary-soft) 58%, transparent); box-shadow: inset 4px 0 0 var(--primary); }
.interpret-option:hover { background: color-mix(in srgb, var(--primary-soft) 38%, transparent); }
.interpret-option.selected:hover { background: color-mix(in srgb, var(--primary-soft) 68%, transparent); }
.interpret-option-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; min-width: 0; }
.interpret-option-choice {
  display: flex;
  align-items: flex-start;
  order: 1;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 10px 4px 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.interpret-option:hover .interpret-option-choice { background: transparent; }
.interpret-option-choice:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 10px; }
.interpret-option-choice:disabled,
.interpret-card-drill:disabled { opacity: .55; cursor: wait; }
.interpret-option-indicator {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.interpret-option.selected .interpret-option-indicator {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 4px var(--primary);
}
.interpret-option-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.interpret-option-label { min-width: 0; color: var(--text); font-size: var(--fs-base); font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.interpret-option.selected .interpret-option-label { color: var(--primary-soft-text); }
.interpret-option-desc { min-width: 0; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.interpret-card-difference { display: block; }
.interpret-card-drill {
  display: inline-flex;
  flex: none;
  order: 3;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  margin: 0 6px 0 0;
  padding: 0 6px 0 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--border));
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.interpret-card-drill i { font-size: var(--fs-base); color: var(--primary-soft-text); }
.interpret-card-drill:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 46%, transparent);
  color: var(--primary-soft-text);
}
.interpret-card-drill:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

@keyframes interpretSlideForward { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes interpretSlideBack { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }
#interpretOptions.interpret-slide-forward { animation: interpretSlideForward .28s cubic-bezier(.22, .61, .36, 1) both; }
#interpretOptions.interpret-slide-back { animation: interpretSlideBack .28s cubic-bezier(.22, .61, .36, 1) both; }
@media (prefers-reduced-motion: reduce) {
  #interpretOptions.interpret-slide-forward,
  #interpretOptions.interpret-slide-back { animation: none; }
}
.interpret-other { display: grid; gap: 8px; margin: 0 14px 12px 41px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--bg); }
.interpret-other textarea { width: 100%; min-height: 64px; resize: vertical; }

.interpret-confirm-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  margin: 0 0 16px;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}
.interpret-composition {
  margin: 0;
  padding: 0 2px;
  max-width: 100%;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  display: -webkit-box;
  white-space: normal;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.interpret-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}
.interpret-confirm-secondary { display: flex; flex: none; }
.interpret-confirm-secondary .secondary-btn {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-text);
  font-weight: 600;
  box-shadow: none;
}
.interpret-confirm-btn {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border-radius: 12px;
  font-size: var(--fs-base);
  font-weight: 700;
}

.interpret-status {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: 100%;
  min-height: 260px;
  margin: 0;
  padding: 26px 20px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.interpret-loading-copy { display: grid; justify-items: center; gap: 7px; max-width: 460px; }
.interpret-loading-copy strong { color: var(--text); font-size: var(--fs-base); line-height: 1.45; }
.interpret-loading-copy > span:last-child { font-size: var(--fs-sm); line-height: 1.55; overflow-wrap: anywhere; }
.interpret-loading-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.interpret-loading-icon i { font-size: var(--fs-xl); }
.interpret-loading-skeletons { display: grid; gap: 8px; width: min(100%, 560px); }
.interpret-loading-skeleton { display: flex; align-items: center; gap: 11px; height: 58px; padding: 9px 12px; border: 1px solid var(--border-light); border-radius: 10px; background: linear-gradient(90deg, var(--bg) 15%, var(--border-light) 45%, var(--bg) 75%); background-size: 220% 100%; animation: interpretSkeleton 1.25s ease-in-out infinite; }
.interpret-loading-skeleton-indicator { flex: none; width: 18px; height: 18px; border: 2px solid color-mix(in srgb, var(--surface) 75%, transparent); border-radius: 50%; background: color-mix(in srgb, var(--surface) 58%, transparent); }
.interpret-loading-skeleton-copy { display: grid; gap: 7px; width: min(80%, 360px); }
.interpret-loading-skeleton-line { display: block; width: 64%; height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 62%, transparent); }
.interpret-loading-skeleton-line.is-title { width: 88%; height: 9px; }
@keyframes interpretSkeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .interpret-loading-skeleton { animation: none; }
  .interpret-option,
  .interpret-option-choice,
  .interpret-option-indicator,
  .interpret-step-dot { transition: none; }
}


.results-filter-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.summary-chip { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; background: #f1f3f4; color: var(--text-secondary); font-size: var(--fs-xs); }
.results-header { margin-top: 18px; }
.result-card { align-items: flex-start; gap: 13px; padding: 17px 16px; }
.result-rank { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; border-radius: 9px; background: #f1f3f4; color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 700; }
.result-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.result-title { font-size: var(--fs-md); font-weight: 600; }
.sim-ring { position: static; display: grid; grid-template-columns: auto auto; align-items: baseline; width: auto; height: auto; padding: 4px 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-soft-text); line-height: 1; }
.sim-ring strong { font-size: var(--fs-base); }
.sim-ring small { margin-left: 3px; font-size: var(--fs-xs); font-weight: 500; }
.result-reason { display: grid; gap: 3px; margin-top: 10px; overflow: hidden; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.6; }
.result-reason-label { display: inline-flex; align-items: center; gap: 5px; color: var(--primary-soft-text); font-size: var(--fs-sm); line-height: 1.4; }
.result-reason-label i { color: var(--primary); font-size: var(--fs-base); }
.result-reason-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.results-guidance {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  border-radius: 4px 10px 10px 4px;
  background: var(--primary-soft);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.results-guidance > i { margin-top: 2px; color: var(--primary); font-size: var(--fs-md); }
.results-guidance strong { color: var(--primary-soft-text); }
.results-guidance.hidden { display: none; }
.result-card > .ti-chevron-right { align-self: center; }
.empty-state { display: grid; justify-items: center; padding: 46px 18px; border: 1px dashed var(--border); border-radius: 20px; background: var(--surface); text-align: center; }
.empty-state > i { color: var(--primary); font-size: var(--fs-hero); }
.empty-state h2 { margin: 12px 0 4px; font-size: var(--fs-lg); }
.empty-state p { margin: 0 0 18px; color: var(--text-secondary); font-size: var(--fs-text); }
.empty-state .secondary-btn { width: auto; }
.notice {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 4px 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  line-height: 1.55;
}
.notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
}
.notice-icon i { font-size: var(--fs-md); line-height: 1; }
.notice-copy { display: inline; min-width: 0; }
.notice-copy strong { margin-right: 5px; color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 500; }
.notice-copy > span { font-size: var(--fs-xs); }

.detail-head h1 { margin-top: 4px; font-size: var(--fs-hero); }
.detail-empty { margin: 0; color: var(--text-muted); font-size: var(--fs-text); }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, .corpus-option:has(input:focus-visible), .corpus-scope-option:has(input:focus-visible) {
  outline: 3px solid rgba(26,115,232,.32);
  outline-offset: 2px;
}
.search-input-wrap input:focus, textarea:focus, .corpus-year-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); outline: none; }

@media (min-width: 641px) {
  .search-card .input-grid { flex-wrap: nowrap; }
  .search-card .field-block { flex: 1; }
  .search-card .action-row { display: block; margin-top: 20px; }
  .search-card .primary-btn { width: 100%; min-height: 50px; }
  #resultsView .back-btn, #detailScreen .back-btn, #interpretView .back-btn { margin-left: -8px; }
  .interpret-keyboard-hint { display: flex; align-items: center; gap: 5px; margin: -3px 0 10px; color: var(--text-muted); font-size: var(--fs-xs); }
  .interpret-keyboard-hint i { margin-right: 2px; font-size: var(--fs-base); }
  .interpret-keyboard-hint kbd { padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--text-secondary); font: inherit; font-weight: 700; }
}

@media (max-width: 640px) {
  .page { padding-left: 14px; padding-right: 14px; }
  .topbar { flex-wrap: nowrap; }
  .brand-link { gap: 9px; }
  .logo { width: 36px; height: 36px; }
  .account-chip { max-width: 48vw; padding-right: 10px; }
  .hero-copy { margin: 16px auto 14px; }
  .hero-copy h1 { font-size: var(--fs-xl); }
  .login-banner { width: auto; max-width: none; margin-left: -2px; margin-right: -2px; }
  .search-card { margin: 0 -2px; padding: 18px 14px; border-radius: 20px; }
  .mode-heading { align-items: center; }
  .mode-heading h2 { font-size: var(--fs-md); }
  .trial-note { max-width: 46%; white-space: normal; text-align: center; }
  .mode-btn { gap: 3px; font-size: var(--fs-sm); }
  .mode-btn i { font-size: var(--fs-lg); }
  .panel { min-height: 0; }
  .corpus-list { grid-template-columns: 1fr; max-height: 330px; }
  .corpus-filter-grid { grid-template-columns: minmax(0, 1fr) 128px; gap: 8px; }
  .corpus-year-field select { padding-left: 10px; font-size: var(--fs-base); }
  .corpus-analysis { margin-top: 13px; padding: 13px 10px; }
  .corpus-scope-option { grid-template-columns: 32px minmax(0, 1fr) 20px; gap: 8px; min-height: 70px; padding: 10px 9px; }
  .corpus-chart-step { min-height: 0; padding: 13px 12px; }
  .corpus-chart-step:not(:last-child)::before { left: 26px; top: 28px; bottom: -29px; }
  .corpus-chart-step-main { grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
  .corpus-chart-match { align-items: flex-start; flex-direction: column; padding: 8px 9px; }
  .corpus-chart-step .corpus-chart-example { width: auto; font-size: var(--fs-text); }
  .advanced-body .chips { gap: 6px; }
  .advanced-body .chip { min-height: 38px; padding: 0 11px; font-size: var(--fs-sm); }
  .search-card .search-action-bar { position: sticky; bottom: 0; z-index: 20; margin: 0 -6px -8px; width: auto; padding: 12px 6px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface); }
  .results-hero { padding: 17px 16px; }
  .results-query-row { grid-template-columns: 1fr; gap: 4px; }
  .results-interpret-action { align-items: flex-start; flex-direction: column; }
  .results-interpret-btn { width: 100%; min-height: 44px; }
  #interpretView { margin-top: 4px; }
  #interpretView .back-btn { gap: 6px; margin-bottom: 4px; padding: 7px 10px 7px 6px; font-size: var(--fs-text); }
  .interpret-hero { margin: 0 0 10px; padding: 0 1px; }
  .interpret-hero h1 { margin: 3px 0 4px; font-size: var(--fs-md); line-height: 1.4; }
  .interpret-lead { margin-bottom: 8px; font-size: var(--fs-sm); line-height: 1.45; }
  .interpret-base { gap: 4px; padding: 8px 10px; border-radius: 9px; }
  .interpret-base-label { font-size: var(--fs-xs); }
  .interpret-base-text { font-size: var(--fs-text); line-height: 1.5; }
  .interpret-add-label { margin-bottom: 6px; font-size: var(--fs-sm); }
  .interpret-clues { gap: 4px; margin-top: 1px; }
  .interpret-clue { padding: 2px 8px; font-size: var(--fs-xs); }
  .interpret-clues-label { font-size: var(--fs-xs); }
  .interpret-selected-label { margin-top: 6px; font-size: var(--fs-sm); line-height: 1.4; }
  .interpret-options { margin-bottom: 10px; border-radius: 12px; }
  .interpret-option-choice { gap: 9px; min-height: 44px; padding: 9px 2px 9px 12px; }
  .interpret-option-label { font-size: var(--fs-text); line-height: 1.45; }
  .interpret-option-desc { font-size: var(--fs-sm); line-height: 1.45; }
  .interpret-card-drill { min-width: 44px; min-height: 44px; margin-right: 4px; padding: 0 7px; font-size: var(--fs-xs); }
  .interpret-other { gap: 6px; margin: 0 12px 10px 38px; padding: 10px; border-radius: 10px; }
  .interpret-other textarea { min-height: 60px; }
  .interpret-confirm-bar { gap: 5px; margin-bottom: 12px; padding-top: 7px; }
  .interpret-composition { font-size: var(--fs-sm); }
  .interpret-confirm-actions { gap: 8px; }
  .interpret-confirm-secondary .secondary-btn { min-height: 44px; padding: 0 11px; font-size: var(--fs-text); }
  .interpret-confirm-btn { min-height: 44px; border-radius: 11px; font-size: var(--fs-base); }
  .interpret-status { gap: 14px; min-height: 220px; padding: 20px 14px 14px; border-radius: 12px; }
  .interpret-loading-icon { width: 36px; height: 36px; }
  .interpret-loading-icon i { font-size: var(--fs-lg); }
  .interpret-loading-skeletons { gap: 7px; }
  .interpret-loading-skeleton { height: 44px; border-radius: 9px; }
  .result-card { gap: 9px; padding: 14px 11px; }
  .result-rank { width: 25px; height: 25px; border-radius: 7px; }
  .result-title { font-size: var(--fs-base); }
  .result-qno { display: inline; margin-left: 6px; }
  .result-reason { gap: 2px; font-size: var(--fs-sm); }
  .result-reason-text { -webkit-line-clamp: 3; }
  .results-sort { display: none; }
  .detail-head { gap: 11px; }
}

@media (max-width: 380px) {
  .mode-label { display: inline; }
  .mode-btn { flex-direction: column; gap: 1px; font-size: var(--fs-xs); }
  .trial-note { display: none; }
}

/* ---------- signed-in home ---------- */
.account-email {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip.quota-low { border-color: #f7cb6c; background: #fffaf0; color: #7a4b00; }
.account-chip.quota-empty { border-color: #f3b8b3; background: #fff5f4; color: #a50e0e; }
.account-chip.quota-low i, .account-chip.quota-empty i { color: inherit; }

.billing-notice { display: flex; align-items: center; gap: 10px; }
.billing-notice > span { flex: 1; min-width: 0; }
.billing-recheck {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}

.quota-notice {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 18px;
  padding: 12px 13px;
  border: 1px solid #f7cb6c;
  border-radius: 14px;
  background: #fffaf0;
  color: #7a4b00;
}
.quota-notice.exhausted { border-color: #f3b8b3; background: #fff5f4; color: #a50e0e; }
.quota-notice > i { flex: none; font-size: var(--fs-xl); }
.quota-notice-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.quota-notice-copy strong { font-size: var(--fs-text); }
.quota-notice-copy span { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.5; }
.quota-upgrade-btn {
  flex: none;
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.quota-upgrade-btn:disabled { opacity: .6; cursor: wait; }

.recent-history {
  max-width: 920px;
  margin: 22px auto 0;
  padding: 28px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow-1);
}
.recent-history-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.recent-history-head h2 { margin: 3px 0 0; font-size: var(--fs-lg); }
.text-btn {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: var(--fs-text);
  font-weight: 600;
  cursor: pointer;
}
.text-btn i { font-size: var(--fs-md); vertical-align: -2px; }
.recent-history-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

body.drawer-open { overflow: hidden; }
html { overflow-x: clip; scrollbar-gutter: stable; }
.history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  background: rgba(32,33,36,.34);
}
.history-drawer {
  width: min(430px, 100vw);
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  border-left: 1px solid var(--border-light);
  background: var(--surface);
  box-shadow: -12px 0 40px rgba(60,64,67,.18);
  outline: none;
}
.history-menu-head { flex: none; }
.history-menu-title { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.history-head-actions { display: flex; gap: 6px; }
.drawer-icon-btn, .history-delete-btn, .history-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}
.drawer-icon-btn i { font-size: var(--fs-lg); }
.history-list {
  flex: 1;
  align-content: start;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  padding: 1px 3px 8px 1px;
}
.history-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.history-card:hover { border-color: #c8daf7; }
.history-open {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 11px 6px 11px 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.history-open:hover { background: #f8fbff; }
.history-kind-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  overflow: visible;
}
.history-kind-icon i { display: block; font-size: var(--fs-xl); line-height: 1; }
.history-arrow { flex: none; color: var(--text-muted); font-size: var(--fs-md); }
.history-delete-btn { width: 36px; height: 36px; margin-right: 8px; border: 0; color: var(--text-muted); }
.history-delete-btn:hover { background: #fff1f0; color: #b3261e; }
.history-card-actions { display: flex; align-items: center; gap: 1px; padding-right: 5px; }
.history-card-actions .history-delete-btn { margin-right: 0; }
.history-share-btn { width: 36px; height: 36px; border: 0; color: var(--text-muted); }
.history-share-btn:hover { background: var(--primary-soft); color: var(--primary); }
.history-share-btn:disabled { opacity: .5; cursor: wait; }
.history-delete-confirm {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 9px 10px;
  border-top: 1px solid #f3d4d1;
  background: #fff8f7;
}
.history-delete-confirm > span { margin-right: auto; color: #8c1d18; font-size: var(--fs-sm); }
.history-cancel-btn, .history-confirm-delete-btn {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.history-cancel-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); }
.history-confirm-delete-btn { border: 1px solid #b3261e; background: #b3261e; color: #fff; }
.history-cancel-btn:disabled, .history-confirm-delete-btn:disabled { opacity: .58; cursor: wait; }
.history-error { margin: 0; padding: 9px 10px; border-radius: 10px; background: #fce8e6; color: #a50e0e; font-size: var(--fs-sm); line-height: 1.5; }
.recent-history-error { grid-column: 1 / -1; }
.history-empty { display: grid; justify-items: center; gap: 5px; border-radius: 14px; background: #f7f9fb; }
.history-empty i { color: var(--primary); font-size: var(--fs-hero); }
.history-empty strong { color: var(--text); font-size: var(--fs-text); }
.history-empty span { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; }
.history-loading {
  display: grid;
  min-height: 148px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border-radius: 14px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: var(--fs-text);
  font-weight: 600;
  text-align: center;
}
.history-loading i { color: var(--primary); font-size: var(--fs-xl); }
.recent-card { min-height: 126px; align-content: start; }
.recent-card .history-open { align-items: flex-start; min-height: 86px; }
.recent-card .history-kind-icon { width: 30px; height: 30px; }
.recent-card .history-arrow { display: none; }
.recent-card .history-card-actions { position: absolute; top: 7px; right: 5px; padding: 0; }
.recent-card .history-delete-btn { margin: 0; }
.recent-card .history-main { padding-right: 76px; }
.recent-card .history-title { white-space: normal; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.recent-card .history-meta { display: grid; gap: 2px; }
.recent-history-list > .history-empty { grid-column: 1 / -1; min-height: 110px; align-content: center; }

/* Keep drawer rows on the same rhythm, regardless of how much metadata they contain. */
.history-list .history-card { min-height: 76px; }
.history-list .history-open { height: 76px; box-sizing: border-box; }
.history-list .history-main { overflow: hidden; }
.history-list .history-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-list .history-meta > span { display: inline; }
.history-list .history-meta > span + span::before { content: " ・ "; }

@media (max-width: 760px) {
  .recent-history-list { grid-template-columns: 1fr; }
  .recent-card { min-height: 0; }
  .recent-card .history-open { min-height: 76px; }
}

@media (max-width: 640px) {
  .billing-notice { align-items: flex-start; flex-wrap: wrap; }
  .billing-recheck { margin-left: auto; }
  .quota-notice { align-items: flex-start; flex-wrap: wrap; }
  .quota-notice-copy { flex: 1 1 calc(100% - 34px); }
  .quota-upgrade-btn { margin-left: auto; }
  .recent-history { margin-top: 16px; padding: 16px 13px; border-radius: 18px; }
  .recent-history-head { align-items: center; }
  .history-backdrop { align-items: flex-end; }
  .history-drawer {
    width: 100%;
    height: min(78vh, 680px);
    padding: 15px 14px calc(15px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 34px rgba(60,64,67,.20);
  }
  .history-drawer::before { content: ""; width: 38px; height: 4px; margin: -4px auto 1px; border-radius: 99px; background: #d4d8dc; }
}

/* ---------- student-friendly UX refresh v7 ---------- */
:root {
  --primary: #1a73e8;
  --primary-dark: #155ec0;
  --primary-soft: #e9f2ff;
  --primary-soft-text: #1455a3;
  --mint: #168a73;
  --mint-soft: #e6f6f1;
  --mint-text: #0d6655;
  --warm: #fff4d6;
  --warm-border: #f1d58a;
  --warm-text: #714d00;
  --text: #172033;
  --text-secondary: #526074;
  --text-muted: #748096;
  --bg: #f6f8fb;
  --surface: #fff;
  --border: #d8dee8;
  --border-light: #e7ebf1;
  --shadow-1: 0 2px 10px rgba(45, 61, 82, .07);
  --shadow-2: 0 16px 46px rgba(45, 61, 82, .13);
}

body {
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
}

.page { max-width: 1040px; }
.topbar { max-width: 940px; }
.logo {
  background: linear-gradient(145deg, var(--primary), #4799ff);
  box-shadow: 0 8px 20px rgba(26, 115, 232, .22);
}
.brand .title { color: var(--text); font-weight: 700; }
.brand .subtitle { color: var(--text-muted); }

.hero-copy {
  position: relative;
  max-width: 900px;
  margin: 20px auto 16px;
  isolation: isolate;
}
.hero-copy h1 { font-size: var(--fs-xl); letter-spacing: var(--tracking-tight); }

.search-card {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px;
  border-color: rgba(216, 222, 232, .88);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-2);
}
.mode-heading { align-items: center; margin-bottom: 16px; }
.mode-heading h2 { font-size: var(--fs-lg); }
.step-label { color: var(--mint); }
.trial-note { background: var(--mint-soft); color: var(--mint-text); }

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  height: auto;
  margin-bottom: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.mode-btn {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 82px;
  padding: 13px 12px;
  border: 1px solid var(--border-light);
  border-radius: 17px;
  background: #fbfcfe;
  color: var(--text-secondary);
  text-align: left;
  transform: none;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s;
}
.mode-btn:hover { border-color: #b7cdf0; background: #fff; box-shadow: var(--shadow-1); transform: translateY(-1px); }
.mode-btn.active {
  border-color: #8ab4f8;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  box-shadow: inset 0 0 0 1px rgba(26, 115, 232, .16);
}
.mode-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #eef2f6;
  color: var(--text-secondary);
}
.mode-btn.active .mode-icon { background: #fff; color: var(--primary); }
.mode-icon i, .mode-btn.active .mode-icon i { color: inherit; font-size: var(--fs-xl); opacity: 1; }
.mode-copy { display: grid; min-width: 0; gap: 2px; }
.mode-label { font-size: var(--fs-base); font-weight: 700; line-height: 1.4; }
.mode-copy small { overflow: hidden; color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.mode-btn.active .mode-copy small { color: #4773a9; }
.mode-lock {
  position: absolute;
  top: 7px;
  right: 8px;
  display: none;
  align-items: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.mode-lock i { color: inherit; font-size: var(--fs-xs); }
.guest-mode .mode-btn:not([data-mode="corpus"]) .mode-lock { display: inline-flex; }

.panel { min-height: 0; }
.panel-intro { background: #f7f9fc; }
.panel-intro.trial { border: 1px solid #c9eadf; background: var(--mint-soft); }
.panel-intro.trial strong { color: var(--mint-text); }
.panel-auth-gate {
  display: none;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 13px;
  border: 1px solid var(--warm-border);
  border-radius: 15px;
  background: var(--warm);
  color: var(--warm-text);
}
.guest-mode .panel-auth-gate { display: grid; }
.auth-gate-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: rgba(255,255,255,.72); }
.auth-gate-icon i { font-size: var(--fs-xl); }
.panel-auth-gate > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.panel-auth-gate strong { font-size: var(--fs-text); }
.panel-auth-gate small { color: #806424; font-size: var(--fs-xs); line-height: 1.45; }
.panel-login-btn {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}
.panel-login-btn:hover { background: var(--primary-dark); }
.panel-login-btn i { margin-right: 4px; }

.advanced-options { background: #fff; }
.primary-btn { font-weight: 700; }
.primary-btn.search-trial { background: var(--mint); box-shadow: 0 4px 14px rgba(22, 138, 115, .22); }
.primary-btn.search-trial:hover { background: #11745f; }
.quota-notice { border-radius: 15px; }

.result-card { border-radius: 18px; }
.result-rank { background: var(--mint-soft); color: var(--mint-text); }
.result-reason { padding: 9px 10px; border-radius: 10px; background: #f7f9fc; }
.result-reason-label { color: var(--mint-text); }
.sim-ring { background: #eef3f9; color: #53647a; }
.card-title { color: var(--mint-text); }
.card.warn { border-color: var(--warm-border); background: #fffaf0; }
.card-title.warn { color: var(--warm-text); }

.account-chip, .icon-btn, .drawer-icon-btn, .history-delete-btn, .history-share-btn { min-width: 44px; min-height: 44px; }
.back-btn, .text-btn, .secondary-btn { min-height: 44px; }
.error { border-radius: 14px; box-shadow: var(--shadow-1); }

@media (max-width: 700px) {
  .hero-copy { margin: 16px auto 14px; }
  .hero-copy h1 { font-size: var(--fs-xl); }
  .search-card { padding: 19px 15px; }
  .mode-heading { align-items: flex-start; }
  .mode-heading h2 { font-size: var(--fs-lg); }
  .mode-toggle { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mode-btn { min-height: 76px; padding: 11px 10px; }
  .mode-copy small { font-size: var(--fs-xs); }
  .panel-auth-gate { grid-template-columns: 36px minmax(0, 1fr); }
  .auth-gate-icon { width: 36px; height: 36px; }
  .panel-login-btn { grid-column: 1 / -1; width: 100%; min-height: 44px; }
}

@media (max-width: 520px) {
  .mode-btn {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 5px;
    min-height: 84px;
    padding: 9px 4px;
    text-align: center;
  }
  .mode-copy { justify-items: center; }
  .mode-copy small { display: none; }
  .mode-label { font-size: var(--fs-sm); }
  .mode-lock { top: 5px; right: 5px; }
  .mode-lock > span[aria-hidden="true"] { display: none; }
}

@media (max-width: 400px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .topbar { gap: 8px; flex-wrap: nowrap; align-items: center; }
  .brand-link { flex: 1 1 auto; min-width: 0; }
  .brand .title { font-size: var(--fs-md); white-space: nowrap; }
  .account-chip {
    width: 42px;
    max-width: 42px;
    padding: 0;
    justify-content: center;
  }
  .account-chip > span,
  .account-chip .chev { display: none; }
  .hero-copy h1 { font-size: var(--fs-xl); }
  .search-card { margin: 0; padding: 17px 13px; }
  .trial-note { display: none; }
  .mode-btn { grid-template-columns: minmax(0, 1fr); min-height: 84px; gap: 5px; }
  .mode-icon { width: 34px; height: 34px; }
  .mode-label { display: inline; font-size: var(--fs-xs); }
  .mode-lock { top: 5px; right: 6px; font-size: var(--fs-xs); }
  .corpus-filter-grid { grid-template-columns: 1fr; }
  .corpus-year-field select { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Material-inspired refinement v9 ---------- */
:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --primary-soft: #e8f0fe;
  --primary-soft-text: #1967d2;
  --mint: #1a73e8;
  --mint-soft: #e8f0fe;
  --mint-text: #1967d2;
  --warm: #fef7e0;
  --warm-border: #f6d77a;
  --warm-text: #694a00;
  --warn-text: #8a4b00;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #626f81;
  --bg: #f8f9fa;
  --surface: #fff;
  --border: #dadce0;
  --border-light: #e8eaed;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, .08);
  --shadow-2: 0 2px 8px rgba(60, 64, 67, .10);
}

body {
  color: var(--text);
  background: var(--bg);
}

.page {
  max-width: 1120px;
  padding-top: 18px;
}

.topbar {
  max-width: 1040px;
  min-height: 52px;
  margin-bottom: 0;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  box-shadow: none;
}

.brand-link { gap: 10px; }
.brand .title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
.brand .subtitle { font-size: var(--fs-xs); }
.account-chip {
  min-height: 42px;
  border-color: var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: none;
}

.hero-copy {
  max-width: 920px;
  margin: 20px auto 16px;
}
.eyebrow {
  color: var(--primary-soft-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
}
.hero-copy h1 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}
.hero-copy .eyebrow {
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.search-card {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.mode-heading { margin-bottom: 16px; }
.mode-heading h2 { font-size: var(--fs-lg); font-weight: 500; }
.step-label { color: var(--primary-soft-text); font-weight: 500; }
.trial-note {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: #f1f3f4;
  color: var(--text-secondary);
  font-weight: 500;
}

.mode-toggle { gap: 8px; }
.mode-btn {
  min-height: 76px;
  padding: 12px;
  border-color: var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: none;
}
.mode-btn:hover {
  border-color: #bdc1c6;
  background: #f8f9fa;
  box-shadow: none;
  transform: none;
}
.mode-btn.active {
  border-color: var(--primary);
  background: #f8fbff;
  color: var(--primary-soft-text);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.mode-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f3f4;
  color: var(--text-secondary);
}
.mode-btn.active .mode-icon { background: var(--primary-soft); color: var(--primary); }
.mode-label { font-size: var(--fs-text); font-weight: 500; }
.mode-copy small, .mode-btn.active .mode-copy small { color: var(--text-secondary); font-weight: 400; }
.mode-lock { color: var(--text-muted); font-weight: 400; }

.panel-intro {
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: #f8f9fa;
}
.panel-intro.trial {
  border: 0;
  border-left: 3px solid var(--primary);
  border-radius: 4px 8px 8px 4px;
  background: #f8fbff;
}
.panel-intro.trial strong { color: var(--primary-soft-text); }
.panel-auth-gate {
  border: 0;
  border-radius: 8px;
  background: var(--warm);
}
.auth-gate-icon { border-radius: 50%; background: #fff; }
.panel-login-btn {
  min-height: 40px;
  border-radius: 20px;
  font-weight: 500;
}

.search-input-wrap input,
.corpus-year-field select,
textarea {
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: none;
}
.search-input-wrap input:hover,
.corpus-year-field select:hover,
textarea:hover { border-color: #bdc1c6; }
.search-input-wrap input:focus,
textarea:focus,
.corpus-year-field select:focus,
.corpus-year-field select:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.14);
  outline: none;
}

.corpus-list { gap: 8px; }
.corpus-option {
  min-height: 64px;
  border-color: var(--border-light);
  border-radius: 8px;
  background: var(--surface);
}
.corpus-option:hover { border-color: #bdc1c6; background: #f8f9fa; }
.corpus-option.selected {
  border-color: #8ab4f8;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  box-shadow: none;
}
.corpus-option-body strong { font-weight: 500; }

.advanced-options {
  border-color: var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.advanced-options summary { min-height: 44px; }
.advanced-body { border-color: var(--border-light); }
.chip { border-radius: 18px; }

.primary-btn,
.primary-btn.search-trial {
  min-height: 48px;
  border-radius: 24px;
  background: var(--primary);
  box-shadow: none;
  font-weight: 500;
}
.primary-btn:hover,
.primary-btn.search-trial:hover { background: var(--primary-dark); box-shadow: 0 1px 2px rgba(60,64,67,.2); }
.action-hint { color: var(--text-muted); }

#resultsView { max-width: 920px; }
.results-hero {
  border-color: var(--border);
  border-radius: 12px;
  box-shadow: none;
}
.result-card {
  border-color: var(--border);
  border-radius: 12px;
  box-shadow: none;
}
.result-card:hover { border-color: #bdc1c6; box-shadow: var(--shadow-1); transform: none; }
.result-rank { border-radius: 50%; background: #f1f3f4; color: var(--text-secondary); }
.result-reason {
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8f9fa;
}
.result-reason-label { color: var(--primary-soft-text); }
.sim-ring { border-radius: 6px; background: #f1f3f4; color: var(--text-secondary); }
.tag { border-radius: 4px; }

.result-card {
  display: block;
  overflow: hidden;
  padding: 0;
  cursor: default;
}
.result-card:active { transform: none; background: var(--surface); }
.result-open {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 17px 16px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.result-open:hover { background: #fbfcfd; }
.result-open:active { background: #f8f9fa; }
.result-open > .ti-chevron-right { align-self: center; color: var(--text-muted); }
.result-match-step {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #c9e8df;
  border-radius: 8px;
  background: #f1faf7;
  color: var(--text-secondary);
  font-size: var(--fs-text);
  line-height: 1.55;
}
.result-match-step strong { color: var(--mint-text); font-size: var(--fs-sm); }
.result-match-step i { margin-right: 4px; }
.result-match-step small { color: var(--text-muted); font-size: var(--fs-sm); }
.result-profile { border-top: 1px solid var(--border-light); }
.result-profile-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 16px 14px 57px;
  list-style: none;
  cursor: pointer;
}
.result-profile-summary::-webkit-details-marker { display: none; }
.result-profile-summary::marker { content: ""; }
.result-profile-summary:hover { background: #fbfcfd; }
.result-profile-preview { display: grid; gap: 8px; min-width: 0; }
.result-profile-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.55; }
.result-profile-row > strong { color: var(--primary-soft-text); font-size: var(--fs-sm); }
.result-profile-row > span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.result-profile[open] .result-profile-row > span { display: block; overflow: visible; -webkit-line-clamp: unset; }
.result-profile-toggle { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-size: var(--fs-sm); white-space: nowrap; }
.result-profile-toggle .when-open { display: none; }
.result-profile[open] .result-profile-toggle .when-closed { display: none; }
.result-profile[open] .result-profile-toggle .when-open { display: inline; }
.result-profile-toggle i { transition: transform .18s ease; }
.result-profile[open] .result-profile-toggle i { transform: rotate(180deg); }
.result-profile-expanded { display: grid; gap: 14px; padding: 0 16px 16px 57px; }
.result-profile-section { padding-top: 12px; border-top: 1px solid var(--border-light); }
.result-profile-section > strong { display: block; margin-bottom: 6px; color: var(--primary-soft-text); font-size: var(--fs-sm); }
.result-profile-section > strong i { margin-right: 5px; }
.result-profile-section p { margin: 0; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.65; overflow-wrap: anywhere; }
.result-profile-section.bottleneck { padding: 11px 12px; border: 1px solid #f1d17a; border-radius: 8px; background: var(--warm); }
.result-profile-section.bottleneck > strong { color: var(--warn-text); }
.result-flow-list { display: grid; gap: 9px; }
.result-flow-step {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #fff;
}
.result-flow-step.matched,
.step.matched { border-color: #9bd3c4; background: #f1faf7; }
.result-flow-step-no { display: flex; align-items: center; justify-content: center; width: 27px; height: 27px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-soft-text); font-size: var(--fs-sm); font-weight: 600; }
.result-flow-step-main { display: grid; gap: 3px; min-width: 0; }
.result-flow-action { color: var(--text); font-size: var(--fs-text); line-height: 1.55; overflow-wrap: anywhere; }
.result-flow-step-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.result-flow-purpose,
.step-purpose {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.matched-step-label { color: var(--mint-text); font-size: var(--fs-xs); line-height: 1.4; }
.matched-step-label i { margin-right: 4px; }
.result-flow-timeline { display: block; gap: 0; }
.result-flow-timeline > .result-flow-timeline-step {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  background: transparent;
}
.result-flow-timeline > .result-flow-timeline-step:last-child { border-bottom: 0; }
.result-flow-timeline > .result-flow-timeline-step.matched { background: #f1faf7; }
.result-flow-timeline .result-flow-step-main { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
.result-flow-timeline .result-flow-step-no { width: 30px; height: 30px; background: var(--primary); color: #fff; font-weight: 700; box-shadow: 0 0 0 4px var(--surface); }
.result-flow-timeline .result-flow-step-content { display: grid; gap: 10px; min-width: 0; }
.result-flow-timeline .result-flow-step-copy { display: grid; gap: 6px; min-width: 0; }
.result-flow-timeline .result-flow-action { font-size: var(--fs-base); line-height: 1.55; }
.step { padding: 10px; border: 1px solid transparent; border-radius: 8px; }
.step > div:last-child { min-width: 0; }
.learning-examples {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #b9d4f5;
  border-radius: 8px;
  background: #f5f9ff;
}
.learning-examples-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.learning-examples-title { color: var(--primary-soft-text); font-size: var(--fs-sm); }
.learning-examples-title i { margin-right: 5px; color: var(--primary); }
.learning-examples-preview-badge { padding: 2px 7px; border: 1px solid #d18a25; border-radius: 999px; background: #fff6df; color: #8a5300; font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; }
.learning-example-list { display: grid; gap: 7px; }
.learning-example-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 7px; min-width: 0; }
.learning-example-source { display: grid; min-width: 0; gap: 1px; }
.learning-example-source strong { min-width: 0; color: var(--text); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.learning-example-source small { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.45; }
.learning-example-item p { grid-column: 2; margin: 0; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.55; overflow-wrap: anywhere; }
.learning-example-actions { grid-column: 2; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; }
.learning-example-metrics { color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.learning-example-open-btn { min-height: 30px; padding: 5px 9px; border: 1px solid #8fb8e8; border-radius: 7px; background: var(--surface); color: var(--primary-soft-text); font-size: var(--fs-xs); font-weight: 700; cursor: pointer; }
.learning-example-open-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.learning-example-open-btn i { margin-right: 4px; }
.learning-example-role { align-self: start; padding: 2px 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-soft-text); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.learning-example-preview-dialog { width: min(980px, calc(100% - 24px)); max-width: none; max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 24px 70px #17213b80; }
.learning-example-preview-dialog::backdrop { background: rgba(23,33,59,.76); }
.learning-example-preview-card { display: grid; gap: 12px; padding: 14px; }
.learning-example-preview-head, .learning-example-preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.learning-example-preview-stage { display: grid; place-items: center; min-height: 240px; max-height: calc(100dvh - 160px); overflow: auto; border-radius: 12px; background: #edf2f7; }
.learning-example-preview-stage img { display: none; max-width: 100%; height: auto; object-fit: contain; }
.learning-example-preview-stage img.loaded { display: block; }
.learning-example-preview-stage span { padding: 24px; color: #526176; text-align: center; }
.learning-example-preview-actions { color: var(--text-muted); font-size: var(--fs-xs); }
.learning-example-preview-actions a { display: inline-flex; align-items: center; justify-content: center; gap: 4px; text-decoration: none; }
@media(max-width:700px){.learning-example-preview-dialog{width:calc(100% - 10px);max-height:calc(100dvh - 10px);border-radius:14px}.learning-example-preview-card{padding:10px}.learning-example-preview-stage{max-height:calc(100dvh - 180px)}.learning-example-preview-actions{align-items:stretch;flex-direction:column}.learning-example-preview-actions a{width:100%}}

.analysis-hero { margin: 2px 0 18px; padding: 20px 22px; border: 1px solid var(--border-light); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1); }
.analysis-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 12px; }
.analysis-title-row h1 { margin: 4px 0 8px; font-size: var(--fs-hero); }
.analysis-lead { margin: 0; color: var(--text-secondary); line-height: 1.65; }
.analysis-inference-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border: 1px solid #f1d17a; border-radius: 999px; background: var(--warm); color: var(--warn-text); font-size: var(--fs-sm); font-weight: 700; }
.input-analysis-card { display: grid; gap: 14px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-1); }
.input-analysis-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.input-analysis-field { min-width: 0; padding: 13px 14px; border: 1px solid var(--border-light); border-radius: 9px; background: #fbfcfd; }
.input-analysis-field strong { display: block; margin-bottom: 6px; color: var(--primary-soft-text); font-size: var(--fs-sm); }
.input-analysis-field p { margin: 0; color: var(--text-secondary); font-size: var(--fs-text); line-height: 1.7; overflow-wrap: anywhere; }
.input-analysis-field.bottleneck { grid-column: 1 / -1; border-color: #f1d17a; background: var(--warm); }
.input-analysis-field.bottleneck strong { color: var(--warn-text); }
.input-analysis-flow > h2 { margin: 0 0 10px; color: var(--text); font-size: var(--fs-md); }
.analysis-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.analysis-actions .primary-btn, .analysis-actions .secondary-btn { min-height: 46px; }
.results-source-analysis { margin: 0 0 18px; }
.results-source-analysis > details { border: 1px solid #b7d6f7; border-radius: 12px; background: #f8fbff; overflow: hidden; }
.results-source-analysis summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; color: var(--primary-soft-text); font-size: var(--fs-text); font-weight: 700; cursor: pointer; list-style: none; }
.results-source-analysis summary::-webkit-details-marker { display: none; }
.results-source-analysis summary::after { content: "詳しく見る"; color: var(--primary); font-size: var(--fs-sm); font-weight: 600; }
.results-source-analysis details[open] summary::after { content: "閉じる"; }
.results-source-analysis .input-analysis-card { border: 0; border-top: 1px solid #d9e8f8; border-radius: 0; box-shadow: none; }
.input-analysis-whole-btn { margin-top: 2px; }

@media (max-width: 640px) {
  .result-open { gap: 9px; padding: 14px 11px; }
  .result-profile-summary { grid-template-columns: 1fr; gap: 9px; padding: 12px 11px; }
  .result-profile-toggle { justify-self: end; }
  .result-profile-expanded { padding: 0 11px 13px; }
  .result-profile-row { grid-template-columns: 52px minmax(0, 1fr); font-size: var(--fs-sm); }
  .result-flow-timeline > .result-flow-timeline-step { padding: 13px 12px; }
  .result-flow-timeline > .result-flow-timeline-step:not(:last-child)::before { left: 26px; top: 28px; bottom: -29px; }
  .result-flow-timeline .result-flow-step-main { grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
  .analysis-hero { padding: 17px 15px; border-radius: 14px; }
  .input-analysis-card { padding: 13px 11px; }
  .input-analysis-summary { grid-template-columns: 1fr; }
  .input-analysis-field.bottleneck { grid-column: auto; }
  .analysis-actions { display: grid; grid-template-columns: 1fr; }
  .analysis-actions .primary-btn, .analysis-actions .secondary-btn, .input-analysis-whole-btn { width: 100%; min-height: 44px; }
  .results-source-analysis summary { align-items: flex-start; }
}

.detail-head h1 { font-weight: 500; }
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: none;
}
.card-title { color: var(--primary-soft-text); }
.card.warn { border-color: #f1d17a; background: var(--warm); }
.step-no { background: var(--primary-soft); color: var(--primary-soft-text); }

.recent-history,
.account-menu,
.history-drawer {
  border-color: var(--border);
  box-shadow: var(--shadow-2);
}

@media (max-width: 700px) {
  .page { padding-top: 10px; }
  .hero-copy { margin: 16px auto 14px; }
  .hero-copy h1 { font-size: var(--fs-xl); font-weight: 700; }
  .search-card { padding: 18px 14px; border-radius: 14px; }
  .mode-btn { min-height: 72px; border-radius: 10px; }
}

@media (max-width: 400px) {
  .hero-copy h1 { font-size: var(--fs-xl); }
  .search-card { padding: 16px 12px; }
  .mode-btn { padding: 9px 3px; }
}

@media (max-width: 360px) {
  .topbar { align-items: center; }
  .brand-link { flex: 1; }
  .brand .title { font-size: var(--fs-md); white-space: nowrap; }
  .brand .subtitle { display: none; }
  .account-chip {
    width: 42px;
    max-width: 42px;
    padding: 0;
    justify-content: center;
  }
  .account-chip > span,
  .account-chip .chev { display: none; }
}

.detail-actions { display: flex; align-items: center; gap: 6px; justify-self: end; }
.detail-action-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary); }
.detail-action-btn[aria-pressed="true"] { color: var(--primary); border-color: var(--primary-soft); background: var(--primary-soft); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; padding: 10px 16px; border-radius: 999px; background: rgba(32, 33, 36, 0.92); color: #fff; font-size: var(--fs-text); box-shadow: var(--shadow-2); }
.toast.hidden { display: none; }

/* ---------- Compact mobile controls v10 ---------- */
.mode-toggle {
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: #f8f9fa;
}
.mode-btn {
  min-height: 64px;
  padding: 8px 9px;
  border-color: transparent;
  border-radius: 9px;
  background: transparent;
}
.mode-btn:hover {
  border-color: #d7dce2;
  background: #fff;
}
.mode-btn.active {
  border-color: #8ab4f8;
  background: #f3f8ff;
  box-shadow: none;
}
.mode-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}
.mode-icon i,
.mode-btn.active .mode-icon i { font-size: var(--fs-lg); }
.mode-label { font-size: var(--fs-sm); }
.mode-copy small { font-size: var(--fs-xs); }

.dropzone-preview-card {
  box-sizing: border-box;
  flex-basis: 140px;
  min-width: 140px;
  padding: 5px;
  border-radius: 10px;
}
.dropzone-add-card {
  box-sizing: border-box;
  flex-basis: 140px;
  min-width: 140px;
  min-height: 162px;
  border-radius: 10px;
}
.dropzone-preview,
.dropzone-preview-placeholder { height: 92px; }
.dropzone-preview-error {
  min-height: 92px;
  padding: 10px 7px;
}
.dropzone-preview-meta {
  margin-top: 3px;
  font-size: var(--fs-xs);
}
.dropzone-preview-order {
  top: 7px;
  left: 7px;
  min-height: 22px;
  padding: 0 6px;
  font-size: var(--fs-xs);
}
.dropzone-preview-actions {
  gap: 2px;
  margin-top: 2px;
}

.image-order-btn,
.image-rotate-btn,
.image-remove-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}
.image-rotate-btn,
.image-remove-btn { position: absolute; }
.image-rotate-btn {
  right: 2px;
  bottom: 2px;
  font-size: var(--fs-lg);
}
.image-remove-btn {
  top: 0;
  right: 0;
  font-size: var(--fs-md);
}
.image-order-btn { font-size: var(--fs-md); }
.image-order-btn::before,
.image-rotate-btn::before,
.image-remove-btn::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: -1;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  transform: translate(-50%, -50%);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.image-order-btn::before {
  border: 1px solid var(--border);
  background: var(--surface);
}
.image-order-btn:hover:not(:disabled) {
  border-color: transparent;
  background: transparent;
}
.image-order-btn:hover:not(:disabled)::before {
  border-color: #9fc0f2;
  background: #f8fbff;
}
.image-rotate-btn::before {
  border: 1px solid rgba(255,255,255,.7);
  background: rgba(20,30,48,.78);
  box-shadow: 0 3px 10px rgba(15,23,42,.24), inset 0 1px 0 rgba(255,255,255,.14);
}
.image-rotate-btn:hover {
  background: transparent;
  box-shadow: none;
  transform: none;
}
.image-rotate-btn:hover::before { background: rgba(26,115,232,.92); }
.image-rotate-btn:active { transform: none; }
.image-rotate-btn:active::before { transform: translate(-50%, -50%) scale(.92); }
.image-remove-btn::before {
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  box-shadow: 0 1px 4px rgba(32,33,36,.2);
}
.image-remove-btn:hover { background: transparent; }
.image-remove-btn:hover::before { background: #fff3f1; }
.image-order-btn > i,
.image-rotate-btn > i,
.image-remove-btn > i {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

@media (min-width: 641px) and (max-width: 880px) {
  .search-card .image-input-grid { display: block; }
  .image-field-block + .image-field-block { margin-top: 14px; }
  .dropzone-preview-card,
  .dropzone-add-card { flex-basis: 168px; min-width: 168px; }
  .dropzone-add-card { min-height: 182px; }
  .dropzone-preview,
  .dropzone-preview-placeholder { height: 112px; }
  .dropzone-preview-error { min-height: 112px; }
}

@media (max-width: 700px) {
  .mode-toggle {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .mode-btn {
    height: auto;
    min-height: 64px;
    padding: 8px 9px;
    gap: 7px;
    border-radius: 10px;
  }
  .mode-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .mode-icon i,
  .mode-btn.active .mode-icon i { font-size: var(--fs-md); }
  .mode-label { font-size: var(--fs-sm); }
  .mode-lock { top: 5px; right: 5px; }
  .description-example-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .description-example-chip { width: 100%; text-align: left; }
}

/* ---------- Production accessibility hardening ---------- */
.skip-link {
  position: fixed;
  top: 10px;
  left: max(10px, env(safe-area-inset-left, 0px));
  z-index: 300;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 10px;
  background: #202124;
  color: #fff;
  font-size: var(--fs-base);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-2);
  transform: translateY(calc(-100% - 20px));
  transition: transform .15s ease;
}
.skip-link:focus-visible { transform: translateY(0); outline: 3px solid #8ab4f8; outline-offset: 2px; }
#mainContent:focus,
.route-heading:focus { outline: none; }
.brand-link { min-height: var(--tap); }
.account-chip,
.corpus-change-btn,
.panel-login-btn,
.billing-recheck,
.results-share-btn { min-height: var(--tap); }
.detail-action-btn,
.feedback-btn {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
}

@media (max-width: 400px) {
  .account-chip {
    width: var(--tap);
    max-width: var(--tap);
  }
}

/* ---------- production shell, legal pages, and resilient fallbacks ---------- */
.noscript-notice {
  margin: 12px auto;
  max-width: 720px;
  padding: 12px 16px;
  border: 1px solid #f1c75b;
  border-radius: var(--radius-s);
  background: var(--warn-bg);
  color: #754500;
  font-weight: 600;
}
.payment-consent {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.65;
}
.payment-consent a,
.site-footer a,
.legal-document a { color: var(--primary-soft-text); text-underline-offset: 3px; }
.confirmation-message { white-space: pre-line; }
.confirmation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.confirmation-actions button { min-height: var(--tap); }
.corpus-empty-actions { display: grid; justify-items: start; gap: 8px; margin-top: 10px; }
.corpus-empty-actions button,
.corpus-empty-actions a {
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--primary-soft-text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: var(--tap);
  text-decoration: none;
  cursor: pointer;
}
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.empty-actions .primary-btn,
.empty-actions .secondary-btn { width: auto; min-height: var(--tap); text-decoration: none; }
.site-footer {
  margin-top: 48px;
  padding: 22px 0 max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-align: center;
}
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.site-footer p { margin: 12px 0 0; }

/* Text below 12px is especially difficult on school-issued and low-DPI devices. */
.history-badge,
.required-note,
.optional-note,
.subtitle,
.step-label,
.optional,
.dropzone-format,
.dropzone-preview-placeholder,
.dropzone-preview-error,
.dropzone-preview-meta,
.dropzone-preview-order,
.mode-copy small,
.mode-lock,
.mode-lock i,
.panel-auth-gate small,
.option-count,
.corpus-selected-copy small,
#searchScreen.search-locked-state .search-mode-row > .field-label::after { font-size: var(--fs-sm); }

/* Similarity is communicated as an ordinal band, not a misleading raw score. */
.similarity-badge {
  display: grid;
  min-width: 86px;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 9px;
  background: #eef3f9;
  color: #43566f;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
}
.similarity-badge-track { width: 100%; height: 4px; overflow: hidden; border-radius: 999px; background: #d8e0e9; }
.similarity-badge-fill { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* Legal documents deliberately reuse the product shell without app JavaScript. */
.legal-page { background: #f6f8fa; }
.legal-shell { max-width: 920px; }
.legal-topbar { justify-content: space-between; margin-bottom: 12px; }
.legal-document {
  padding: clamp(22px, 5vw, 48px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.legal-kicker { margin: 0; color: var(--primary-soft-text); font-size: var(--fs-sm); font-weight: 800; letter-spacing: .14em; }
.legal-document h1 { margin: 4px 0 0; font-size: var(--fs-hero); line-height: 1.35; }
.legal-updated { margin: 8px 0 26px; color: var(--text-muted); font-size: var(--fs-text); }
.legal-document section { margin-top: 30px; scroll-margin-top: 16px; }
.legal-document h2 { margin: 0 0 8px; font-size: var(--fs-lg); line-height: 1.5; }
.legal-document p,
.legal-document li,
.legal-document td,
.legal-document th { font-size: var(--fs-base); line-height: 1.8; }
.legal-document ul { padding-left: 1.4em; }
.legal-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-s); }
.legal-document table { width: 100%; border-collapse: collapse; background: var(--surface); }
.legal-document th,
.legal-document td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); text-align: left; vertical-align: top; }
.legal-document tr:last-child th,
.legal-document tr:last-child td { border-bottom: 0; }
.legal-document thead th,
.commerce-table th { background: #f6f8fa; color: var(--text-secondary); font-weight: 700; }
.commerce-table th { width: 28%; min-width: 150px; }
.publication-blocker {
  display: block;
  padding: 12px;
  border: 2px solid #d93025;
  border-radius: 8px;
  background: #fce8e6;
  color: #8c1d18;
}
.legal-note { margin-top: 18px; color: var(--text-muted); font-size: var(--fs-sm) !important; }

@media (min-width: 760px) {
  .corpus-scope-list.scrollable { max-height: none; overflow: visible; padding-right: 0; scrollbar-gutter: auto; }
}

@media (max-width: 520px) {
  .similarity-badge { min-width: 74px; font-size: var(--fs-xs); }
  .legal-document { padding: 22px 16px; }
  .commerce-table th { width: 36%; min-width: 120px; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar-actions,
  .back-btn,
  .results-hero-actions,
  .feedback-panel,
  .detail-actions,
  .site-footer nav,
  .search-card,
  .recent-history,
  .toast { display: none !important; }
  .page,
  .legal-shell { max-width: none; padding: 0; }
  .result-card,
  .card,
  .legal-document { break-inside: avoid; box-shadow: none; }
  .result-profile { display: block; }
  a { color: #000; text-decoration: none; }
}
