body.chat-pc {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--chat-page-bg, linear-gradient(180deg, #f0ffe0 0%, #f8fafc 40%, #eef7ff 100%));
}

body.chat-pc .chat-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

body.chat-pc .chat-card {
  width: min(1000px, 100%);
  height: min(720px, calc(100dvh - 40px));
  border-radius: var(--chat-card-radius, 18px);
  box-shadow: var(--chat-card-shadow, 0 12px 48px rgba(15, 23, 42, 0.12));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #fff;
}

body.chat-embed {
  margin: 0;
  background: #fff;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

body.chat-embed .chat-shell,
body.chat-embed .chat-card {
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

body.chat-embed .chat-card {
  border-radius: 0;
  box-shadow: none;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

body.chat-mobile.chat-pc {
  background: #fff;
}

body.chat-mobile.chat-pc .chat-shell {
  padding: 0;
  align-items: stretch;
}

body.chat-mobile.chat-pc .chat-card {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

.guest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.header-main {
  min-width: 0;
  flex: 1;
}

.header-main h2 {
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-main p {
  margin: 6px 0 0;
  opacity: 0.9;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-tools {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.btn-header-reconnect {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-header-reconnect:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-header-reconnect:active {
  transform: scale(0.98);
}

.btn-header-reconnect[hidden] {
  display: none !important;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.45);
}

.tool-btn:active {
  transform: scale(0.96);
}

.tool-btn.active {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.tool-btn.off { opacity: 0.5; }

.tool-btn-icon {
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-btn-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

body.chat-embed .guest-header,
body.chat-pc .guest-header {
  padding: 16px 18px;
  background: var(--chat-header-bg, var(--primary, #22c55e));
  color: var(--chat-header-text, #fff);
}

body.chat-style-minimal .guest-header,
body.chat-style-business .guest-header,
body[data-header-mode="solid"] .guest-header {
  background: var(--primary, #22c55e) !important;
}

body.chat-style-glass .guest-header,
body[data-header-mode="glass"] .guest-header {
  background: color-mix(in srgb, var(--chat-header-bg, var(--primary)) 78%, transparent) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.chat-style-minimal.chat-pc .chat-card,
body.chat-style-minimal.chat-embed .chat-card {
  border: 1px solid var(--border, #e5e7eb);
}

body.chat-pc .chat-messages,
body.chat-embed .chat-messages {
  background: var(--chat-messages-bg, #fff);
  grid-row: 3;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.chat-pc .guest-header,
body.chat-embed .guest-header {
  grid-row: 1;
}

body.chat-pc .contact-drawer,
body.chat-embed .contact-drawer {
  grid-row: 2;
}

body.chat-pc .chat-bottom-dock,
body.chat-embed .chat-bottom-dock {
  grid-row: 4;
  min-height: 0;
}

.chat-offline-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  padding-bottom: 4px;
}

.chat-offline-stack[hidden] {
  display: none !important;
}

.chat-offline-stack .faq-panel {
  margin: 0;
}

.chat-offline-stack .guestbook-card {
  margin: 0;
}

body.chat-pc .chat-card.chat-offline-inline .chat-messages,
body.chat-embed .chat-card.chat-offline-inline .chat-messages {
  padding-bottom: 12px;
}

body.chat-pc .chat-card.chat-no-compose .chat-bottom-dock,
body.chat-embed .chat-card.chat-no-compose .chat-bottom-dock {
  display: none;
}

body.chat-pc .chat-card.chat-no-compose,
body.chat-embed .chat-card.chat-no-compose {
  grid-template-rows: auto auto minmax(0, 1fr);
}

body.chat-pc .chat-card.chat-no-compose .chat-bottom-dock[hidden],
body.chat-embed .chat-card.chat-no-compose .chat-bottom-dock[hidden] {
  display: none !important;
}

body.chat-pc .chat-input,
body.chat-embed .chat-input {
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.chat-input[hidden] {
  display: none !important;
}

.chat-bottom-dock {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: #fff;
  z-index: 2;
}

.chat-bottom-dock[hidden] {
  display: none !important;
}

.chat-offline-footer {
  flex-shrink: 0;
  padding: 12px 14px 0;
  background: var(--chat-messages-bg, #fff);
}

.chat-offline-footer[hidden] {
  display: none !important;
}

.chat-offline-footer .faq-panel {
  margin: 0 0 12px;
}

.chat-offline-footer .guestbook-card {
  margin: 0;
}

.chat-bottom-dock .chat-input {
  border-top: 1px solid #e5e7eb;
}

.chat-bottom-dock:has(.chat-offline-footer:not([hidden])) .chat-input {
  border-top-color: #e5e7eb;
}

body.chat-pc .chat-input textarea,
body.chat-embed .chat-input textarea {
  min-height: 44px;
  max-height: 120px;
  resize: none;
}

body.chat-offline-simple .chat-input {
  padding: 10px 14px;
}

body.chat-offline-simple .chat-input textarea {
  min-height: 40px;
  max-height: 88px;
}

body.chat-offline-simple .chat-input .btn {
  align-self: end;
  padding: 10px 14px;
}

body.chat-pc .chat-input .btn,
body.chat-embed .chat-input .btn {
  min-width: 72px;
  border-radius: 12px;
  padding: 12px 16px;
}

body.chat-mobile .guest-header {
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.contact-drawer {
  background: #fff;
  border-bottom: 1px solid var(--border, #e5e7eb);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.contact-drawer.open {
  max-height: min(42vh, 300px);
  overflow: auto;
}

.contact-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #1f2937);
}

.contact-drawer-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  color: var(--muted, #6b7280);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.contact-drawer-close:hover {
  background: var(--primary-light, #dcfce7);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  color: var(--primary-dark);
}

.contact-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 14px 14px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.contact-item:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.contact-item-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-light, #dcfce7);
  color: var(--primary-dark, #16a34a);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.contact-item-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.contact-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.contact-item-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #6b7280);
  line-height: 1.2;
}

.contact-item-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1f2937);
  word-break: break-all;
  line-height: 1.4;
}

.contact-item-action {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary-light, #dcfce7);
  color: var(--primary-dark, #16a34a);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.contact-item-action:hover,
.contact-item-link:hover .contact-item-action {
  background: var(--primary);
  color: #fff;
}

.contact-item-image {
  align-items: stretch;
}

.contact-item-image .contact-item-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.contact-item-qr {
  display: block;
  width: min(120px, 100%);
  max-height: 120px;
  object-fit: contain;
  margin-top: 6px;
  border-radius: 10px;
  background: #fafbfc;
  padding: 6px;
  border: 1px solid var(--border, #e5e7eb);
}

body.chat-mobile .contact-grid {
  padding: 8px 12px 12px;
}

body.chat-mobile .contact-item {
  padding: 11px 12px;
}

body.chat-mobile .contact-drawer.open {
  max-height: min(55vh, 380px);
}

/* Guestbook feature card */
.guestbook-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary-light, #dcfce7) 0%, #fff 100%);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border, #e5e7eb));
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.guestbook-card-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary, #22c55e);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.guestbook-card-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.guestbook-card-body {
  flex: 1;
  min-width: 0;
}

.guestbook-card-title {
  display: block;
  font-size: 15px;
  color: var(--text, #1f2937);
  margin-bottom: 4px;
}

.guestbook-card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted, #6b7280);
}

.guestbook-card-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 10px 16px;
  border-radius: 12px;
}

body.chat-mobile .guestbook-card {
  flex-wrap: wrap;
}

body.chat-mobile .guestbook-card-btn {
  width: 100%;
}

/* Guestbook modal */
.guestbook-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.guestbook-modal[hidden] {
  display: none !important;
}

.guestbook-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.guestbook-modal-dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  padding: 18px 18px 16px;
}

.guestbook-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.guestbook-modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.guestbook-modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: #fff;
  color: var(--muted, #6b7280);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.guestbook-modal-close:hover {
  background: var(--primary-light, #dcfce7);
  color: var(--primary-dark);
}

.guestbook-form .field {
  margin-bottom: 12px;
}

.guestbook-form .field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1f2937);
}

.guestbook-form select,
.guestbook-form input,
.guestbook-form textarea {
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--chat-input-radius, 10px);
  padding: 10px 12px;
  font: inherit;
  box-sizing: border-box;
}

.guestbook-form select:focus,
.guestbook-form input:focus,
.guestbook-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.guestbook-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted, #6b7280);
  line-height: 1.5;
}

.guestbook-count {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted, #6b7280);
  text-align: right;
}

.guestbook-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.guestbook-modal-actions .btn {
  min-width: 96px;
}

.guestbook-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

body.guestbook-open {
  overflow: hidden;
}

body.chat-mobile .guestbook-modal {
  padding: 0;
  align-items: stretch;
}

body.chat-mobile .guestbook-modal-dialog {
  width: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.bubble.rich-html {
  line-height: 1.55;
}

.bubble.rich-html p {
  margin: 0 0 0.5em;
}

.bubble.rich-html p:last-child {
  margin-bottom: 0;
}

.bubble.rich-html ul,
.bubble.rich-html ol {
  margin: 0.35em 0;
  padding-left: 1.2em;
}

.bubble.rich-html img,
.faq-panel-title.rich-html img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.faq-panel-title.rich-html,
.faq-chip .rich-html {
  line-height: 1.45;
}

.faq-chip .rich-html img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

body.chat-mobile .header-main h2 {
  font-size: 16px;
}

body.chat-mobile .header-main p {
  font-size: 12px;
}

body.chat-mobile .chat-messages {
  padding: 12px;
}

body.chat-mobile .chat-offline-footer {
  padding: 10px 12px 0;
}

body.chat-mobile .chat-input {
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  grid-template-columns: 1fr auto;
  gap: 8px;
}

body.chat-mobile .chat-input textarea {
  min-height: 44px;
  max-height: 120px;
  font-size: 16px;
  padding: 10px 12px;
}

body.chat-mobile .chat-input .btn {
  padding: 10px 14px;
  align-self: end;
}

body.chat-mobile .msg {
  max-width: 88%;
}

.faq-panel {
  margin: 8px 0 16px;
  padding: 12px;
  background: var(--primary-light, #e8f8d8);
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.faq-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark, #4da502);
  margin-bottom: 10px;
}

.faq-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.faq-chip {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  color: var(--text, #1f2937);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.faq-chip:hover {
  border-color: var(--primary, #22c55e);
  background: var(--primary-light, #dcfce7);
}

.faq-chip:active {
  transform: scale(0.98);
}

body.chat-mobile .faq-chip {
  font-size: 14px;
  padding: 10px 14px;
}

.faq-editor-item {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}

.faq-editor-item .field {
  margin-bottom: 10px;
}

.faq-editor-item .field:last-child {
  margin-bottom: 0;
}

.faq-editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

@media (max-width: 768px) {
  body.chat-pc .chat-shell {
    padding: 0;
  }

  body.chat-pc .chat-card {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }
}
