:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --text: #172033;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .035);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.7; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { color: var(--text); line-height: 1.25; letter-spacing: -.02em; }
h1 { margin: 0 0 var(--space-4); font-size: clamp(2rem, 4vw, 2.65rem); }
h2 { margin: 0 0 var(--space-3); font-size: clamp(1.35rem, 2.4vw, 1.65rem); }
h3 { margin: 0 0 var(--space-2); font-size: 1.1rem; }
h4 { margin: var(--space-4) 0 var(--space-2); font-size: .95rem; }
p { margin: 0 0 var(--space-4); }
ul, ol { padding-left: 1.4rem; }

.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(226,232,240,.9); backdrop-filter: blur(14px); }
.nav-shell { width: min(1180px, calc(100% - 40px)); min-height: 68px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.22rem; font-weight: 750; text-decoration: none; letter-spacing: -.025em; }
.brand-icon { display: block; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 10px; object-fit: cover; }
.brand-sub { display: block; color: var(--text-muted); font-size: .67rem; font-weight: 500; letter-spacing: .08em; }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { padding: 8px 12px; border-radius: var(--radius-sm); color: #475569; font-weight: 600; text-decoration: none; }
.site-nav a:hover { background: var(--surface-subtle); color: var(--text); }
.site-nav a.active { background: var(--primary-soft); color: var(--primary); }
.container { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: var(--space-12) 0 72px; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.footer-shell { width: min(1120px, calc(100% - 40px)); margin: auto; padding: var(--space-6) 0; display: flex; justify-content: space-between; gap: var(--space-4); font-size: .9rem; }

.panel, .card { margin: 0 0 var(--space-6); padding: clamp(22px, 3.2vw, 30px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel > :last-child, .card > :last-child { margin-bottom: 0; }
.panel-inset { margin-top: var(--space-4); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); }
.hero { padding: clamp(36px, 7vw, 72px); border-color: #dbe7fb; background: linear-gradient(135deg, #fff 20%, #f7faff 100%); overflow: hidden; }
.hero h1 { max-width: 780px; font-size: clamp(2.25rem, 5.5vw, 3.55rem); }
.hero .lead { max-width: 720px; color: #526078; font-size: clamp(1rem, 2vw, 1.15rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.eyebrow { margin-bottom: var(--space-3); color: var(--primary); font-size: .78rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); margin-bottom: var(--space-6); }
.choice-grid .panel { margin: 0; min-height: 100%; }
.feature-card { position: relative; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.feature-card:hover { transform: translateY(-2px); border-color: #c7d7ef; box-shadow: 0 10px 28px rgba(15,23,42,.07); }
.card-icon, .state-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: var(--space-4); border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 1.15rem; font-weight: 750; }
.state-icon.success { background: var(--success-soft); color: var(--success); }
.state-icon.warning { background: var(--warning-soft); color: var(--warning); }

button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: var(--space-3); padding: 10px 18px; border: 1px solid transparent; border-radius: 9px; background: var(--primary); color: #fff; font: inherit; font-weight: 700; line-height: 1.25; text-decoration: none; cursor: pointer; transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
button:hover, .button:hover { background: var(--primary-hover); color: #fff; transform: translateY(-1px); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(37,99,235,.22); outline-offset: 2px; }
.button.secondary, .secondary-button { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.button.secondary:hover, .secondary-button:hover { background: var(--surface-subtle); color: var(--text); }
button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.link-button { min-height: auto; margin: 0; padding: 0; border: 0; background: none; color: var(--primary); font-weight: 600; }
.link-button:hover { background: none; color: var(--primary-hover); transform: none; }
.danger-link { color: #9f3a3a; }
.danger-button { background: var(--danger); }
.danger-button:hover { background: #991b1b; }
.small-button { min-height: 34px; margin: 0; padding: 6px 10px; font-size: .86rem; }

form { max-width: 920px; }
label { display: block; margin: var(--space-4) 0 var(--space-2); color: #334155; font-weight: 700; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .16s ease, box-shadow .16s ease; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); outline: none; }
input[type="file"] { padding: 12px; border-style: dashed; background: #fafcff; cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 8px 12px; border: 0; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-weight: 700; cursor: pointer; }
.upload-zone { padding: var(--space-6); border: 1.5px dashed #b9c7dc; border-radius: var(--radius); background: #fafcff; }
.upload-zone h2, .upload-zone h3 { margin-bottom: var(--space-2); }
.upload-zone input[type="file"] { border: 0; padding: var(--space-3) 0 0; background: transparent; }
.upload-zone.drop-enabled { transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.upload-zone.is-dragover { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.file-selection { max-width: 100%; margin: 10px 0 0; overflow-wrap: anywhere; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-4); margin: var(--space-6) 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 0 var(--space-4); }
.inline { display: inline-flex !important; align-items: center; gap: 8px; margin-right: var(--space-4) !important; }
.inline input, .candidate-check input { width: auto; }
.add-row { display: flex; gap: 10px; align-items: end; margin-bottom: var(--space-4); }
.add-row select { width: auto; min-width: 220px; }

.message, .diagnostic { margin: var(--space-4) 0; padding: var(--space-4) var(--space-6); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--surface-subtle); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.message.pass, .message.success, .diagnostic-success { border-color: #bbdfc5; border-left-color: var(--success); background: var(--success-soft); }
.message.warning, .diagnostic-warning { border-color: #f2d6a2; border-left-color: var(--warning); background: var(--warning-soft); }
.message.error, .diagnostic-error { border-color: #efc7c7; border-left-color: var(--danger); background: var(--danger-soft); }
.message.info, .diagnostic-info { border-color: #cbdcf7; border-left-color: var(--primary); background: var(--primary-soft); }
.text-error { color: var(--danger); }
.muted, .small { color: var(--text-muted); }
.small { font-size: .88rem; }
.status, .confidence, .badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 750; }
.status-pass { background: #dcfce7; color: #166534; }
.status-warning { background: #fef3c7; color: #92400e; }
.status-error { background: #fee2e2; color: #991b1b; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin: var(--space-6) 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--border); }
.summary div { min-width: 0; padding: var(--space-4); background: var(--surface); }
.summary dt { color: var(--text-muted); font-size: .78rem; font-weight: 650; }
.summary dd { margin: 4px 0 0; font-size: 1.08rem; font-weight: 750; overflow-wrap: anywhere; }
.metadata { display: flex; flex-wrap: wrap; gap: var(--space-4); color: var(--text-muted); font-size: .86rem; }
.metadata div { min-width: 110px; }
.metadata dt { font-weight: 650; }
.metadata dd { margin: 2px 0; color: var(--text); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.actions form { display: inline; }
.list-tools { max-width: 520px; margin-bottom: var(--space-4); }
.secondary-link { margin-left: var(--space-3); }

.rule-list, .candidate-list { display: grid; gap: var(--space-3); }
.saved-rule, .step-card, .candidate-card { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.saved-rule { transition: border-color .16s ease, background .16s ease; }
.saved-rule:hover { border-color: #c7d7ef; background: #fcfdff; }
.saved-rule h3 { margin-bottom: 6px; }
.step-card { margin: 10px 0; background: #fafbfc; }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.candidate-card { border-left: 4px solid #94a3b8; }
.candidate-card.confidence-高 { border-left-color: var(--success); }
.candidate-card.confidence-中 { border-left-color: var(--warning); }
.candidate-card.confidence-低 { border-left-color: #94a3b8; }
.candidate-card.confidence-高 .confidence { background: #dcfce7; color: #166534; }
.candidate-card.confidence-中 .confidence { background: #fef3c7; color: #92400e; }
.candidate-card.confidence-低 .confidence { background: #e2e8f0; color: #475569; }
.candidate-check { margin: 0; font-size: 1rem; }

.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-wrap.compact { max-width: 520px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-subtle); color: #475569; font-size: .8rem; font-weight: 750; }
tbody tr:hover td { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td { overflow-wrap: anywhere; }
td:has(> .number), td.number, th.number { text-align: right; }

details { margin-top: var(--space-4); }
summary { color: #475569; font-weight: 700; cursor: pointer; }
pre { max-width: 100%; overflow: auto; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f8fafc; color: #334155; font: .86rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.5; tab-size: 2; }
.version { padding: 3px 8px; border-radius: 999px; background: var(--surface-subtle); color: var(--text-muted); font-size: .74rem; }
.empty-state { padding: var(--space-8); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fbfcfe; }
.empty-state .card-icon { margin-inline: auto; }
.steps { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-6); padding: 0; list-style: none; color: var(--text-muted); font-size: .86rem; font-weight: 650; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li:not(:last-child)::after { content: ""; width: 28px; height: 1px; margin-left: 8px; background: var(--border-strong); }
.steps .active { color: var(--primary); }
.step-number { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--surface-subtle); }
.steps .active .step-number { background: var(--primary); color: #fff; }
.loading-card { display: flex; align-items: center; gap: var(--space-4); }
.spinner { width: 24px; height: 24px; flex: 0 0 auto; border: 3px solid #bfdbfe; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 800px) {
  .container { width: min(100% - 28px, 1120px); padding-top: var(--space-8); }
  .nav-shell { width: calc(100% - 28px); min-height: 62px; }
  .site-nav a { padding: 7px 8px; font-size: .86rem; }
  .brand-sub { display: none; }
  .choice-grid, .upload-grid { grid-template-columns: 1fr; }
  .hero { padding: 32px 24px; }
  .footer-shell { width: calc(100% - 28px); }
}
@media (max-width: 1024px) {
  .nav-shell { align-items: flex-start; padding: 12px 0; }
  .site-nav { justify-content: flex-end; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .site-nav a:not(:first-child) { display: none; }
  .container { width: min(100% - 20px, 1120px); }
  .panel, .card { padding: 20px 16px; }
  .actions, .hero-actions { align-items: stretch; flex-direction: column; }
  .actions .button, .hero-actions .button { width: 100%; }
  .steps { flex-wrap: wrap; }
  .steps li:not(:last-child)::after { width: 12px; }
  .summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

.result-hero { border-top: 4px solid var(--primary); }
.result-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1.25rem; }
.button-large { padding: .9rem 1.3rem; font-size: 1rem; }
.reuse-cta { background: linear-gradient(135deg, #f4f7ff, #fff); }
.technical-details > summary { font-weight: 700; font-size: 1.05rem; }
.technical-details[open] > summary { margin-bottom: 1.25rem; }
.technical-details .panel { box-shadow: none; border-color: var(--border); }
.compact-empty { padding-block: 1.1rem; text-align: left; }
.footer-shell > div { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.footer-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: .9rem; }
.legal-document { max-width: 820px; margin-inline: auto; }
.legal-document section + section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.legal-document h2 { margin-bottom: .75rem; }
.legal-document p, .legal-document li { line-height: 1.85; }
.data-notice { margin: 1rem 0; }
.auth-card { max-width: 560px; margin-inline: auto; }
.auth-brand-icon { display: block; width: 72px; height: 72px; margin: 0 0 var(--space-4); border-radius: 18px; object-fit: cover; }
.user-label { color: var(--muted); font-size: .88rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.logout-form { margin: 0; }
