:root {
  /* 優しいライトモードのカラーパレット */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-focus: #10b981;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent-primary: #059669;
  --accent-primary-light: #ecfdf5;
  --accent-blue: #0284c7;
  --accent-blue-light: #f0f9ff;
  --accent-emerald: #10b981;
  --accent-amber: #d97706;
  --accent-amber-light: #fffbeb;
  --accent-rose: #e11d48;
  --accent-rose-light: #fff1f2;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-soft: 0 4px 18px -2px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 24px -4px rgba(15, 23, 42, 0.1);

  --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 12% 10%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 88% 18%, rgba(2, 132, 199, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(251, 146, 60, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
  padding-bottom: calc(var(--safe-area-bottom) + 70px);
}

/* App Container */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding: 1.1rem 1.1rem 2rem;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0 1.25rem;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: block;
  margin-top: -2px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s;
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: #cbd5e1;
}

/* Status Banner */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  color: var(--text-muted);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
}
.dot.warning { background: var(--accent-amber); }

/* Mode Switcher Tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
  background: #f1f5f9;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.mode-btn {
  padding: 0.65rem 0.3rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s;
}

.mode-btn.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Camera & Scanner Viewport */
.camera-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  border: 2px solid var(--border-subtle);
  aspect-ratio: 4 / 3;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scanner Overlay Reticle */
.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.reticle-frame {
  width: 72%;
  height: 55%;
  border: 2px dashed rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

/* Glowing Corners */
.reticle-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #10b981;
  border-style: solid;
}
.reticle-corner.tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 12px; }
.reticle-corner.tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 12px; }
.reticle-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 12px; }
.reticle-corner.br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 12px; }

/* Animated Scan Laser Line */
.scan-laser {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #10b981, #ffffff, #10b981, transparent);
  box-shadow: 0 0 10px #10b981;
  top: 15%;
  animation: laserScan 2.2s infinite ease-in-out alternate;
}

@keyframes laserScan {
  0% { top: 10%; opacity: 0.5; }
  100% { top: 90%; opacity: 1; }
}

.reticle-hint {
  position: absolute;
  bottom: 12px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

/* Camera Controls Floating Bar */
.camera-floating-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.cam-ctrl-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.cam-ctrl-btn.active {
  background: var(--accent-amber);
  color: #ffffff;
}

/* Card General */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-hover);
}

/* Form Styling */
.form-group {
  margin-bottom: 1.15rem;
  transition: opacity 0.2s, filter 0.2s;
}
.form-group.disabled {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.85);
  user-select: none;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.form-label-tag {
  font-size: 0.72rem;
  color: var(--accent-primary);
  background: var(--accent-primary-light);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

.form-input {
  flex: 1;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}
.form-input:focus {
  background: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-secondary {
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #e2e8f0;
}

/* Quick Date Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.chip {
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.chip:hover {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  border-color: rgba(16, 185, 129, 0.4);
}

/* Expiration Countdown Preview */
.expiry-preview {
  margin-top: 0.65rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.expiry-preview.warning {
  background: var(--accent-amber-light);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: var(--accent-amber);
}
.expiry-preview.danger {
  background: var(--accent-rose-light);
  border: 1px solid rgba(225, 29, 72, 0.25);
  color: var(--accent-rose);
}
.expiry-preview.safe {
  background: var(--accent-primary-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-primary);
}
.expiry-preview.infinity {
  background: #eef2ff;
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #4f46e5;
}

/* Category Selection Pills */
.category-row {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}
.cat-pill {
  flex: 1;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: all 0.2s;
}
.cat-pill.active {
  background: var(--accent-primary-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 700;
}

/* Main Action Submit Button */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.95rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Registered Items Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}
.count-badge {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
}

/* Items Category Tabs */
.category-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  gap: 0.25rem;
  margin-bottom: 0.85rem;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.tab-badge {
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 1.2rem;
  text-align: center;
}
.tab-btn.active .tab-badge {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

/* Items List Cards */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: all 0.2s;
}
.item-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.item-card.danger {
  border-left: 5px solid var(--accent-rose);
}
.item-card.warning {
  border-left: 5px solid var(--accent-amber);
}
.item-card.safe {
  border-left: 5px solid var(--accent-emerald);
}
.item-card.infinity {
  border-left: 5px solid #6366f1;
}

.item-info {
  flex: 1;
  min-width: 0;
  padding-right: 0.75rem;
}
.item-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.item-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.item-cat {
  background: #f1f5f9;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
}

.item-status {
  text-align: right;
  flex-shrink: 0;
}
.days-left {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}
.days-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  display: block;
  margin-top: 0.15rem;
}
.item-actions {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.35rem;
}
.btn-consume {
  border: 1px solid rgba(225, 29, 72, 0.25);
  background: #fff1f2;
  color: #e11d48;
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 1px 3px rgba(225, 29, 72, 0.08);
  transition: all 0.2s;
}
.btn-consume:hover, .btn-consume:active {
  background: #ffe4e6;
  border-color: #e11d48;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(225, 29, 72, 0.16);
}

.btn-mini {
  border: none;
  background: #f1f5f9;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-mini:hover {
  background: var(--accent-rose-light);
  color: var(--accent-rose);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

/* Modal Styling */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.toast-msg.show {
  transform: translateX(-50%) translateY(0);
}
