:root {
  --text: #222;
  --subtext: #7b7b7b;
  --accent: #4b4b4f;
  --danger: #ff3b30;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
  --dialog-opacity: 0.22;
  --page-grad-1: #fafaf8;
  --page-grad-2: #f4f3ef;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--page-grad-1) 0%, var(--page-grad-2) 100%);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

textarea {
  resize: none;
}

.native-file-input {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

.page-slider {
  width: 100%;
  height: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-snap-stop: always;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.page-slider::-webkit-scrollbar {
  display: none;
}

.page {
  width: 100vw;
  min-width: 100vw;
  height: 100%;
  flex: 0 0 100vw;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
}

#page-chat {
  background: linear-gradient(180deg, var(--page-grad-1) 0%, var(--page-grad-2) 100%);
}

.chat-top-fixed {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 50;
}

.left-zone {
  left: 16px;
}

.right-zone {
  right: 16px;
}

.top-icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  color: #111;
  font-size: 18px;
  display: grid;
  place-items: center;
}

.history-icon-btn svg {
  width: 20px;
  height: 20px;
}

.large-icon-btn {
  width: 50px;
  height: 50px;
  font-size: 28px;
  font-weight: 700;
}

.immersive-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.fullscreen-character {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  transform: translateZ(0);
}

.character-fade-top,
.character-fade-bottom {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.character-fade-top {
  top: 0;
  height: 14vh;
  background: linear-gradient(180deg, rgba(250, 250, 248, 0.82) 0%, rgba(250, 250, 248, 0) 100%);
}

.character-fade-bottom {
  bottom: 0;
  height: 28vh;
  background: linear-gradient(180deg, rgba(244, 243, 239, 0) 0%, rgba(244, 243, 239, 0.72) 100%);
}

.dialog-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 10;
}

.dialog-bubble {
  min-height: 58px;
  max-height: 24vh;
  overflow-y: auto;
  padding: 14px 14px 30px;
  border-radius: 24px;
  background: rgba(255, 255, 255, var(--dialog-opacity));
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  color: var(--text);
  word-break: break-word;
  position: relative;
}

.bubble-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  min-height: 18px;
  margin-bottom: 10px;
  position: relative;
}

.bubble-speaker {
  font-size: 12px;
  color: rgba(34, 34, 34, 0.7);
  text-align: left;
  flex: 1;
}

.bubble-text {
  line-height: 1.75;
  font-size: 15px;
  text-align: center;
  white-space: pre-wrap;
}

.reroll-btn {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 16px;
  color: rgba(34, 34, 34, 0.58);
  padding: 4px;
  background: transparent;
}

.typing-indicator {
  position: absolute;
  top: 0;
  right: 28px;
  margin-top: 0;
  text-align: right;
  color: rgba(34, 34, 34, 0.65);
  font-size: 12px;
  line-height: 1;
}

