
:root {
  color-scheme: light;
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --text: #171a1f;
  --muted: #667085;
  --subtle: #98a2b3;
  --border: #d9dee7;
  --border-strong: #c7ced9;
  --accent: #2457d6;
  --accent-hover: #1947bd;
  --accent-soft: #eef3ff;
  --danger: #b42318;
  --danger-soft: #fff3f1;
  --success: #176448;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Ensure the HTML hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--page); }
body { margin: 0; background: var(--page); color: var(--text); font-family: var(--sans); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; padding: 54px 24px 32px; }
.tool-page { width: min(1100px, 100%); margin: 0 auto; }

.page-header { margin-bottom: 30px; }
.eyebrow {
  display: inline-block;
  margin-bottom: 9px;
  color: var(--accent);
  font: 700 11px/1.2 var(--mono);
  letter-spacing: .13em;
}
.page-header h1 { margin: 0; font-size: clamp(26px, 3vw, 34px); line-height: 1.18; letter-spacing: -.025em; font-weight: 720; }
.page-header p { margin: 9px 0 0; color: var(--muted); font-size: 14px; }

.input-section { border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border); background: var(--surface); padding: 22px 0 20px; }
.extract-form { padding: 0 22px; }
.extract-form label { display: block; margin-bottom: 8px; color: #344054; font-size: 13px; font-weight: 650; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.input-row input {
  min-width: 0;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  outline: none;
  padding: 0 13px;
  background: #fff;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-row input:focus { border-color: #6f8fe8; box-shadow: 0 0 0 3px rgba(36, 87, 214, .11); }
.primary-button {
  height: 44px;
  min-width: 142px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: white;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.primary-button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-button:disabled { cursor: not-allowed; opacity: .68; }
.url-hint { margin-top: 9px; color: var(--subtle); font-size: 12px; }

.results-section { margin-top: 28px; }
.results-head { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between; margin-bottom: 11px; }
.results-title { font-size: 15px; font-weight: 720; }
.results-count { margin-top: 4px; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: flex-end; }
.detail-toggle { display: inline-flex; align-items: center; gap: 8px; height: 32px; color: #344054; font-size: 12px; cursor: pointer; user-select: none; }
.detail-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 31px; height: 17px; border: 1px solid #b9c1ce; background: #dfe3e9; border-radius: 10px; transition: .15s ease; }
.switch::after { content: ""; position: absolute; width: 11px; height: 11px; left: 2px; top: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 2px rgba(16,24,40,.25); transition: .15s ease; }
.detail-toggle input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.detail-toggle input:checked + .switch::after { transform: translateX(14px); }
.toolbar-separator { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
.text-button, .copy-button, .batch-copy-button {
  border: 1px solid transparent;
  background: transparent;
  color: #344054;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
}
.text-button { height: 32px; padding: 0 8px; }
.batch-copy-button { height: 32px; padding: 0 12px; border-color: #9db1ea; background: var(--accent-soft); color: #1d4fc4; font-weight: 700; }
.batch-copy-button:hover:not(:disabled) { border-color: #7594e7; background: #e3ebff; color: #173fa0; }
.batch-copy-button:disabled { opacity: .42; cursor: not-allowed; }
.text-button:hover:not(:disabled) { background: #eaedf2; color: #101828; }
.text-button:disabled, .copy-button:disabled { opacity: .42; cursor: not-allowed; }
.text-button.danger { color: var(--danger); }
.text-button.danger:hover:not(:disabled) { background: var(--danger-soft); }

.batch-hint { margin-bottom: 10px; padding: 8px 11px; border: 1px solid #d9e2f8; background: #f7f9ff; color: #52627d; font-size: 12px; line-height: 1.55; }

.notice-line, .error-line { margin-bottom: 10px; border-left: 3px solid; padding: 9px 11px; font-size: 12px; }
.notice-line { background: #eff9f5; border-color: #38a078; color: var(--success); }
.error-line { background: var(--danger-soft); border-color: #d92d20; color: #7a271a; }

.result-frame { overflow: hidden; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); }
.empty-state, .loading-state { min-height: 170px; display: flex; align-items: center; justify-content: center; gap: 13px; color: var(--muted); }
.empty-state { justify-content: flex-start; padding: 36px 26px; background: repeating-linear-gradient(-45deg, #fff, #fff 8px, #fbfcfd 8px, #fbfcfd 16px); }
.empty-code { font: 700 17px/1 var(--mono); color: #c2c8d2; }
.empty-state strong { display: block; color: #475467; font-size: 13px; }
.empty-state p { margin: 5px 0 0; font-size: 12px; }
.loading-state { font-family: var(--mono); font-size: 12px; }
.spinner { width: 15px; height: 15px; border: 2px solid #cad1dc; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-list { list-style: none; margin: 0; padding: 0; font-family: var(--mono); }
.result-item { display: grid; grid-template-columns: 54px minmax(0, 1fr) 58px; min-height: 48px; align-items: stretch; border-bottom: 1px solid #e5e9ef; }
.result-item:last-child { border-bottom: 0; }
.result-item:hover { background: #fafbfc; }
.index-cell { display: flex; align-items: center; justify-content: center; border-right: 1px solid #e5e9ef; color: #8490a3; background: #f8f9fb; font-size: 12px; font-weight: 700; }
.result-content { min-width: 0; display: flex; align-items: center; padding: 11px 14px; }
.magnet-text { color: #172b4d; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; overflow-wrap: anywhere; }
.copy-button { align-self: center; justify-self: center; height: 28px; padding: 0 9px; border-color: #d5dae3; background: #fff; }
.copy-button:hover { border-color: #aeb7c6; background: #f4f6f8; }

.result-item.detailed { min-height: 132px; }
.result-item.detailed .result-content { align-items: flex-start; }
.detail-grid { width: 100%; margin: 0; display: grid; gap: 7px; }
.detail-grid > div { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 8px; }
.detail-grid dt { color: #98a2b3; font-size: 11px; }
.detail-grid dd { margin: 0; min-width: 0; color: #475467; font-size: 11.5px; line-height: 1.55; }
.detail-grid .normal-text { font-family: var(--sans); font-size: 12px; color: #344054; }
.detail-grid a { color: var(--accent); text-decoration: none; }
.detail-grid a:hover { text-decoration: underline; }
.break-all { overflow-wrap: anywhere; }

.page-footer { padding: 15px 2px 0; color: #98a2b3; font-size: 11px; text-align: right; }

@media (max-width: 760px) {
  .app-shell { padding: 32px 14px 22px; }
  .page-header { margin-bottom: 23px; }
  .input-section { margin: 0 -2px; }
  .extract-form { padding: 0 14px; }
  .input-row { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .results-head { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: flex-start; margin-left: -7px; }
  .toolbar-separator { display: none; }
  .result-item { grid-template-columns: 42px minmax(0, 1fr) 52px; }
  .result-content { padding: 10px; }
  .copy-button { padding: 0 7px; }
  .detail-grid > div { grid-template-columns: 1fr; gap: 2px; }
  .result-item.detailed { min-height: 180px; }
  .page-footer { text-align: left; }
}
