.stylemaster-app {
  width: 100%;
  max-width: 1140px;
  margin: 12px auto;
  padding: 0 12px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1f2a30;
}

.sm-card {
  background: linear-gradient(180deg, #ffffff, #f4f8f8);
  border: 1px solid #d7e1e3;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(30, 50, 60, 0.08);
}

.sm-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.sm-row textarea,
.sm-row input,
#sm-note {
  width: 100%;
  border: 1px solid #c5d0d3;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}

.sm-row button,
#sm-next,
#sm-unlock-btn,
#sm-send {
  border: none;
  border-radius: 10px;
  background: #0e6f74;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

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

#sm-unlock-btn {
  min-width: 128px !important;
  width: auto !important;
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

.sm-row button[disabled],
#sm-next[disabled] {
  background: #90a6aa;
  cursor: not-allowed;
}

.sm-chat {
  border: 1px solid #d0dde0;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdfd;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
}

.sm-msg {
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 10px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.sm-user {
  background: #dbf2f2;
}

.sm-assistant {
  background: #edf3f6;
}

.sm-assistant-dev {
  background: #fff3cd;
  border: 1px solid #f0d98a;
}

.sm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px;
  margin: 12px 0;
}

.sm-image-card {
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: #f4f6f8;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  position: relative;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.sm-image-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.sm-image-card.is-selected {
  border-color: #0e6f74;
  box-shadow: 0 0 0 3px rgba(14, 111, 116, 0.35);
}

.sm-image-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s ease;
  pointer-events: none;
}

.sm-image-card.is-selected::after {
  background: rgba(14, 111, 116, 0.16);
}

.sm-checkmark {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0e6f74;
  color: #fff;
  font-size: 16px;
  line-height: 26px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.sm-image-card.is-selected .sm-checkmark {
  opacity: 1;
  transform: scale(1);
}

.sm-round-indicator {
  display: inline-block;
  margin: 4px 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8f3f4;
  color: #0c4f55;
  font-size: 13px;
  font-weight: 700;
}

.sm-actions {
  align-items: center;
  justify-content: space-between;
}

.sm-instruction {
  margin-top: 6px;
}

.sm-summary {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d8e4e8;
  background: #f9fcfc;
}

.sm-intro-text,
.sm-confrontation-text {
  line-height: 1.6;
  margin-top: 8px;
  margin-bottom: 12px;
}

.sm-transition-text {
  line-height: 1.6;
  margin-top: 8px;
  margin-bottom: 12px;
}

.sm-intro-text p,
.sm-transition-text p {
  margin: 0 0 10px 0;
}

.sm-intro-text h1,
.sm-intro-text h2,
.sm-intro-text h3,
.sm-intro-text h4,
.sm-intro-text h5,
.sm-transition-text h1,
.sm-transition-text h2,
.sm-transition-text h3,
.sm-transition-text h4,
.sm-transition-text h5 {
  margin: 0 0 10px 0;
}

.sm-markdown {
  line-height: 1.6;
}

.sm-markdown h1,
.sm-markdown h2,
.sm-markdown h3,
.sm-markdown h4,
.sm-markdown h5,
.sm-markdown h6,
.sm-confrontation-text h1,
.sm-confrontation-text h2,
.sm-confrontation-text h3,
.sm-confrontation-text h4,
.sm-confrontation-text h5,
.sm-confrontation-text h6 {
  margin: 0 0 10px 0;
}

.sm-markdown p,
.sm-confrontation-text p {
  margin: 0 0 12px 0;
}

.sm-markdown hr,
.sm-confrontation-text hr {
  border: 0;
  border-top: 1px solid #d7e1e3;
  margin: 14px 0;
}

.sm-markdown ul,
.sm-confrontation-text ul {
  margin: 0 0 12px 0;
  padding-left: 20px;
}

.sm-report-section {
  margin-bottom: 16px;
}

.sm-report-section h3 {
  margin-bottom: 8px;
}

.sm-report-section ul {
  margin: 0;
  padding-left: 18px;
}

.sm-error {
  color: #b01020;
  font-weight: 600;
}

.sm-success {
  color: #146c2e;
  font-weight: 600;
}

.sm-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: #1b3a42;
  font-size: 14px;
  background: #eaf3f4;
  border: 1px solid #c9dadd;
  border-radius: 8px;
  padding: 8px 10px;
}

.sm-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bfd0d4;
  border-top-color: #0e6f74;
  border-radius: 50%;
  animation: sm-spin 0.8s linear infinite;
}

.sm-network-busy {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f4852;
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.sm-network-busy .sm-spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
}

.sm-press-preview {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(12, 23, 28, 0.9);
}

.sm-press-preview.is-visible {
  display: flex;
}

.sm-press-preview img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 10px;
}

html.sm-no-scroll,
body.sm-no-scroll {
  overflow: hidden;
}

@keyframes sm-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .sm-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 820px) {
  .stylemaster-app {
    width: calc(100vw - 8px);
    max-width: none;
    margin-top: 8px;
    margin-bottom: 8px;
    margin-left: calc(50% - 50vw + 4px);
    margin-right: calc(50% - 50vw + 4px);
    padding: 0 4px;
  }

  .sm-card {
    padding: 12px;
    border-radius: 12px;
  }

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

  .sm-row {
    flex-direction: column;
  }
}

@media (max-width: 820px) and (orientation: landscape) {
  .sm-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
