:root {
  --dml-font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: inherit;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: var(--dml-font);
  font-size: 16px;
  line-height: 1.45;
  color: #111;
  background: #fff;
}

button,
textarea,
select {
  font: inherit;
  font-size: 16px;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}

/* ========== ヘッダー ========== */
.header-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 18px;
}

.badge {
  display: inline-block;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1;
  background: #f3f4f6;
  color: #374151;
}

.update-date {
  font-size: 12px;
  color: #6b7280;
}

/* ========== 共通UI ========== */
fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 16px;
}

legend {
  padding: 0 6px;
  font-size: 18px;
  color: #374151;
  font-weight: 500;
}

.field {
  margin: 4px 0;
}

.field label {
  display: block;
  color: #374151;
  margin-bottom: 4px;
  font-weight: 500;
}

select,
textarea {
  width: 100%;
  border: 1px solid #b9bdc4;
  border-radius: 8px;
  outline: none;
  background: #fff;
}

select {
  min-height: 44px;
  padding: 8px 10px;
}

textarea {
  min-height: 590px;
  padding: 12px;
  line-height: 1.45;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 2;
}

textarea:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.input-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.action-btn {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  padding: 10px 12px;
  cursor: pointer;
}

.action-btn.danger {
  border-color: #fecaca;
  background: #fff7f7;
}

.action-btn:active {
  transform: scale(0.99);
}

.parse-status {
  min-height: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: #4b5563;
  line-height: 1.45;
  white-space: pre-wrap;
}

.parse-status.warn {
  color: #b91c1c;
}

/* ========== 機種情報 ========== */
.machine-info {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
}

.machine-name {
  font-weight: 700;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.machine-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.machine-meta-grid div {
  min-width: 0;
}

.machine-meta-grid span,
.machine-meta-grid strong {
  display: block;
}

.machine-meta-grid span {
  font-size: 12px;
  color: #6b7280;
}

.machine-meta-grid strong {
  margin-top: 2px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* ========== 計算結果 ========== */
.result-text {
  margin: 0;
  min-height: 220px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--dml-font);
  font-size: 16px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  textarea {
    min-height: 540px;
  }

  .machine-meta-grid {
    grid-template-columns: 1fr;
  }
}