.typing-indicator span {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 4px;
  border-radius: 50%;
  background: rgba(34, 34, 34, 0.65);
  animation: blinkDot 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: .15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes blinkDot {

  0%,
  80%,
  100% {
    opacity: .25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.fade-switch {
  animation: fadeSwitch .22s ease;
}

@keyframes fadeSwitch {
  from {
    opacity: .3;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-input-bar {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 11;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.tool-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-size: 20px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-input-bar textarea {
  flex: 1;
  min-width: 0;
  max-height: 96px;
  min-height: 42px;
  border: none;
  background: transparent;
  outline: none;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  overflow-y: auto;
}

.send-btn {
  min-width: 64px;
  padding: 0 16px;
  height: 42px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  font-weight: 600;
}

#page-apps {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.86), transparent 28%),
    linear-gradient(180deg, var(--page-grad-1) 0%, var(--page-grad-2) 100%);
}

.apps-page-inner {
  width: 100%;
  height: 100%;
  padding:
    calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.widget-board {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 220px;
}

.widget-card {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 26px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.widget-main {
  grid-row: 1 / span 2;
  padding: 0;
}

.clickable-widget {
  cursor: pointer;
}

.fixed-widget-preview {
  width: 100%;
  height: 220px;
  min-height: 220px;
  max-height: 220px;
}

.widget-preview {
  border-radius: 26px;
  overflow: hidden;
  background: linear-gradient(180deg, #f7f7f7, #ecece9);
  position: relative;
}

.widget-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.widget-preview.has-image img {
  display: block;
}

.widget-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--subtext);
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

.widget-overlay-text {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  color: white;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.widget-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.widget-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.widget-side>* {
  position: relative;
  z-index: 1;
}

.widget-side-title {
  color: var(--subtext);
  font-size: 12px;
  margin-bottom: 6px;
}

.widget-side-value {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}

.widget-side-main {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  white-space: pre-line;
}

.widget-side-sub {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(34, 34, 34, 0.5);
  line-height: 1.4;
}

.widget-side-days {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.dock-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 14px;
  justify-items: center;
  align-content: start;
  padding: 6px 4px 0;
}

.app-icon-card {
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.app-icon-visual {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.app-icon-card span {
  font-size: 13px;
  color: var(--text);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.sheet-modal {
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
  padding: 18px;
}

.fullscreen-modal {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(248, 248, 246, 0.98);
  backdrop-filter: blur(20px);
}

.fullscreen-modal-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.fullscreen-header {
  flex-shrink: 0;
  padding:
    calc(16px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px);
}

.center-title-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
}

.timeline-header-grid {
  grid-template-columns: 44px 1fr 44px !important;
  position: relative;
}

.center-title-header h2 {
  text-align: center;
  font-size: 19px;
  font-weight: 600;
}

.timeline-header-grid h2 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  text-align: center;
}

.header-space {
  width: 44px;
  height: 44px;
}

.close-x,
.icon-mini-btn,
.mini-glass-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.timeline-top-actions {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toolbar-pill-btn {
  min-width: 48px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.12);
  color: #111;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.icon-book-btn svg {
  width: 28px;
  height: 28px;
  display: block;
}

.fullscreen-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.ios-btn,
.tag-btn {
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
}

.ios-btn.primary {
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
}

.ios-btn.secondary,
.tag-btn {
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
}

.ios-btn.danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

.label-btn {
  cursor: pointer;
}

.fullscreen-body,
.list-stack,
.history-list,
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--subtext);
}

.field input,
.field textarea,
.field select,
.history-tools input {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
  color: var(--text);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row>* {
  flex: 1;
}

.preview-image {
  width: 100%;
  max-width: 220px;
  border-radius: 18px;
  display: block;
  margin-top: 8px;
  box-shadow: var(--shadow);
}

.info-box,
.card-list-item,
.history-item,
.memory-summary-card {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 18px;
  padding: 14px;
}

.memory-summary-top {
  margin-bottom: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-sub {
  font-size: 12px;
  color: var(--subtext);
  line-height: 1.7;
  margin-top: 6px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.card-actions .ios-btn {
  white-space: nowrap;
}

.history-speaker {
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 6px;
}

.history-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline-list {
  position: relative;
  padding-left: 18px;
}

.timeline-item {
  position: relative;
  padding-left: 22px;
  padding-bottom: 18px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111;
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 19px;
  width: 2px;
  height: calc(100% - 6px);
  background: rgba(0, 0, 0, 0.16);
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-time {
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 4px;
}

.timeline-title {
  font-size: 15px;
  font-weight: 600;
}

.timeline-desc {
  margin-top: 4px;
  color: var(--subtext);
  line-height: 1.7;
}

.sticker-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sticker-item {
  border-radius: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  padding: 10px;
  cursor: pointer;
}

.sticker-preview-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.66);
}

.sticker-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sticker-preview-text {
  margin-top: 8px;
  font-size: 12px;
  color: var(--subtext);
  line-height: 1.4;
  text-align: center;
  min-height: 34px;
}

.sticker-manager-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sticker-manager-thumb {
  width: 88px;
  flex-shrink: 0;
}

.sticker-manager-thumb .sticker-preview-box {
  width: 88px;
  height: 88px;
  aspect-ratio: auto;
}

.sticker-meta {
  flex: 1;
}

.sticker-check {
  width: 18px;
  height: 18px;
  margin-top: 36px;
}

.sticker-order-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.companion-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #fbfbfa, #f1f1ee);
  border-radius: 24px;
  padding: 18px;
}

.companion-stage {
  min-height: 240px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.companion-stage img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.companion-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 120;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 24%),
    linear-gradient(180deg, var(--page-grad-1) 0%, var(--page-grad-2) 100%);
  display: flex;
  flex-direction: column;
}

.companion-fullscreen-top {
  padding:
    calc(16px + env(safe-area-inset-top)) 16px 14px;
  display: flex;
  justify-content: flex-end;
}

.companion-fullscreen-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.companion-fullscreen-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.companion-bubble {
  margin: 0 16px calc(18px + env(safe-area-inset-bottom));
  padding: 14px 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(18px);
  line-height: 1.8;
}

.api-card.current-api {
  background: rgba(120, 120, 128, 0.18);
  border: 1px solid rgba(60, 60, 67, 0.16);
}

.current-anniversary {
  background: rgba(120, 120, 128, 0.18);
  border: 1px solid rgba(60, 60, 67, 0.16);
}

/* 世界书分组展开里的编辑按钮更小 */
.wb-inline-edit-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

/* 设置页图标：两两一行 */
.settings-icon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-icon-card {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  padding: 10px;
}

.settings-icon-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-icon-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-icon-preview {
  width: 32px;
  height: 32px;
  aspect-ratio: 1 / 1;
  margin-left: auto;
  flex: 0 0 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .9);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: var(--shadow);
}

.settings-icon-form .field {
  gap: 4px;
}

.settings-icon-form .field input,
.settings-icon-form .field select {
  padding: 9px 11px;
  border-radius: 12px;
}

.settings-icon-card .row {
  gap: 8px;
}

/* 陪伴页按钮更小 */
.companion-mini-actions {
  justify-content: center;
  gap: 8px;
}

.companion-mini-actions>* {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 12px;
  font-size: 13px;
}

/* 沉浸式陪伴底部小按钮 */
.companion-bottom-mini-actions {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 130;
}

.companion-bottom-mini-actions .ios-btn {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 12px;
  font-size: 13px;
}

.companion-dialog-panel {
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 125;
}

/* 全局 Toast */
.global-toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(34, 34, 34, 0.88);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.global-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 触控点击更稳定 */
.modal-overlay,
.fullscreen-modal,
.sheet-modal,
.fullscreen-body,
.sticker-item,
.app-icon-card,
.widget-card,
.ios-btn,
.tag-btn,
.close-x,
.tool-btn,
.send-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 480px) {
  .fixed-widget-preview {
    height: 210px;
    min-height: 210px;
    max-height: 210px;
  }

  .app-icon-card {
    width: 82px;
  }

  .app-icon-visual {
    width: 64px;
    height: 64px;
    border-radius: 18px;
  }

  .settings-icon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .settings-icon-preview {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .typing-indicator {
    right: 26px;
    font-size: 11px;
  }

  .companion-bottom-mini-actions .ios-btn,
  .companion-mini-actions>* {
    min-width: 58px;
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* 世界書分組按鈕更小 */
.wb-group-mini-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

/* 世界書展開後的編輯按鈕更小 */
.wb-inline-edit-btn {
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

/* 陪伴頁按鈕更清楚，背景更深 */
.companion-mini-actions .ios-btn,
.companion-bottom-mini-actions .ios-btn {
  background: rgba(34, 34, 34, 0.28);
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.companion-mini-actions .ios-btn.primary {
  background: rgba(34, 34, 34, 0.42);
  color: #fff;
}

/* 大圖片組件：把文字移到上方白色區，圖片在下方 */
.widget-preview.fixed-widget-preview {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.95);
}

.widget-overlay-text {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  order: 1;
  min-height: 54px;
  padding: 14px 16px 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  text-shadow: none;
  background: rgba(255, 255, 255, 0.96);
}

.widget-preview img {
  order: 2;
  flex: 1;
  min-height: 0;
}

.widget-empty {
  top: 54px;
}

/* 沒圖時也保留上方文字區 */
.widget-preview:not(.has-image) .widget-overlay-text {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

/* 設置頁圖標兩兩一行，正方圓角更小 */
.settings-icon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-icon-card {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  padding: 10px;
}

.settings-icon-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-icon-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-icon-preview {
  width: 32px;
  height: 32px;
  aspect-ratio: 1 / 1;
  margin-left: auto;
  flex: 0 0 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .9);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: var(--shadow);
}

.settings-icon-form .field {
  gap: 4px;
}

.settings-icon-form .field input,
.settings-icon-form .field select {
  padding: 9px 11px;
  border-radius: 12px;
}

.settings-icon-card .row {
  gap: 8px;
}

/* 手機下再縮一點 */
@media (max-width: 480px) {
  .settings-icon-preview {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .wb-group-mini-btn,
  .wb-inline-edit-btn {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* 大圖組件：上方文字區固定，下方圖片吃滿，不會只剩中間 */
.widget-preview.fixed-widget-preview {
  display: grid;
  grid-template-rows: 58px 1fr;
  background: rgba(255, 255, 255, 0.96);
}

.widget-overlay-text {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 58px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-shadow: none;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 2;
}

.widget-preview img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

.widget-empty {
  top: 58px;
}

/* 陪伴深色背景按鈕更清楚 */
.companion-mini-actions .ios-btn,
.companion-bottom-mini-actions .ios-btn {
  background: rgba(34, 34, 34, 0.38);
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.10);
}

.companion-mini-actions .ios-btn.primary {
  background: rgba(34, 34, 34, 0.52);
  color: #fff;
}

/* 世界書分組按鈕更小 */
.wb-group-mini-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

.wb-inline-edit-btn {
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 12px;
  flex: 0 0 auto;
}

/* iOS 風格開關 */
.ios-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 52px;
  height: 32px;
  flex: 0 0 auto;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.28);
  transition: .22s ease;
}

.ios-switch-slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  transition: .22s ease;
}

.ios-switch input:checked+.ios-switch-slider {
  background: rgba(34, 34, 34, 0.52);
}

.ios-switch input:checked+.ios-switch-slider::before {
  transform: translateX(20px);
}