* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	--primary-color: #2563eb;
	--primary-hover: #1d4ed8;
	--success-color: #16a34a;
	--error-color: #dc2626;
	--text-color: #1f2937;
	--text-secondary: #6b7280;
	--border-color: #d1d5db;
	--bg-light: #f9fafb;
	--bg-white: #ffffff;
	--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
	--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
		'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
		sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	background-color: var(--bg-light);
	color: var(--text-color);
	line-height: 1.6;
}

main {
	min-height: 100vh;
	padding: 2rem 1rem;
}

.hidden {
	display: none !important;
}

/* ============================================
   Downloader Container
   ============================================ */
.downloader-container {
	max-width: 800px;
	margin: 0 auto;
}

.downloader-card {
	background: var(--bg-white);
	border-radius: 12px;
	padding: 2rem;
	box-shadow: var(--shadow-lg);
}

.title {
	font-size: 2rem;
	font-weight: 700;
	margin-bottom: 0.5rem;
	color: var(--primary-color);
}

.subtitle {
	font-size: 1rem;
	color: var(--text-secondary);
	margin-bottom: 2rem;
}

.enrich-promo {
	font-size: 0.85rem;
	margin: 0 0 0.75rem;
}

.enrich-promo a {
	color: #2563eb;
	text-decoration: none;
	font-weight: 500;
}

.enrich-promo a:hover {
	text-decoration: underline;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
	margin-bottom: 1.5rem;
}

.indented-group {
	margin-left: 1.5rem;
}

.label {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	margin-bottom: 0.5rem;
	color: var(--text-color);
}

.input,
.select {
	width: 100%;
	padding: 0.75rem;
	font-size: 1rem;
	border: 1px solid var(--border-color);
	border-radius: 6px;
	background: var(--bg-white);
	color: var(--text-color);
	transition: all 0.2s;
}

.input:focus,
.select:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input:disabled,
.select:disabled {
	background: var(--bg-light);
	cursor: not-allowed;
	opacity: 0.6;
}

.help-text {
	font-size: 0.75rem;
	color: var(--text-secondary);
	margin-top: 0.25rem;
}

.loading-text {
	font-size: 0.875rem;
	color: var(--text-secondary);
	font-style: italic;
}

.error-text {
	font-size: 0.875rem;
	color: var(--error-color);
	font-weight: 500;
}

.sub-panel {
	margin-bottom: 1.5rem;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 1rem 1rem 1rem 1.5rem;
	background-color: #f9f9f9;
}

.sub-panel-title {
	margin-top: 0;
	margin-bottom: 1rem;
	font-size: 1.1rem;
	color: #333;
}

.grid-2col {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
}

/* ============================================
   Radio & Checkbox Buttons
   ============================================ */
.radio-group {
	display: flex;
	gap: 1.5rem;
}

.radio-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	cursor: pointer;
	font-size: 0.875rem;
}

.radio-label input[type='radio'] {
	width: 1.25rem;
	height: 1.25rem;
	cursor: pointer;
}

.radio-label input[type='radio']:disabled {
	cursor: not-allowed;
}

.checkbox-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	cursor: pointer;
	font-size: 0.875rem;
}

.checkbox-label input[type='checkbox'] {
	width: 1.25rem;
	height: 1.25rem;
	cursor: pointer;
}

.checkbox-label input[type='checkbox']:disabled {
	cursor: not-allowed;
}

/* ============================================
   Download & Cancel Buttons
   ============================================ */
.action-row {
	display: flex;
	gap: 1rem;
	align-items: center;
}

.download-button {
	flex: 1;
	width: 100%;
	padding: 1rem;
	font-size: 1rem;
	font-weight: 600;
	color: white;
	background: var(--primary-color);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s;
	box-shadow: var(--shadow-sm);
}

.download-button:hover:not(:disabled) {
	background: var(--primary-hover);
	box-shadow: var(--shadow-md);
	transform: translateY(-1px);
}

