:root {
  color-scheme: light;
  --bg: #fbf6f8;
  --ink: #2a2024;
  --muted: #7a6b72;
  --line: #eadde2;
  --panel: #fffdfc;
  --accent: #9b5f73;
  --accent-ink: #ffffff;
  --quick-bg: #fff7f8;
  --quick-border: #e7b8c4;
  --quick-ink: #7f4b5d;
  --quick-hover: #f7e8ee;
  --danger: #a4493c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--accent-ink);
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

button:disabled:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 26vw);
  min-height: 100vh;
}

.catalog-pane {
  padding: 32px;
  border-right: 1px solid var(--line);
}

.chat-pane {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: clamp(320px, 26vw, 380px);
  height: 100vh;
  max-height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: hidden;
  z-index: 10;
}

.chat-tools {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  display: flex;
  gap: 6px;
}

.chat-collapse,
.chat-new,
.login-button {
  width: auto;
  min-width: 84px;
  min-height: 36px;
  padding: 0 12px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chat-collapse,
.chat-new {
  width: 36px;
  min-width: 36px;
  padding: 0;
  border-color: #c86d8a;
  background: #b94f74;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 8px 18px rgba(185, 79, 116, 0.24);
}

.chat-collapse {
  width: 36px;
  background: #b94f74;
}

.chat-new {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: none;
}

.chat-new:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-collapse:hover {
  border-color: #a83f64;
  background: #a83f64;
}

.login-button {
  min-width: 0;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.login-button.is-logged-in {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.topbar,
.chat-header,
.search-row,
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(32px, 5vw, 64px);
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h1 a:hover {
  color: var(--accent);
}

h2 {
  font-size: 24px;
}

.search-row {
  margin: 28px 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 12px;
  outline-color: var(--accent);
}

.search-row select {
  width: auto;
  min-width: 112px;
}

#searchBtn {
  min-width: 84px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.product-empty {
  grid-column: 1 / -1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border: 1px dashed var(--line);
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.product-empty strong {
  color: var(--ink);
  font-size: 18px;
}

.product {
  display: grid;
  grid-template-rows: 180px auto;
  min-height: 360px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
}

.product-image-link {
  display: block;
  min-width: 0;
}

.product img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #e8e1d8;
  display: block;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.product h3 a {
  color: inherit;
  text-decoration: none;
}

.product h3 a:hover {
  color: var(--accent);
}

.product p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.meta button {
  min-height: 36px;
  min-width: 82px;
  padding: 0 12px;
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.meta button:hover {
  background: var(--accent);
  color: #fff;
}

.chat-header {
  padding: 24px 72px 24px 24px;
  border-bottom: 1px solid var(--line);
}

.chat-header .eyebrow,
.chat-header h2 {
  white-space: nowrap;
}

#statusBadge,
#conversationBadge {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.badges {
  display: grid;
  gap: 6px;
  justify-items: end;
  white-space: nowrap;
}

#conversationBadge {
  color: var(--ink);
}

#statusBadge[data-status="human_handoff"] {
  color: #a34b00;
}

.selected-products {
  min-height: 46px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.selected-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.selected-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.selected-chip {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 24px;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
}

.selected-thumbnail {
  width: 34px;
  height: 100%;
  min-height: 38px;
  object-fit: cover;
  background: #e8e1d8;
}

.selected-details {
  min-width: 0;
  display: grid;
  align-content: center;
}

.selected-details span {
  min-width: 0;
  padding: 6px 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-details small {
  padding: 0 8px 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-list a {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-decoration: none;
}

.selected-list a.selected-details {
  display: grid;
}

.selected-list a:hover {
  color: var(--accent);
}

.selected-chip:hover {
  border-color: var(--accent);
}

.selected-remove {
  min-height: 0;
  width: 24px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
}

.selected-remove:hover {
  background: #f7e9e5;
  border-color: var(--line);
  color: var(--danger);
  transform: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
  padding: 20px 24px;
}

.message {
  max-width: 88%;
  padding: 12px 14px;
  line-height: 1.5;
  background: #f8edf1;
  white-space: pre-line;
}

.collapsed-reply {
  display: none;
}

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

.message.loading {
  color: var(--muted);
}

.message.streaming::after {
  content: "▍";
  animation: streaming-caret 1s steps(2) infinite;
}

@keyframes streaming-caret {
  50% {
    opacity: 0;
  }
}

.message.chat-error {
  border-left: 3px solid #c0392b;
}

.chat-retry-btn {
  margin-top: 8px;
  padding: 6px 16px;
  border: 1px solid #c0392b;
  background: #fff;
  color: #c0392b;
  cursor: pointer;
}

.chat-retry-btn:hover {
  background: #c0392b;
  color: #fff;
}

.chat-form {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 24px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.chat-form textarea {
  min-height: 76px;
  max-height: 110px;
  resize: vertical;
}

.quick-phrases,
.autocomplete-box {
  width: 100%;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  padding-bottom: 2px;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}

.quick-phrases::-webkit-scrollbar,
.autocomplete-box::-webkit-scrollbar {
  display: none;
}

.quick-phrases.is-hidden {
  display: none;
}

.quick-phrases button,
.autocomplete-box button {
  flex: 0 0 auto;
  width: auto;
  height: 28px;
  min-height: 0;
  min-width: 0;
  max-width: min(170px, 82%);
  aspect-ratio: auto;
  padding: 0 10px;
  border-color: var(--quick-border);
  border-radius: 999px;
  background: var(--quick-bg);
  color: var(--quick-ink);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-phrases button:hover,
.autocomplete-box button:hover {
  border-color: var(--accent);
  background: var(--quick-hover);
  color: var(--accent);
  transform: none;
}

.autocomplete-box[hidden] {
  display: none;
}

.login-dialog {
  width: min(360px, calc(100vw - 28px));
  border: 1px solid var(--line);
  padding: 0;
  background: var(--panel);
  color: var(--ink);
}

.login-dialog::backdrop {
  background: rgba(24, 21, 18, 0.38);
}

.login-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-header h3,
.login-panel p {
  margin: 0;
}

.login-header h3 {
  font-size: 18px;
}

.login-panel p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.login-header button,
.login-panel > button {
  min-height: 36px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.manual-review-note {
  grid-column: 1 / -1;
  margin: 0;
  color: #6c5548;
  font-size: 12px;
  line-height: 1.45;
  text-wrap: balance;
}

.actions button {
  min-width: 104px;
}

#chatSubmitBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 100%;
  background: var(--accent);
  border-color: var(--accent);
}

#chatSubmitBtn:hover {
  background: #864d61;
  border-color: #864d61;
}

.order-action[hidden] {
  display: none;
}

.primary-order {
  min-width: 92px;
  background: #6f7f5f;
  color: #fff;
  border-color: #6f7f5f;
}

.primary-order:disabled {
  display: none;
}

.help-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  padding: 0;
  background: var(--panel);
  color: var(--ink);
}

.order-confirm-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100svh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.order-confirm-dialog::backdrop {
  background: rgb(28 23 24 / 55%);
}

.order-confirm-panel {
  display: grid;
  max-height: calc(100svh - 26px);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.order-confirm-body {
  overflow-y: auto;
  padding: 18px;
}

.order-checkout-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.order-checkout-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-checkout-fields input,
.order-checkout-fields select,
.order-checkout-fields textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.order-checkout-fields textarea {
  resize: vertical;
}

.order-field-wide {
  grid-column: 1 / -1;
}

.order-confirm-error {
  margin: 0 0 12px;
  color: #9f2f3f;
  font-size: 13px;
  font-weight: 700;
}

.order-confirm-items {
  display: grid;
  gap: 8px;
}

.order-confirm-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.order-confirm-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  background: #e8e1d8;
}

.order-confirm-item div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.order-confirm-item span,
.order-confirm-body > p {
  color: var(--muted);
  font-size: 12px;
}

.order-confirm-totals,
.order-confirm-customer {
  display: grid;
  grid-template-columns: minmax(100px, 0.4fr) minmax(0, 1fr);
  gap: 6px 12px;
  margin: 16px 0 0;
}

.order-confirm-totals dd,
.order-confirm-customer dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.order-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.help-dialog::backdrop {
  background: rgba(24, 21, 18, 0.38);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.help-header h3 {
  margin: 0;
  font-size: 20px;
}

.help-header button {
  min-height: 34px;
  padding: 0 10px;
}

.help-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.help-body h4,
.help-body p {
  margin: 0;
}

.help-body h4 {
  font-size: 15px;
}

.help-body p {
  color: var(--muted);
  line-height: 1.6;
}

.image-preview-dialog {
  width: min(860px, calc(100vw - 24px));
  border: 1px solid var(--line);
  padding: 0;
  background: var(--panel);
  color: var(--ink);
}

.image-preview-dialog::backdrop {
  background: rgba(42, 32, 36, 0.56);
}

.image-preview-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.image-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-preview-header h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.image-preview-header button {
  min-height: 34px;
  padding: 0 12px;
  border-color: var(--quick-border);
  background: var(--quick-bg);
  color: var(--quick-ink);
}

.preview-stage {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
}

.preview-image-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(64vh, 620px);
  background: #f5eef1;
  touch-action: pan-y;
  user-select: none;
}

.preview-stage img {
  width: 100%;
  height: min(64vh, 620px);
  object-fit: contain;
  background: #f5eef1;
}

.preview-image-status {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.preview-nav {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-color: var(--quick-border);
  background: var(--quick-bg);
  color: var(--quick-ink);
  font-size: 30px;
}

.preview-nav:disabled {
  visibility: hidden;
}

.preview-counter {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.preview-thumbnails {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.preview-thumbnails button {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  min-height: 0;
  padding: 0;
  border: 2px solid transparent;
  background: #f5eef1;
}

.preview-thumbnails button.active {
  border-color: var(--accent);
}

.preview-thumbnails img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.preview-share {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.preview-share-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.preview-share-button,
.preview-share button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.preview-share-button:hover,
.preview-share button:hover {
  transform: translateY(-1px);
  filter: brightness(0.94);
}

.share-line {
  background: #06c755;
  font-size: 8px;
}

.share-facebook {
  background: #1877f2;
  font-family: Arial, sans-serif;
  font-size: 21px;
}

.share-email {
  background: #765e69;
}

.share-copy {
  background: var(--accent);
  font-size: 9px;
}

.share-copy.is-copied {
  background: #4f8b70;
  font-size: 15px;
}

.preview-copy-status {
  color: var(--quick-ink);
  font-size: 11px;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  justify-content: center;
}

.preview-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.preview-actions a:hover {
  background: var(--accent-strong);
}

@media (min-width: 921px) and (max-width: 1360px) {
  .chat-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .badges {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
  }
}

@media (max-width: 920px) {
  .workspace {
    --mobile-chat-height: 52svh;

    display: block;
    min-height: 100svh;
  }

  .catalog-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    padding-bottom: calc(var(--mobile-chat-height) + 16px);
  }

  .chat-pane {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: 100%;
    height: var(--mobile-chat-height);
    max-height: var(--mobile-chat-height);
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .chat-pane.is-collapsed {
    height: 104px;
    max-height: 104px;
  }

  .chat-pane.is-collapsed .selected-products,
  .chat-pane.is-collapsed .messages {
    display: none;
  }

  .chat-tools {
    position: absolute;
    top: auto;
    right: 10px;
    bottom: auto;
    z-index: 40;
  }

  .chat-collapse,
  .chat-new,
  .login-button {
    width: auto;
    min-height: 44px;
    padding: 0 14px;
    border-color: var(--quick-border);
    background: var(--quick-bg);
    color: var(--quick-ink);
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(127, 75, 93, 0.14);
  }

  .chat-collapse,
  .chat-new {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .chat-collapse {
    border-color: #c86d8a;
    background: #b94f74;
    color: #fff;
    box-shadow: 0 8px 18px rgba(185, 79, 116, 0.28);
  }

  .login-button {
    min-width: 76px;
  }

  .topbar {
    min-height: 22px;
    align-items: center;
  }

  .topbar .eyebrow,
  .chat-header {
    display: none;
  }

  h1 {
    display: block;
    font-size: 22px;
    line-height: 1;
  }

  h2 {
    font-size: 18px;
  }

  .search-row {
    position: sticky;
    top: 0;
    z-index: 8;
    margin: 12px 0;
    padding: 8px 0;
    background: var(--bg);
    gap: 6px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .search-row select {
    flex: 0 0 88px;
    min-width: 88px;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 14px;
  }

  .search-row input {
    min-width: 0;
    min-height: 44px;
    padding: 10px;
  }

  #searchBtn {
    flex: 0 0 64px;
    min-width: 64px;
    min-height: 44px;
    padding: 0 8px;
    font-size: 14px;
  }

  .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .product {
    grid-template-rows: 132px auto;
    min-height: 218px;
  }

  .product img,
  .product-image-link {
    width: 100%;
    height: 132px;
  }

  .product-body {
    gap: 7px;
    padding: 8px;
    min-width: 0;
  }

  .product h3 {
    font-size: 13px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product p {
    display: none;
  }

  .meta {
    display: flex;
    gap: 6px;
    font-size: 13px;
  }

  .meta button {
    min-height: 44px;
    min-width: 72px;
    padding: 0 10px;
    font-size: 12px;
  }

  .selected-products {
    min-height: 44px;
    padding: 7px 110px 7px 12px;
    font-size: 13px;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .selected-label {
    display: none;
  }

  .selected-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .selected-list::-webkit-scrollbar {
    display: none;
  }

  .selected-chip {
    flex: 0 0 100%;
    grid-template-columns: 36px minmax(0, 1fr) 44px;
    scroll-snap-align: start;
  }

  .selected-thumbnail {
    width: 36px;
    min-height: 44px;
  }

  .selected-list a {
    min-height: 44px;
    font-size: 11px;
  }

  .selected-details span {
    padding: 5px 6px 0;
  }

  .selected-details small {
    padding: 0 6px 5px;
  }

  .selected-remove {
    width: 44px;
    min-width: 44px;
    font-size: 16px;
  }

  .messages {
    gap: 6px;
    padding: 8px 12px 6px;
  }

  .message {
    max-width: 94%;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.4;
  }

  .chat-form {
    gap: 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    align-content: start;
    align-items: start;
    padding: 7px 12px max(9px, env(safe-area-inset-bottom));
  }

  .chat-form textarea {
    grid-column: 1 / -1;
    min-height: 38px;
    max-height: 58px;
    resize: none;
    padding: 8px;
    font-size: 16px;
    line-height: 1.35;
  }

  .quick-phrases,
  .autocomplete-box {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 5px;
    padding-bottom: 0;
    scrollbar-width: none;
  }

  .quick-phrases {
    display: flex;
    flex-wrap: nowrap;
    max-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .quick-phrases::-webkit-scrollbar {
    display: none;
  }

  .autocomplete-box {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .autocomplete-box::-webkit-scrollbar {
    display: none;
  }

  .quick-phrases button,
  .autocomplete-box button {
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
    height: 44px;
    aspect-ratio: auto;
    min-height: 44px;
    min-width: 44px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .actions {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    justify-self: stretch;
    align-self: stretch;
  }

  .quick-phrases.is-hidden + .autocomplete-box + .actions {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .actions button {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 0 9px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1;
  }

  #helpBtn,
  #chatSubmitBtn {
    width: 100%;
  }

  #chatSubmitBtn {
    flex: unset;
  }

  .actions .order-action {
    display: none;
  }

  .actions .primary-order:not(:disabled) {
    display: flex;
    grid-column: 1 / -1;
    justify-content: center;
  }

  .chat-pane.is-collapsed .collapsed-reply {
    display: block;
    margin: 8px 112px 0 12px;
    padding: 7px 9px;
    border: 1px solid var(--quick-border);
    border-radius: 12px;
    background: #fff7f8;
    color: #6d4452;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-pane.is-collapsed .quick-phrases,
  .chat-pane.is-collapsed .autocomplete-box {
    display: none;
  }

  .chat-pane.is-collapsed .chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    padding-top: 6px;
  }

  .chat-pane.is-collapsed .chat-form textarea {
    grid-column: 1 / 2;
    grid-row: 1;
    min-height: 44px;
    max-height: 44px;
  }

  .chat-pane.is-collapsed .actions {
    grid-column: 2 / 3;
    grid-row: 1;
    grid-template-columns: 1fr;
    width: 92px;
  }

  .chat-pane.is-collapsed .quick-phrases.is-hidden + .autocomplete-box + .actions {
    grid-column: 2 / 3;
    justify-self: end;
  }

  .chat-pane.is-collapsed #helpBtn {
    display: none;
  }

  .chat-pane.is-collapsed .actions .primary-order {
    display: none;
  }

  .image-preview-dialog {
    width: calc(100vw - 14px);
    max-height: calc(100svh - 18px);
  }

  .image-preview-panel {
    gap: 10px;
    padding: 10px;
  }

  .preview-stage {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 4px;
  }

  .preview-stage img {
    height: min(58vh, 520px);
  }

  .preview-nav {
    width: 34px;
    min-height: 38px;
    font-size: 26px;
  }

  .preview-footer {
    gap: 8px 10px;
  }
}

@media (max-width: 560px) {
  .order-checkout-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .order-field-wide {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .catalog-pane {
    padding: 10px 10px calc(var(--mobile-chat-height) + 16px);
  }

  .search-row {
    display: flex;
    gap: 5px;
  }

  .search-row input {
    min-width: 0;
    flex: 1 1 auto;
  }

  .search-row button {
    min-width: 0;
    padding: 0 8px;
  }

  .search-row select {
    min-width: 0;
    font-size: 16px;
  }
}

@media (max-width: 400px) {
  .workspace {
    --mobile-chat-height: min(64svh, 540px);
  }
}

@media (max-width: 480px) and (max-height: 760px) {
  .workspace {
    --mobile-chat-height: min(68svh, 540px);
  }
}
