/* Local/CI-only iPhone Chat adapter. Keep these tokens separate from Android. */
.sai-lab--smartphone.is-ios {
  --ios-bg: #ffffff;
  --ios-surface: rgba(246, 246, 248, .92);
  --ios-surface-strong: #eeeeef;
  --ios-label: #111113;
  --ios-secondary: #67676d;
  --ios-line: rgba(60, 60, 67, .16);
  --ios-user: #ececef;
  --ios-blue: #007aff;
  --ios-radius-control: 22px;
  --ios-radius-card: 18px;
  --ios-shadow-float: 0 14px 44px rgba(0, 0, 0, .18);
}

.sai-lab--smartphone.is-ios .phone-app {
  background: var(--ios-bg);
  color: var(--ios-label);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

.sai-lab--smartphone.is-ios .phone-homebar {
  background: var(--ios-bg);
}

.sai-lab--smartphone.is-ios .practice-watermark {
  color: #dbeafe;
  background: #172033;
}

.sai-lab--smartphone .ios-chat-screen {
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: calc(100% + 28px);
  min-height: calc(100% + 16px);
  margin: 0 -14px -16px;
  padding: max(2px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
  flex-direction: column;
  overflow: hidden;
  color: var(--ios-label);
  background: var(--ios-bg);
  isolation: isolate;
}

.sai-lab--smartphone .ios-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sai-lab--smartphone .ios-icon-button {
  display: grid;
  box-sizing: border-box;
  width: 46px;
  height: 46px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ios-label);
  background: transparent;
  font: inherit;
}

.sai-lab--smartphone .ios-chat-topbar {
  position: relative;
  z-index: 6;
  display: grid;
  min-height: 58px;
  grid-template-columns: 50px minmax(0, 1fr) 50px;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid transparent;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}

.sai-lab--smartphone .ios-chat-topbar__side {
  display: flex;
  min-width: 0;
  justify-content: flex-start;
}

.sai-lab--smartphone .ios-chat-topbar__side--right {
  justify-content: flex-end;
}

.sai-lab--smartphone .ios-menu-button,
.sai-lab--smartphone .ios-top-action-owner {
  background: var(--ios-surface);
  box-shadow: inset 0 0 0 1px rgba(60, 60, 67, .06);
}

.sai-lab--smartphone .ios-mode-switch {
  display: grid;
  min-width: 0;
  min-height: 50px;
  padding: 3px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  border-radius: 24px;
  background: var(--ios-surface-strong);
}

.sai-lab--smartphone .ios-mode-switch button {
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  border-radius: 20px;
  color: var(--ios-secondary);
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}

.sai-lab--smartphone .ios-mode-switch .is-current {
  color: var(--ios-label);
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .13);
}

.sai-lab--smartphone .ios-chat-content {
  display: flex;
  min-height: 0;
  padding: 10px 2px 4px;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sai-lab--smartphone .ios-empty-state {
  margin: auto 0;
  padding: 20px 8px;
  text-align: center;
}

.sai-lab--smartphone .ios-chat-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 15px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: #111113;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .13);
}

.sai-lab--smartphone .ios-empty-state h2 {
  margin: 0;
  font-size: clamp(20px, 6.1vw, 24px);
  font-weight: 650;
  letter-spacing: -.035em;
}

.sai-lab--smartphone .ios-chat-thread {
  display: flex;
  min-width: 0;
  gap: 12px;
  padding: 4px 0 8px;
  flex-direction: column;
}

.sai-lab--smartphone .ios-user-bubble {
  box-sizing: border-box;
  max-width: 84%;
  margin-left: auto;
  padding: 10px 14px;
  border-radius: var(--ios-radius-card) var(--ios-radius-card) 5px var(--ios-radius-card);
  color: var(--ios-label);
  background: var(--ios-user);
  font-size: 15px;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.sai-lab--smartphone .ios-answer {
  min-width: 0;
  color: var(--ios-label);
  font-size: 15px;
  line-height: 1.6;
}

.sai-lab--smartphone .ios-answer p {
  margin: 0;
}

.sai-lab--smartphone .ios-answer--latest {
  padding-bottom: 2px;
}

.sai-lab--smartphone .ios-answer-tools {
  min-height: 48px;
  margin-top: 3px;
  gap: 1px;
  flex-wrap: nowrap;
}

.sai-lab--smartphone .ios-answer-tool {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  flex: 0 0 48px;
  color: var(--ios-secondary);
}

.sai-lab--smartphone .ios-answer-tool .ios-icon {
  width: 21px;
  height: 21px;
}

.sai-lab--smartphone .ios-thinking {
  display: flex;
  width: 58px;
  height: 44px;
  gap: 5px;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--ios-surface);
}

.sai-lab--smartphone .ios-thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ios-secondary);
  animation: iosThinking 1.2s infinite ease-in-out;
}

.sai-lab--smartphone .ios-thinking span:nth-child(2) { animation-delay: .14s; }
.sai-lab--smartphone .ios-thinking span:nth-child(3) { animation-delay: .28s; }

