:root {
  --bg: #ece8e2;
  --bg-accent: #d9d1c7;
  --panel: rgba(250, 247, 243, 0.94);
  --border: #cfc4b7;
  --text: #34281f;
  --muted: #6f6358;
  --brand: #6c4f3d;
  --brand-strong: #4f392d;
  --brand-rgb: 108, 79, 61;
  --neutral-rgb: 104, 98, 91;
  --danger: #9d3f2c;
  --warning: #9a6700;
  --shadow: 0 20px 45px rgba(52, 40, 31, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  font-family: "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(128, 128, 128, 0.14), transparent 28%),
    linear-gradient(135deg, #d9d7d3 0%, #c8c4be 100%);
  color: var(--text);
}

body::before,
body::after {
  content: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: calc(100% - 40px);
  max-width: 1220px;
  margin: 0 auto;
  padding: 26px 0 34px;
}

.hero {
  margin-bottom: 18px;
  padding: 22px 28px 20px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(250, 247, 243, 0.78) 0%, rgba(247, 240, 232, 0.44) 100%);
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 24px 54px rgba(52, 40, 31, 0.12);
  backdrop-filter: blur(10px);
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px);
  gap: 24px;
  align-items: start;
}

.hero-content {
  min-width: 0;
}

.hidden {
  display: none !important;
}

.auth-card {
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 252, 248, 0.72);
  border: 1px solid rgba(220, 208, 195, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.auth-state {
  display: grid;
  gap: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(249, 243, 236, 0.72);
}

.auth-tab {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  transition: background 0.18s ease, color 0.18s ease;
}

.auth-tab.active {
  background: var(--brand-strong);
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field-label {
  margin: 0;
}

.auth-input {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(108, 79, 61, 0.18);
  border-radius: 18px;
  padding: 13px 16px;
  font-size: 0.98rem;
  background: rgba(255, 255, 255, 0.82);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(var(--brand-rgb), 0.12);
}

.auth-submit {
  width: 100%;
}

.auth-status,
.auth-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-status {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(249, 243, 236, 0.58);
}

.auth-status.warning {
  color: var(--warning);
}

.auth-status.danger {
  color: var(--danger);
}

.auth-status.success {
  color: #2d6a4f;
}

.auth-session-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.auth-heading {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.app-shell[data-auth-locked="true"] .scanner-panel,
.app-shell[data-auth-locked="true"] .result-panel {
  opacity: 0.68;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brand);
}

.hero h1 {
  margin: 0;
  max-width: 8.5ch;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 50rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding-top: 0;
}

.panel {
  background: rgba(250, 247, 243, 0.76);
  border: 1px solid rgba(214, 202, 188, 0.84);
  border-radius: 28px;
  box-shadow: 0 22px 48px rgba(52, 40, 31, 0.12);
  backdrop-filter: blur(10px);
}

.scanner-panel,
.result-panel,
.history-panel {
  padding: 22px;
}

.scanner-panel {
  margin-bottom: 18px;
  background: linear-gradient(180deg, rgba(252, 248, 243, 0.9) 0%, rgba(249, 243, 236, 0.78) 100%);
}

.scanner-panel .panel-header {
  align-items: center;
}

.scanner-panel .panel-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.scanner-header-actions,
.camera-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hidden-file-input {
  display: none;
}

.field-label {
  display: inline-block;
  margin: 14px 0 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.scanner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.scanner-input {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(108, 79, 61, 0.2);
  border-radius: 22px;
  padding: 15px 18px;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.scanner-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(var(--brand-rgb), 0.14);
}

.action-button,
.secondary-button,
.mode-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.action-button:hover,
.secondary-button:hover,
.mode-button:hover {
  transform: translateY(-1px);
}

.action-button {
  min-height: 58px;
  padding: 0 22px;
  border-radius: 22px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: 0 14px 28px rgba(79, 57, 45, 0.18);
}

.secondary-button {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--brand-strong);
  font-weight: 700;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 18px;
  background: rgba(79, 57, 45, 0.1);
  box-shadow: inset 0 0 0 1px rgba(79, 57, 45, 0.08);
}

.button-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.button-hidden {
  display: none;
}

.mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: fit-content;
  margin-top: 14px;
  padding: 4px;
  border-radius: 24px;
  background: rgba(249, 243, 236, 0.52);
}

.mode-button {
  min-height: 46px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.94rem;
}

.mode-button.active {
  background: var(--brand-strong);
  color: #fff;
}

.scanner-status {
  display: none;
}

.scanner-status.warning {
  display: none;
}

.scanner-status.danger {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(249, 243, 236, 0.84);
  color: var(--brand-strong);
  font-weight: 700;
  white-space: normal;
  font-size: 0.92rem;
}

.result-card {
  min-height: 180px;
  margin-top: 14px;
  border-radius: 24px;
  padding: 18px;
  background: rgba(252, 248, 243, 0.62);
  border: 1px solid rgba(221, 207, 191, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.result-card.empty {
  display: grid;
  place-items: center;
}

.result-placeholder {
  margin: 0;
  max-width: 18ch;
  color: var(--muted);
  text-align: center;
  font-size: 1.08rem;
  line-height: 1.45;
}

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

.result-product-name {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
}

.result-status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-box {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(221, 211, 200, 0.5);
}

.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.detail-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.history-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #e2d8cd;
}

.history-item.pending {
  border-color: rgba(var(--brand-rgb), 0.3);
  background: rgba(var(--neutral-rgb), 0.1);
  animation: syncPulse 1.1s ease-in-out infinite alternate;
}

.history-item.failed {
  border-color: rgba(157, 63, 44, 0.32);
  background: rgba(157, 63, 44, 0.08);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.camera-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.camera-modal.hidden {
  display: none;
}

.camera-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(47, 36, 25, 0.42);
  backdrop-filter: blur(8px);
}

.camera-modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(840px, 100%);
  padding: 24px;
  border-radius: 30px;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid rgba(210, 195, 175, 0.82);
  box-shadow: 0 30px 60px rgba(24, 18, 14, 0.2);
}

.camera-modal-card .panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 8px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98) 82%, rgba(255, 252, 247, 0));
}