.download-button:active:not(:disabled) {
	transform: translateY(0);
}

.download-button:disabled {
	background: var(--border-color);
	cursor: not-allowed;
	transform: none;
}

.cancel-button {
	padding: 0.75rem 1.5rem;
	background-color: #dc3545;
	color: white;
	border: none;
	border-radius: 8px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s;
	white-space: nowrap;
}

.cancel-button:hover {
	background-color: #c82333;
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-container {
	margin-top: 2rem;
	padding: 1.5rem;
	background: var(--bg-light);
	border-radius: 8px;
	border: 1px solid var(--border-color);
}

.progress-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.75rem;
}

.progress-message {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text-color);
}

.progress-count {
	font-size: 0.75rem;
	color: var(--text-secondary);
	font-weight: 500;
}

.progress-bar {
	width: 100%;
	height: 12px;
	background: #e5e7eb;
	border-radius: 6px;
	overflow: hidden;
	margin-bottom: 0.5rem;
}

.progress-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--primary-color), var(--success-color));
	border-radius: 6px;
	transition: width 0.3s ease;
}

.progress-percentage {
	text-align: right;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--primary-color);
}

/* ============================================
   Info & Error Boxes
   ============================================ */
.info-box {
	margin-top: 2rem;
	padding: 1.5rem;
	background: #eff6ff;
	border-left: 4px solid var(--primary-color);
	border-radius: 6px;
}

.info-box h3 {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 0.75rem;
	color: var(--primary-color);
}

.info-box ul {
	list-style: none;
	padding-left: 0;
}

.info-box li {
	font-size: 0.875rem;
	color: var(--text-secondary);
	margin-bottom: 0.5rem;
	padding-left: 1.5rem;
	position: relative;
}

.info-box li::before {
	content: '•';
	position: absolute;
	left: 0.5rem;
	color: var(--primary-color);
	font-weight: bold;
}

.info-box a {
	color: #1d4ed8;
}

.error-box {
	margin-top: 1.5rem;
	padding: 1rem;
	background: #fef2f2;
	border-left: 4px solid var(--error-color);
	border-radius: 6px;
	color: var(--error-color);
	font-size: 0.875rem;
}

.error-box strong {
	font-weight: 700;
}

.timeout-box {
	margin-top: 1.5rem;
	padding: 1rem 1.25rem;
	background: #fffbeb;
	border-left: 4px solid #f59e0b;
	border-radius: 6px;
	color: #78350f;
	font-size: 0.875rem;
	line-height: 1.7;
}

.timeout-box strong {
	font-weight: 700;
}

.timeout-link {
	color: #1d4ed8;
	font-weight: 700;
	font-size: 0.95rem;
	text-decoration: none;
}

.timeout-link:hover {
	text-decoration: underline;
}

/* ============================================
   Related Links
   ============================================ */
.spec-section {
	margin-top: 1.5rem;
}

.spec-intro {
	font-size: 0.83rem;
	color: #64748b;
	margin: 0 0 0.5rem;
}

.related-links {
	margin-top: 2rem;
}

.related-links-title {
	font-size: 1rem;
	font-weight: 600;
	color: var(--text-color);
	margin-bottom: 0.75rem;
}

.related-links-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 0.75rem;
}

.related-card {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	padding: 0.875rem 1rem;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	border-radius: 8px;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.related-card:hover {
	background: #dbeafe;
	border-color: var(--primary-color);
	box-shadow: var(--shadow-sm);
}

.related-card-icon {
	font-size: 1.1rem;
}

.related-card-label {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--primary-color);
	line-height: 1.3;
}

.related-card-desc {
	font-size: 0.7rem;
	color: var(--text-secondary);
	line-height: 1.4;
}

/* ============================================
   CsvDataSpec Component
   ============================================ */
.spec-wrapper {
	margin-top: 2rem;
	border-top: 2px solid var(--border-color);
	padding-top: 1.5rem;
}

