:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --top-zone: #f4f7f5;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #617080;
  --line: #d7e2dd;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --success: #067647;
  --warning: #b54708;
  --radius: 12px;
  --control-radius: 10px;
  --soft-shadow: 0 10px 28px rgba(15, 23, 42, 0.075);
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.14);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Hiragino Maru Gothic ProN", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.52;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 14px;
}

/* 上ゾーンは面で主張させず、タブの境界と接続感で切り替え位置を見せる */
.top-zone {
  background: var(--top-zone);
  margin: -14px -14px 0;
  padding: 14px 14px 0;
  border-radius: 0;
}

.top-zone .view-tabs {
  margin-bottom: -1px;
}

.top-zone .settings-panel {
  margin-bottom: 12px;
}

#scannerPanel,
#historyPage,
#resultsPage {
  margin-top: 0;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 14px;
}

.header-title {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.header-title-main {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}

.header h1 {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 22px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header .app-version-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 22px;
  border: 1px solid #b8d7d1;
  border-radius: 999px;
  padding: 2px 8px;
  background: #ecfdf8;
  color: #35635b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.header span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  padding: 14px;
  box-shadow: var(--soft-shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.panel-heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}
/* 見出し内のボタンは文字幅に（モバイルの .btn{width:100%} を打ち消し、待機中などと横並びにする） */
.panel-heading-actions .btn {
  flex: 0 0 auto;
  width: auto;
}

.panel-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.history-delete-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.btn.compact {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.operation-actions {
  flex-wrap: nowrap;
  margin-top: 10px;
}

.operation-actions .btn {
  flex: 0 0 auto;
  width: auto;
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  touch-action: manipulation;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn:hover:not(:disabled),
.btn:focus-visible {
  box-shadow: var(--focus-ring);
  outline: 0;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.danger {
  background: #fff5f3;
  color: var(--danger);
  border-color: #f2b8b5;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--primary-dark);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
}

.icon-button:hover,
.icon-button:focus {
  border-color: var(--primary);
  background: #ecfdf3;
  box-shadow: var(--focus-ring);
  outline: 0;
}

.icon-button:active:not(:disabled) {
  transform: scale(0.98);
}

.status-line {
  margin-top: 8px;
  min-height: 24px;
  color: var(--muted);
  font-size: 15px;
}

.status-line:empty,
.status-line.is-empty {
  display: none;
}

.status-line.error {
  color: var(--danger);
  font-weight: 700;
}

.status-line.success {
  color: var(--success);
  font-weight: 700;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: #f8fafc;
  color: #344054;
}

.empty {
  color: var(--muted);
  padding: 8px 0;
  line-height: 1.5;
}