.sai-lab--smartphone .ios-composer-wrap {
  margin-top: auto;
  padding-top: 8px;
  flex: 0 0 auto;
}

.sai-lab--smartphone .ios-sentence-slot {
  min-height: 52px;
  margin: 0 0 6px;
}

.sai-lab--smartphone .ios-sentence-button {
  border-color: #e0c45b;
  border-radius: 15px;
  color: #342600;
  background: #fff6c7;
}

.sai-lab--smartphone .ios-composer {
  display: flex;
  box-sizing: border-box;
  min-height: 58px;
  gap: 4px;
  padding: 6px;
  align-items: center;
  border: 1px solid var(--ios-line);
  border-radius: 29px;
  background: var(--ios-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
}

.sai-lab--smartphone .ios-composer-plus,
.sai-lab--smartphone .ios-composer-mic {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

.sai-lab--smartphone .ios-composer-trigger,
.sai-lab--smartphone .ios-composer-preview {
  display: flex;
  box-sizing: border-box;
  min-width: 0;
  min-height: 44px;
  padding: 8px 3px;
  flex: 1 1 auto;
  align-items: center;
  border: 0;
  color: var(--ios-secondary);
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.sai-lab--smartphone .ios-composer-preview.has-value {
  color: var(--ios-label);
}

.sai-lab--smartphone .ios-send-button {
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  flex: 0 0 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--ios-label);
}

.sai-lab--smartphone .ios-sidebar-scrim {
  position: absolute;
  z-index: 18;
  inset: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, .24);
}

.sai-lab--smartphone .ios-sidebar {
  position: absolute;
  z-index: 19;
  inset: 0 15% 0 0;
  display: flex;
  box-sizing: border-box;
  min-width: 0;
  padding: max(8px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  flex-direction: column;
  border-right: 1px solid var(--ios-line);
  background: rgba(250, 250, 252, .96);
  box-shadow: var(--ios-shadow-float);
  -webkit-backdrop-filter: blur(24px) saturate(155%);
  backdrop-filter: blur(24px) saturate(155%);
}

.sai-lab--smartphone .ios-sidebar-head {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
}

.sai-lab--smartphone .ios-sidebar-head strong {
  padding-left: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.sai-lab--smartphone .ios-sidebar-row,
.sai-lab--smartphone .ios-sidebar-recent {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  gap: 11px;
  padding: 0 12px;
  align-items: center;
  border: 0;
  border-radius: 13px;
  color: var(--ios-label);
  background: transparent;
  font: inherit;
  font-size: 15px;
  text-align: left;
}

.sai-lab--smartphone .ios-sidebar-new {
  margin: 6px 0 4px;
  background: var(--ios-surface-strong);
  font-weight: 650;
}

.sai-lab--smartphone .ios-sidebar-links {
  display: grid;
  gap: 1px;
}

.sai-lab--smartphone .ios-sidebar-label {
  margin: 13px 12px 4px;
  color: var(--ios-secondary);
  font-size: 12px;
  font-weight: 600;
}

.sai-lab--smartphone .ios-sidebar-recent {
  min-height: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-lab--smartphone .ios-sidebar-account {
  display: flex;
  min-height: 54px;
  margin-top: auto;
  gap: 10px;
  padding: 8px 10px;
  align-items: center;
  border-top: 1px solid var(--ios-line);
}

.sai-lab--smartphone .ios-account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: #222225;
  font-size: 11px;
  font-weight: 800;
}

.sai-lab--smartphone .ios-sidebar-account span:last-child {
  display: grid;
  min-width: 0;
}

.sai-lab--smartphone .ios-sidebar-account small {
  margin-top: 2px;
  color: var(--ios-secondary);
  font-size: 11px;
}

@media (max-width: 340px), (max-height: 700px) {
  .sai-lab--smartphone .ios-chat-screen { padding-inline: 10px; }
  .sai-lab--smartphone .ios-chat-topbar { min-height: 54px; grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 3px; }
  .sai-lab--smartphone .ios-icon-button { width: 44px; height: 44px; }
  .sai-lab--smartphone .ios-chat-content { padding-top: 4px; }
  .sai-lab--smartphone .ios-chat-thread { gap: 8px; }
  .sai-lab--smartphone .ios-user-bubble,
  .sai-lab--smartphone .ios-answer { font-size: 14px; line-height: 1.42; }
  .sai-lab--smartphone .ios-answer-tools { margin-top: 0; }
  .sai-lab--smartphone .ios-answer-tool { width: 48px; height: 48px; }
  .sai-lab--smartphone .ios-composer-wrap { padding-top: 4px; }
  .sai-lab--smartphone .ios-sidebar { right: 10%; padding-top: 6px; }
  .sai-lab--smartphone .ios-sidebar-row { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .sai-lab--smartphone .ios-thinking span { animation: none; }
}

@keyframes iosThinking {
  0%, 65%, 100% { opacity: .3; transform: translateY(0); }
  32% { opacity: 1; transform: translateY(-3px); }
}