.spec-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.875rem 1.25rem;
	background: #eff6ff;
	border: 1.5px solid #bfdbfe;
	border-radius: 8px;
	cursor: pointer;
	font-size: 0.9375rem;
	font-weight: 700;
	color: var(--primary-color);
	transition: background 0.15s;
}

.spec-toggle:hover {
	background: #dbeafe;
}

.spec-toggle-icon {
	font-size: 0.75rem;
	margin-left: 0.5rem;
}

.spec-body {
	margin-top: 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 1.75rem;
}

.spec-academic-note {
	background: #fefce8;
	border-left: 4px solid #ca8a04;
	border-radius: 4px;
	padding: 0.875rem 1.125rem;
	font-size: 0.8125rem;
	color: #78350f;
	line-height: 1.65;
}

.spec-academic-note strong {
	color: #92400e;
}

.spec-academic-note ul {
	margin: 0.5rem 0 0 1.25rem;
	padding: 0;
}

.spec-academic-note li {
	margin-bottom: 0.3rem;
}

.spec-academic-note em {
	font-family: 'Courier New', monospace;
	font-style: normal;
}

.spec-academic-note p {
	margin: 0.5rem 0 0;
}

.spec-doi-link {
	word-break: break-all;
	color: var(--primary-color);
}

.spec-summary h3,
.spec-detail-heading {
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--text-color);
	margin-bottom: 0.75rem;
}

.spec-summary-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.75rem;
}

.spec-summary-card {
	padding: 1rem;
	background: var(--bg-light);
	border: 2px solid;
	border-radius: 8px;
	text-align: center;
}

.spec-summary-count {
	font-size: 2rem;
	font-weight: 800;
	line-height: 1;
}

.spec-summary-label {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--text-color);
	margin-top: 0.25rem;
}

.spec-summary-unit {
	font-size: 0.7rem;
	color: var(--text-secondary);
}

.spec-group {
	border: 1px solid var(--border-color);
	border-radius: 8px;
	overflow: hidden;
}

.spec-group-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.75rem 1rem;
	background: var(--bg-light);
	border: none;
	cursor: pointer;
	text-align: left;
	transition: background 0.15s;
}

.spec-group-header:hover {
	background: #e5e7eb;
}

.spec-group-title {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--text-color);
}

.spec-group-id {
	font-size: 0.7rem;
	font-weight: 700;
	background: var(--primary-color);
	color: white;
	padding: 0.15em 0.5em;
	border-radius: 3px;
}

.spec-badge {
	font-size: 0.6875rem;
	font-weight: 600;
	color: white;
	padding: 0.15em 0.6em;
	border-radius: 12px;
}

.spec-group-body {
	padding: 1rem;
	background: white;
	border-top: 1px solid var(--border-color);
}

.spec-calc-note {
	background: #f0f9ff;
	border-left: 3px solid #38bdf8;
	border-radius: 4px;
	padding: 0.625rem 0.875rem;
	font-size: 0.775rem;
	color: #0c4a6e;
	line-height: 1.65;
	margin-bottom: 0.875rem;
}

.spec-calc-note strong {
	color: #075985;
}

.spec-calc-list {
	margin: 0.35rem 0 0;
	padding-left: 1.4rem;
	font-size: 0.82rem;
	line-height: 1.7;
}

.spec-calc-list li {
	margin-bottom: 0.1rem;
}

.spec-table-wrap {
	overflow-x: auto;
}

.spec-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.78rem;
	min-width: 600px;
}

.spec-table thead th {
	background: var(--primary-color);
	color: white;
	padding: 0.5rem 0.75rem;
	text-align: left;
	font-weight: 600;
	white-space: nowrap;
}

.spec-table tbody tr:nth-child(even) {
	background: var(--bg-light);
}

.spec-table tbody tr:hover {
	background: #eff6ff;
}