.camera-stage {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 10;
  min-height: 340px;
  border-radius: 26px;
  overflow: hidden;
  background: #1f1a15;
}

.camera-preview {
  width: 100%;
  height: 100%;
  display: block;
  background: #1f1a15;
}

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

.camera-frame {
  position: absolute;
  inset: 18% 14%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 22px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.16);
}

@keyframes syncPulse {
  from {
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(var(--brand-rgb), 0);
  }

  to {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(var(--brand-rgb), 0.12);
  }
}

@media (min-width: 1080px) {
  .hero {
    margin-bottom: 20px;
  }

  .scanner-panel,
  .result-panel,
  .history-panel {
    padding: 22px;
  }

  .content-grid {
    align-items: start;
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: calc(100% - 28px);
    padding: 28px 0 36px;
  }

  .hero-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    margin-bottom: 18px;
    padding: 24px 22px 22px;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 8vw, 3rem);
  }

  .hero-copy {
    max-width: none;
    font-size: 0.98rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  .scanner-row {
    grid-template-columns: 1fr;
  }

  .action-button {
    min-height: 52px;
  }

  .camera-modal-card {
    padding: 20px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .result-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-header {
    flex-direction: column;
  }

  .panel-header .badge {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 20px);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 30px;
  }

  .scanner-panel,
  .result-panel,
  .history-panel {
    padding: 18px;
  }

  body {
    background: linear-gradient(180deg, #efe7dc 0%, #e5dbcf 100%);
  }

  body::before,
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
  }

  body::before {
    z-index: 0;
    background: url("./assets/mobile-background.jpeg") center 18% / cover no-repeat;
    opacity: 0.78;
  }

  body::after {
    z-index: 0;
    background: linear-gradient(180deg, rgba(245, 240, 234, 0.08) 0%, rgba(229, 219, 207, 0.14) 100%);
  }

  .app-shell {
    position: relative;
    z-index: 1;
  }

  .hero {
    margin-bottom: 18px;
    padding: 8px 6px 6px;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .hero-layout {
    gap: 14px;
  }

  .auth-card {
    padding: 14px;
    border-radius: 24px;
    background: rgba(250, 247, 243, 0.5);
  }

  .auth-session-head {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-tabs {
    border-radius: 16px;
  }

  .eyebrow {
    margin-bottom: 10px;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    color: rgba(255, 255, 255, 0.94);
    text-shadow: 0 2px 12px rgba(24, 18, 14, 0.42);
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(1.9rem, 7.2vw, 2.35rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    text-shadow: 0 8px 24px rgba(245, 238, 230, 0.16);
  }

  .hero-copy {
    display: none;
  }

  .scanner-header-actions,
  .camera-actions {
    width: auto;
    flex-direction: row;
  }

  .scanner-panel {
    margin-bottom: 18px;
    background: linear-gradient(180deg, rgba(252, 248, 243, 0.84) 0%, rgba(250, 245, 239, 0.74) 100%);
    border-color: rgba(230, 219, 206, 0.8);
    box-shadow: 0 20px 36px rgba(52, 40, 31, 0.16);
  }

  .panel {
    border-radius: 28px;
    background: rgba(250, 247, 243, 0.34);
    backdrop-filter: none;
    border-color: rgba(207, 196, 183, 0.42);
    box-shadow: 0 14px 32px rgba(52, 40, 31, 0.12);
  }

  .scanner-panel .panel-header {
    flex-direction: row;
    align-items: center;
  }

  .scanner-panel .panel-header > div:first-child {
    flex: 1;
    min-width: 0;
  }

  .panel-header h2 {
    font-size: 1.22rem;
    letter-spacing: -0.02em;
  }

  .panel-header p {
    font-size: 0.94rem;
    line-height: 1.45;
    max-width: 19rem;
  }

  .field-label {
    margin-top: 18px;
    font-size: 1rem;
  }

  .icon-button {
    min-width: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 18px;
    background: rgba(79, 57, 45, 0.12);
    box-shadow: inset 0 0 0 1px rgba(79, 57, 45, 0.08);
  }

  .scanner-input {
    min-height: 58px;
    padding: 15px 18px;
    font-size: 1.02rem;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 20px;
    border-color: rgba(108, 79, 61, 0.24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  }

  .scanner-row {
    gap: 10px;
  }

  .action-button {
    min-height: 58px;
    border-radius: 20px;
    font-size: 1.05rem;
    box-shadow: 0 12px 24px rgba(79, 57, 45, 0.18);
  }

  .mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 2px;
    margin-top: 14px;
    padding: 6px;
    border-radius: 24px;
    background: rgba(249, 243, 236, 0.34);
  }

  .mode-button {
    min-height: 50px;
    padding: 12px 10px;
    text-align: center;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.25;
    background: rgba(255, 255, 255, 0.4);
  }

  .mode-button:last-child {
    grid-column: 1 / -1;
  }

  .scanner-status {
    margin-top: 14px;
    padding: 12px 14px;
    font-size: 0.92rem;
  }

  .badge {
    display: none;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.35;
    background: rgba(255, 248, 241, 0.28);
  }

  .result-card {
    min-height: 180px;
    margin-top: 14px;
    padding: 18px;
    border-radius: 24px;
    background: rgba(252, 248, 243, 0.48);
    border-color: rgba(221, 207, 191, 0.4);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }

  .result-product-name {
    font-size: 1.55rem;
    line-height: 1.04;
  }

  .result-placeholder {
    max-width: 14ch;
    font-size: 1.05rem;
    line-height: 1.4;
    color: rgba(52, 40, 31, 0.76);
  }

  .result-status {
    font-size: 0.94rem;
    line-height: 1.45;
  }

  .detail-box {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.42);
    border-color: rgba(221, 211, 200, 0.42);
  }

  .detail-box strong {
    font-size: 1rem;
    word-break: break-word;
  }

  .history-list {
    margin-top: 16px;
    gap: 10px;
  }

  .history-item {
    padding: 12px 14px;
  }

  .history-item strong {
    font-size: 1rem;
    line-height: 1.3;
  }

  .history-item span {
    font-size: 0.9rem;
    word-break: break-word;
  }

  .camera-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    padding: 8px;
    align-items: stretch;
  }

  .camera-modal-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-height: calc(100dvh - 16px);
    overflow: auto;
    padding: 18px;
    border-radius: 28px;
    margin-top: max(4px, env(safe-area-inset-top));
  }

  .camera-modal-card .panel-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-bottom: 8px;
    background: linear-gradient(180deg, rgba(255, 252, 247, 0.98) 78%, rgba(255, 252, 247, 0));
  }

  .secondary-button,
  .mode-button {
    background: rgba(239, 231, 222, 0.32);
    backdrop-filter: none;
  }

  .mode-button.active,
  .action-button {
    background: rgba(108, 79, 61, 0.84);
  }

  .camera-stage {
    margin: 0;
    aspect-ratio: 4 / 3;
    min-height: 280px;
    border-radius: 24px;
  }

  .camera-frame {
    inset: 20% 10%;
    border-radius: 18px;
  }

  .camera-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    bottom: 0;
    padding-top: 8px;
    background: linear-gradient(180deg, rgba(255, 252, 247, 0) 0%, rgba(255, 252, 247, 0.98) 28%);
  }

  .camera-actions .secondary-button,
  .camera-actions .action-button {
    width: 100%;
    min-height: 50px;
    border-radius: 18px;
  }
}
