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

:root {
  /* ベースカラー */
  --bg: #f8faf9;
  --bg-gradient-start: #f0f7f3;
  --bg-gradient-end: #f8faf9;
  --panel: #ffffff;
  --stroke: #d8e3dc;

  /* アクセントカラー */
  --primary: #2d7d4a;
  --primary-light: #4a9d68;
  --primary-subtle: #e8f5ed;
  --accent: #c9a961;

  /* テキストカラー */
  --text: #1a3326;
  --text-secondary: #5a7566;

  /* シャドウ */
  --shadow: 0 4px 12px rgba(45, 125, 74, 0.08);
  --shadow-strong: 0 8px 24px rgba(45, 125, 74, 0.12);
  --shadow-button: 0 4px 12px rgba(45, 125, 74, 0.2);

  --radius: 16px;
  --font-display: "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
}

.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(45, 125, 74, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(201, 169, 97, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* メッシュとグリッドは削除 */
.mesh,
.mesh-a,
.mesh-b,
.grid {
  display: none;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

h1 {
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: 0;
  font-feature-settings: "palt";
  line-height: 1.2;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
}

.lede {
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  margin: 2px 0 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-stack {
  margin-bottom: 12px;
}

.badge {
  padding: 10px 14px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(52, 197, 255, 0.08);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--stroke);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

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

.controls-top {
  align-items: flex-start;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.mode-buttons .btn {
  flex: 1;
  min-height: 50px;
  padding: 14px 20px;
  transition: all 200ms ease;
}

.mode-buttons .btn.active {
  background: var(--primary);
  border: none;
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow-button);
}

.mode-buttons .btn.active:hover:not(:disabled) {
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(45, 125, 74, 0.25);
}

.mode-buttons .btn:not(.active) {
  background: var(--primary-subtle);
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: none;
}

.mode-buttons .btn:not(.active):hover:not(:disabled) {
  background: #d4ede0;
  border-color: var(--primary-light);
  transform: none;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
  font-weight: 600;
}

h2 {
  margin: 2px 0 0;
  font-size: clamp(20px, 3vw, 26px);
  letter-spacing: 0;
  font-feature-settings: "palt";
  line-height: 1.2;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
}

select {
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 190px;
  font-family: var(--font-display);
  font-size: 15px;
  transition: border-color 200ms ease;
}

select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  border: 2px solid var(--stroke);
  border-radius: 12px;
  padding: 14px 20px;
  min-height: 50px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  transition: all 200ms ease;
  font-family: var(--font-display);
}

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

.btn.primary {
  background: var(--primary);
  border: none;
  color: #ffffff;
  box-shadow: var(--shadow-button);
}

.btn.primary:not(:disabled):hover {
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(45, 125, 74, 0.25);
}

.btn.primary:not(:disabled):active {
  transform: translateY(0);
}

.btn.ghost {
  background: transparent;
  border-color: var(--stroke);
  color: var(--text-secondary);
}

.btn.ghost:not(:disabled):hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.camera-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.scan-area {
  position: relative;
  width: 100%;
  min-height: 280px;
}

.camera-view {
  width: 100%;
  min-height: 280px;
  border: 2px dashed var(--stroke);
  border-radius: 14px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: var(--primary-subtle);
}

.camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  color: var(--text-secondary);
  font-size: 16px;
}

.callout {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.flash {
  color: #fefefe;
}

.duo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.dropzone {
  position: relative;
  border: 2px dashed var(--stroke);
  border-radius: 14px;
  min-height: 280px;
  display: grid;
  place-items: center;
  background: var(--primary-subtle);
  transition: all 200ms ease;
}

.hidden {
  display: none !important;
}

.dropzone.dragover {
  border-color: var(--primary);
  border-width: 3px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(45, 125, 74, 0.15);
}

#fileInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-content {
  text-align: center;
  pointer-events: none;
}

.caption {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 6px 0 0;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  transition: color 200ms ease;
}

.link-btn:hover {
  color: var(--primary-light);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 51, 38, 0.75);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
  padding: 24px 20px 20px;
  max-width: min(920px, 96vw);
  width: 96vw;
  max-height: none;
  overflow: visible;
  z-index: 1;
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 700;
}

.modal-card p {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
}

.modal-image {
  margin: 16px 0;
  border: 2px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}

.modal-image img {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  display: block;
  background: var(--primary-subtle);
}

.modal-note {
  color: var(--text-secondary);
  font-size: 15px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 2px solid var(--stroke);
  background: var(--panel);
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

/* タブレット・PC用レイアウト */
@media (min-width: 768px) {
  .shell {
    padding: 32px 24px 48px;
  }

  .hero {
    margin-bottom: 24px;
  }

  /* タブレット以上で横並びレイアウト */
  .main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }

  .scan-area,
  .camera-view,
  .dropzone {
    min-height: 320px;
  }

  .panel {
    padding: 28px;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 24px;
  }
}

@media (min-width: 1024px) {
  .scan-area,
  .camera-view,
  .dropzone {
    min-height: 360px;
  }
}

/* スマホ用レイアウト */
@media (max-width: 767px) {
  .shell {
    padding: 16px 12px 24px;
  }

  .panel {
    padding: 18px;
  }

  .panel-head {
    gap: 12px;
  }

  /* コントロールエリアを100%幅に */
  .controls {
    width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
  }

  /* select-wrapを横並びに */
  .select-wrap {
    flex: 1;
    min-width: 0;
  }

  /* selectを親に合わせる */
  select {
    width: 100%;
    min-width: 0;
    font-size: 14px;
    padding: 10px 12px;
  }

  /* 停止ボタンを固定幅に */
  .btn.ghost {
    flex-shrink: 0;
    min-width: 70px;
    padding: 10px 14px;
    font-size: 14px;
  }

  /* ヘルプボタンを全幅に */
  .link-btn {
    width: 100%;
    text-align: left;
    font-size: 14px;
  }

  .scan-area,
  .camera-view,
  .dropzone {
    min-height: 240px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  .modal-card {
    width: 94vw;
    padding: 20px 16px;
  }

  .modal-image img {
    max-height: 40vh;
  }

  .uid {
    font-size: 14px;
  }

  /* ボタンのフォントサイズ調整 */
  .mode-buttons .btn {
    font-size: 15px;
    padding: 12px 16px;
    min-height: 46px;
  }

  /* パネル間の余白を詰める */
  .panel {
    margin-bottom: 16px;
  }

  .result-stack {
    margin-bottom: 12px;
  }
}
.hint {
  color: var(--text-secondary);
  font-size: 15px;
}

.result-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.uid-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--primary-subtle);
  border-radius: 12px;
  border: 2px solid var(--stroke);
  min-height: 60px;
  transition: all 300ms ease;
}

.uid {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.02em;
  word-break: break-all;
  color: var(--text);
  flex: 1;
}

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  white-space: nowrap;
}

.pill.good {
  background: var(--primary);
  color: #ffffff;
}

.pill.bad {
  background: #d97343;
  color: #ffffff;
}

.pill.muted {
  background: var(--stroke);
  color: var(--text-secondary);
}

.alert {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.5;
}

.alert.bad {
  color: #d97343;
}

.alert.good {
  color: var(--primary);
}

.alert.muted {
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: var(--primary);
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 5;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.uid-box.success {
  background: #e8f5ed;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 125, 74, 0.1);
}

.uid-box.glow {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 125, 74, 0.2);
  animation: glowPulse 1s ease;
}

@keyframes glowPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 125, 74, 0.4);
  }
  60% {
    box-shadow: 0 0 0 10px rgba(45, 125, 74, 0.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(45, 125, 74, 0);
  }
}