.spec-table tbody td {
	padding: 0.4rem 0.75rem;
	border-bottom: 1px solid var(--border-color);
	vertical-align: top;
	color: var(--text-color);
	line-height: 1.5;
}

.spec-code {
	background: #e0e7ff;
	color: #3730a3;
	padding: 0.1em 0.45em;
	border-radius: 3px;
	font-family: 'Courier New', monospace;
	font-size: 0.85em;
	white-space: nowrap;
}

.spec-type {
	font-family: 'Courier New', monospace;
	font-size: 0.82em;
	color: #6b7280;
	white-space: nowrap;
}

.spec-note-cell {
	color: var(--text-secondary);
	font-size: 0.75rem;
}

/* ============================================
   AstroEnricher Page (/enrich)
   ============================================ */
.enricher-container {
	max-width: 760px;
	margin: 0 auto;
	padding: 1.5rem 1rem 4rem;
	font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Meiryo', sans-serif;
	color: #1e293b;
	font-size: 0.95rem;
}

.enricher-header {
	margin-bottom: 1.5rem;
}

.enricher-title {
	font-size: 1.6rem;
	font-weight: 700;
	margin: 0 0 0.4rem;
	color: #1e40af;
}

.enricher-subtitle {
	margin: 0 0 0.6rem;
	color: #475569;
	line-height: 1.6;
	font-size: 0.9rem;
}

.enricher-back-link {
	font-size: 0.85rem;
	color: #2563eb;
	text-decoration: none;
}

.enricher-back-link:hover {
	text-decoration: underline;
}

.enricher-card {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem;
	padding: 1.25rem 1.5rem;
	margin-bottom: 1rem;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.enricher-section-title {
	font-size: 1rem;
	font-weight: 700;
	margin: 0 0 0.75rem;
	color: #1e40af;
}

.enricher-input {
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	font-size: 0.9rem;
	box-sizing: border-box;
	background: #fff;
	color: #1e293b;
}

.enricher-input:disabled {
	background: #f8fafc;
	cursor: not-allowed;
	opacity: 0.65;
}

.enricher-hint {
	font-size: 0.78rem;
	color: #64748b;
	margin: 0.35rem 0 0;
}

.drop-zone {
	border: 2px dashed #94a3b8;
	border-radius: 0.5rem;
	padding: 2rem;
	text-align: center;
	cursor: pointer;
	transition: all 0.15s ease;
	background: #f8fafc;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.drop-zone.active {
	border: 2px dashed #2563eb;
	background: #eff6ff;
}

.drop-zone.success {
	border: 2px dashed #059669;
	background: #f0fdf4;
}

.drop-zone.disabled {
	cursor: not-allowed;
	opacity: 0.65;
}

.drop-icon {
	font-size: 2rem;
}

.drop-text {
	font-weight: 600;
	color: #374151;
}

.drop-hint {
	font-size: 0.8rem;
	color: #6b7280;
}

.enricher-error-box {
	margin-top: 0.75rem;
	background: #fef2f2;
	border: 1px solid #fca5a5;
	border-radius: 0.375rem;
	padding: 0.75rem 1rem;
	color: #b91c1c;
	font-size: 0.85rem;
	white-space: pre-wrap;
}

.enricher-info-box {
	margin-top: 0.75rem;
	background: #eff6ff;
	border: 1px solid #93c5fd;
	border-radius: 0.375rem;
	padding: 0.75rem 1rem;
	font-size: 0.85rem;
	color: #1e40af;
	line-height: 1.6;
}

.enricher-form-group {
	margin-bottom: 1rem;
}

.enricher-label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35rem;
	font-size: 0.9rem;
}

.enricher-select {
	padding: 0.45rem 0.75rem;
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	font-size: 0.9rem;
	background: #fff;
	color: #1e293b;
	min-width: 220px;
}

.enricher-select:disabled {
	background: #f8fafc;
	cursor: not-allowed;
	opacity: 0.65;
}

