:root {
  color-scheme: dark;
  --bg: #1b1f24;
  --surface: #20252b;
  --surface-2: #262c33;
  --text: #f3f5f7;
  --muted: #a0a7b0;
  --accent: #c24434;
  --accent-2: #4bb8a5;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --chip-bg: rgba(255, 255, 255, 0.08);
  --font-sans: "SF Pro Text", "SF Pro Display", "IBM Plex Sans", "Avenir Next", "Avenir",
    "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg: #1b1f24;
  --surface: #20252b;
  --surface-2: #262c33;
  --text: #f3f5f7;
  --muted: #a0a7b0;
  --accent: #c24434;
  --accent-2: #4bb8a5;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --chip-bg: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100svh;
}

.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100svh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: calc(12px + env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
    env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
  gap: 16px;
}

.chat {
  display: none;
}

.chat.is-visible {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 8px;
  box-shadow: var(--shadow);
}

.message {
  padding: 12px 14px;
  border-radius: 16px;
  max-width: 90%;
  line-height: 1.4;
  animation: rise 0.4s ease;
}

.message.assistant {
  background: var(--surface-2);
  border: 1px solid var(--line);
  align-self: flex-start;
}

.message.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
}

.panel-list {
  display: grid;
  gap: 0;
}

.result-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.result-card h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
}

.result-card.is-list {
  display: block;
  padding: 8px 4px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.result-card.is-list h4 {
  font-size: 13px;
  font-weight: 400;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 68px;
  align-items: start;
  gap: 8px;
}

.list-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 68px;
  align-items: center;
  gap: 8px;
  padding: 0 4px 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}

.list-header span:nth-child(2) {
  text-align: center;
}

.list-header span:nth-child(3) {
  text-align: right;
}

.list-name {
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.3;
}

.list-stock {
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 400;
}

.list-location {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}

.list-content {
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
  will-change: transform;
  width: 100%;
}

.swipe-underlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.swipe-underlay.is-active {
  opacity: 1;
}

.swipe-underlay[data-dir="left"] {
  background: var(--accent);
  justify-content: flex-end;
}

.swipe-underlay[data-dir="right"] {
  background: var(--accent-2);
  justify-content: flex-start;
}

.result-card.is-list:first-child {
  border-top: 1px solid var(--line);
}

.result-card.is-selected {
  border-color: rgba(194, 68, 52, 0.6);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.35);
  transform: scale(1.01);
}

.result-card.is-list.is-selected {
  background: rgba(194, 68, 52, 0.08);
  border-bottom-color: rgba(194, 68, 52, 0.4);
  transform: none;
  box-shadow: none;
}

.result-card.is-list.is-selected:first-child {
  border-top-color: rgba(194, 68, 52, 0.4);
}
.result-card.is-fullscreen {
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: none;
  min-height: calc(100% - 2px);
  transform: none;
  padding: 14px;
  gap: 12px;
}

.result-card.is-fullscreen h4 {
  font-size: 20px;
  white-space: normal;
  overflow: visible;
}

.result-card.is-fullscreen .result-meta {
  display: none;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.card-header h4 {
  flex: 1;
  min-width: 0;
}

.stock-badge {
  font-size: 14px;
  color: var(--text);
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}

.result-card.is-list .stock-badge {
  font-size: 12px;
  padding: 0;
}

.result-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.result-meta span {
  background: var(--chip-bg);
  padding: 4px 8px;
  border-radius: 999px;
}

.result-details {
  display: none;
  gap: 10px;
  margin-top: 8px;
}

.result-card.is-fullscreen .result-details {
  gap: 14px;
  margin-top: 4px;
}

.result-card.is-selected .result-details {
  display: grid;
}

.result-card.is-fullscreen .result-details {
  display: grid;
}

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

.detail-line strong {
  color: var(--text);
}

.result-card.is-fullscreen .detail-line {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-card.is-fullscreen .detail-line strong {
  font-weight: 500;
}

.adjust-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.adjust-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

.adjust-value {
  min-width: 54px;
  text-align: center;
  font-weight: 600;
}

.commit-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  padding: 8px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

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

.commit-btn svg {
  width: 18px;
  height: 18px;
}

.commit-btn--danger {
  border-color: rgba(194, 68, 52, 0.5);
  color: var(--accent);
}

.detail-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

.detail-form {
  display: grid;
  gap: 10px;
}

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

.result-card.is-fullscreen .detail-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.detail-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.detail-field label {
  font-weight: 600;
  color: var(--muted);
}

.result-card.is-fullscreen .detail-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-field input {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.result-card.is-fullscreen .detail-field input {
  border: none;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 6px 0;
  background: transparent;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.result-card.is-fullscreen .detail-actions {
  justify-content: flex-end;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.inline-form--synonym {
  flex-wrap: nowrap;
}

.inline-form input {
  flex: 1 1 140px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.result-card.is-fullscreen .inline-form input {
  border: none;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 6px 0;
  background: transparent;
}

.inline-form .commit-btn {
  margin-left: 0;
  flex: 0 0 auto;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip-bg);
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
}

.result-card.is-fullscreen .chip {
  background: transparent;
  border: 1px solid var(--line);
}

.chip-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--accent);
}

.panel {
  background: var(--surface);
  background-image: url("/Logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: clamp(160px, 40vw, 280px);
  border-radius: var(--radius);
  padding: 12px 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.panel.is-hidden {
  display: none;
}

.panel.fullscreen {
  padding: 14px 10px;
}

.panel-empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 22px 0;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.panel .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.panel .details {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.details strong {
  color: var(--text);
}

.location {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.location-graphic {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.location-graphic span {
  background: var(--line);
  padding: 16px 0;
  border-radius: 8px;
}

.location-graphic .highlight {
  background: var(--accent-2);
}

.take-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.take-form input {
  width: 80px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.take-form button {
  flex: 1;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
}

@media (display-mode: standalone) {
  .app {
    padding-bottom: 0;
  }

  .composer {
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
}

.composer input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
}

.composer input.keyword-active {
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.slash-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.keyword-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 4;
}

.keyword-menu.is-visible {
  display: grid;
  gap: 4px;
}

.keyword-item {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.keyword-item:hover,
.keyword-item:focus {
  outline: none;
  background: var(--surface-2);
}

.keyword-item span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.flash-success::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(72, 199, 116, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 3;
}

.flash-success.is-active::after {
  opacity: 1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    max-width: 100%;
    margin: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1f24;
    --surface: #20252b;
    --surface-2: #262c33;
    --text: #f3f5f7;
    --muted: #a0a7b0;
    --accent: #c24434;
    --accent-2: #4bb8a5;
    --shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --chip-bg: rgba(255, 255, 255, 0.08);
  }
}