.enricher-radio-group {
	display: flex;
	gap: 1.5rem;
}

.enricher-radio-label {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	cursor: pointer;
	font-size: 0.9rem;
}

.enricher-progress-wrapper {
	margin-bottom: 1rem;
}

.enricher-progress-header {
	display: flex;
	justify-content: space-between;
	margin-bottom: 0.35rem;
	font-size: 0.875rem;
}

.enricher-progress-message {
	color: #374151;
	font-weight: 500;
}

.enricher-progress-count {
	color: #6b7280;
	font-size: 0.8rem;
}

.enricher-progress-bar-bg {
	width: 100%;
	height: 10px;
	background: #e2e8f0;
	border-radius: 9999px;
	overflow: hidden;
}

.enricher-progress-bar-fill {
	height: 100%;
	border-radius: 9999px;
	transition: width 0.3s ease;
	background-color: #2563eb;
}

.enricher-progress-pct {
	text-align: right;
	font-size: 0.75rem;
	color: #6b7280;
	margin-top: 0.2rem;
}

.enricher-button-row {
	display: flex;
	gap: 0.75rem;
	margin-top: 0.5rem;
}

.enricher-start-button {
	padding: 0.75rem 1.5rem;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 0.5rem;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s;
}

.enricher-start-button:hover:not(:disabled) {
	background: #1d4ed8;
}

.enricher-start-button:disabled {
	background: #94a3b8;
	cursor: not-allowed;
}

.enricher-cancel-button {
	padding: 0.75rem 1.5rem;
	background: #dc2626;
	color: #fff;
	border: none;
	border-radius: 0.5rem;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
}

.enricher-cancel-button:hover {
	background: #b91c1c;
}

.enricher-estimate-box {
	margin-top: 0.75rem;
	padding: 0.6rem 0.9rem;
	background: #fefce8;
	border: 1px solid #fde047;
	border-radius: 0.375rem;
	font-size: 0.82rem;
	color: #713f12;
}

.field-group-block {
	margin-bottom: 0.75rem;
}

.field-group-name {
	font-weight: 600;
	font-size: 0.85rem;
	color: #475569;
	margin-bottom: 0.25rem;
}

.field-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.8rem;
}

.field-td-code {
	font-family: monospace;
	padding: 0.2rem 0.5rem;
	color: #1e40af;
	white-space: nowrap;
	width: 50%;
}

.field-td-desc {
	padding: 0.2rem 0.5rem;
	color: #374151;
}

.methodology-intro {
	font-size: 0.83rem;
	color: #64748b;
	margin: 0 0 0.75rem;
	line-height: 1.6;
}

.methodology-item {
	margin-bottom: 0.5rem;
	border-radius: 0.5rem;
	overflow: hidden;
}

.methodology-btn {
	width: 100%;
	text-align: left;
	padding: 0.65rem 0.9rem;
	border: none;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.85rem;
	font-weight: 600;
}

.methodology-arrow {
	font-size: 0.75rem;
}

.methodology-list {
	margin: 0;
	padding: 0.6rem 0.9rem 0.6rem 2rem;
	font-size: 0.81rem;
	line-height: 1.75;
	color: #374151;
	background: #fff;
}

.methodology-list li {
	margin-bottom: 0.05rem;
}

.methodology-quote {
	font-family: monospace;
	white-space: pre-wrap;
	color: #1e40af;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 640px) {
	.title {
		font-size: 1.5rem;
	}

	.downloader-card {
		padding: 1.5rem;
	}

	.radio-group,
	.enricher-radio-group {
		flex-direction: column;
		gap: 0.75rem;
	}

	.grid-2col {
		grid-template-columns: 1fr;
	}

	.progress-info,
	.enricher-progress-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.25rem;
	}

	.spec-summary-grid {
		grid-template-columns: 1fr;
	}

	.spec-table {
		min-width: 480px;
	}
}
