/* FE/v4/styles.css */

:root {
  --v4-bg: #120f1a;
  --v4-bg-soft: #1c1728;
  --v4-bg-card: rgba(255, 255, 255, 0.08);
  --v4-bg-card-strong: rgba(255, 255, 255, 0.13);
  --v4-border: rgba(255, 255, 255, 0.14);
  --v4-border-strong: rgba(255, 255, 255, 0.24);
  --v4-text: #f7f1ff;
  --v4-text-muted: rgba(247, 241, 255, 0.72);
  --v4-text-subtle: rgba(247, 241, 255, 0.52);
  --v4-accent: #d9a8ff;
  --v4-accent-strong: #f0d1ff;
  --v4-danger: #ff8f9f;
  --v4-danger-bg: rgba(255, 95, 120, 0.16);
  --v4-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --v4-radius-lg: 24px;
  --v4-radius-md: 18px;
  --v4-radius-sm: 12px;
  --v4-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.v4-screen {
  min-height: 100dvh;
  width: 100%;
  margin: 0 auto;
  color: var(--v4-text);
  background:
    radial-gradient(circle at 18% 8%, rgba(217, 168, 255, 0.20), transparent 34%),
    radial-gradient(circle at 82% 2%, rgba(137, 111, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #191225 0%, var(--v4-bg) 48%, #0d0b12 100%);
}

.v4-screen button {
  border: 0;
}

/* =========================
   Lobby
========================= */

.v4-lobby-screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px calc(22px + var(--v4-safe-bottom));
}

.v4-lobby-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--v4-border);
  border-radius: var(--v4-radius-lg);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: var(--v4-shadow);
}

.v4-lobby-hero__eyebrow,
.v4-room-header__eyebrow,
.v4-settings-header__eyebrow {
  margin: 0 0 6px;
  color: var(--v4-accent);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.v4-lobby-hero__title {
  margin: 0;
  font-size: clamp(2.1rem, 12vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.v4-lobby-hero__description {
  margin: 10px 0 0;
  color: var(--v4-text-muted);
  line-height: 1.7;
}

.v4-lobby-hero__portrait {
  display: flex;
  justify-content: center;
}

.v4-lobby-hero__portrait-inner {
  display: grid;
  place-items: center;
  width: min(62vw, 230px);
  aspect-ratio: 1 / 1.22;
  border: 1px solid var(--v4-border);
  border-radius: 999px 999px 34px 34px;
  color: rgba(255, 255, 255, 0.42);
  background:
    radial-gradient(circle at 50% 24%, rgba(240, 209, 255, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}

.v4-lobby-status,
.v4-settings-card {
  padding: 20px;
  border: 1px solid var(--v4-border);
  border-radius: var(--v4-radius-lg);
  background: var(--v4-bg-card);
}

.v4-lobby-status__label,
.v4-current-consultation__label,
.v4-consultation-history__label {
  margin: 0 0 8px;
  color: var(--v4-accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.v4-lobby-status__title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.35;
}

.v4-lobby-status__description {
  margin: 10px 0 18px;
  color: var(--v4-text-muted);
  line-height: 1.7;
}

.v4-lobby-status__primary-button,
.v4-lobby-actions__button,
.v4-settings-actions__button,
.v4-empty-state__primary-button,
.v4-empty-state__secondary-button,
.v4-consultation-history__new-button,
.v4-current-consultation__history-button,
.v4-message-input__send-button,
.v4-dialog__cancel-button,
.v4-dialog__danger-button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--v4-text);
  background: var(--v4-bg-card-strong);
}

.v4-lobby-status__primary-button,
.v4-lobby-actions__button.is-primary,
.v4-settings-actions__button.is-primary,
.v4-empty-state__primary-button,
.v4-consultation-history__new-button,
.v4-message-input__send-button {
  color: #1d1129;
  background: linear-gradient(180deg, var(--v4-accent-strong), var(--v4-accent));
  font-weight: 700;
}

.v4-lobby-actions,
.v4-settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* =========================
   Room header
========================= */

 .v4-room-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.v4-room-header,
.v4-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--v4-border);
  background: rgba(18, 15, 26, 0.82);
  backdrop-filter: blur(18px);
}

.v4-room-header__main,
.v4-settings-header {
  min-width: 0;
}

.v4-room-header__main,
.v4-settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.v4-room-header__back-button,
.v4-settings-header__back-button,
.v4-room-header__settings-button,
.v4-room-error__close {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 40px;
  border-radius: 999px;
  color: var(--v4-text);
  background: var(--v4-bg-card);
}

.v4-room-header__settings-button {
  padding: 0 14px;
  font-size: 0.88rem;
}

.v4-room-header__text,
.v4-settings-header__text {
  min-width: 0;
}

.v4-room-header__title,
.v4-settings-header__title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.v4-room-header__description,
.v4-settings-header__description {
  margin: 4px 0 0;
  color: var(--v4-text-muted);
  font-size: 0.88rem;
}

/* =========================
   Room shell
========================= */

.v4-room-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding: 12px 14px calc(14px + var(--v4-safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.v4-room-shell__segment {
  flex: 0 0 auto;
}

.v4-room-shell__body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
  overflow: hidden;
}

.v4-room-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--v4-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.v4-room-segment__button {
  min-height: 40px;
  border-radius: 999px;
  color: var(--v4-text-muted);
  background: transparent;
  font-weight: 700;
}

.v4-room-segment__button.is-active {
  color: #1d1129;
  background: var(--v4-accent-strong);
}

.v4-room-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 143, 159, 0.34);
  border-radius: var(--v4-radius-sm);
  color: #ffd8df;
  background: var(--v4-danger-bg);
}

.v4-room-error__text {
  min-width: 0;
  line-height: 1.5;
}

/* =========================
   Current consultation
========================= */

.v4-current-consultation,
.v4-consultation-history {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  flex-direction: column;
  border: 1px solid var(--v4-border);
  border-radius: var(--v4-radius-lg);
  background: rgba(255, 255, 255, 0.065);
  overflow: hidden;
}

.v4-current-consultation__header,
.v4-consultation-history__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--v4-border);
}

.v4-current-consultation__title-block,
.v4-consultation-history__title-block {
  min-width: 0;
}

.v4-current-consultation__title,
.v4-consultation-history__title {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.35;
}

.v4-current-consultation__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  color: var(--v4-text-subtle);
  font-size: 0.78rem;
}

.v4-current-consultation__history-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.v4-current-consultation__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.v4-current-consultation__input {
  flex: 0 0 auto;
  border-top: 1px solid var(--v4-border);
}

/* =========================
   Message list
========================= */

.v4-message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.v4-message-list--empty {
  justify-content: center;
}

.v4-message-list__empty-card {
  padding: 18px;
  border: 1px dashed var(--v4-border-strong);
  border-radius: var(--v4-radius-md);
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
}

.v4-message-list__empty-title {
  margin: 0;
  font-weight: 700;
}

.v4-message-list__empty-description {
  margin: 8px 0 0;
  color: var(--v4-text-muted);
  line-height: 1.6;
}

.v4-message {
  display: flex;
  flex-direction: column;
  max-width: 95%;
}

.v4-message.is-user {
  align-self: flex-end;
  align-items: flex-end;
}

.v4-message.is-assistant,
.v4-message.is-unknown {
  align-self: flex-start;
  align-items: flex-start;
}

.v4-message__meta {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--v4-text-subtle);
  font-size: 0.74rem;
}

.v4-message__bubble {
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.7;
  word-break: break-word;
  white-space: normal;
}

.v4-message.is-user .v4-message__bubble {
  border-bottom-right-radius: 6px;
  color: #1d1129;
  background: var(--v4-accent-strong);
}

.v4-message.is-assistant .v4-message__bubble {
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.11);
}

.v4-message.is-pending .v4-message__bubble {
  color: var(--v4-text-muted);
}

/* =========================
   Message input
========================= */

.v4-message-input {
  padding: 10px;
  background: rgba(18, 15, 26, 0.72);
}

.v4-message-input__button-area {
  display: flex;
  flex-direction: column;
  margin-left: 6px;
}

.v4-message-input__tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--v4-text-subtle);
  font-size: 0.76rem;
}

.v4-message-input__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* .v4-message-input__main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
} */
.v4-message-input__main {
  display: flex;
}

.v4-message-input__textarea {
  width: 100%;
  min-height: 46px;
  max-height: 120px;
  padding: 12px 13px;
  border: 1px solid var(--v4-border);
  border-radius: 18px;
  outline: none;
  resize: vertical;
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.09);
}

.v4-message-input__textarea::placeholder {
  color: var(--v4-text-subtle);
}

.v4-message-input__textarea:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

.v4-message-input__send-button {
  min-width: 72px;
  min-height: 46px;
}

/* =========================
   History
========================= */

.v4-consultation-history__description {
  margin: 8px 0 0;
  color: var(--v4-text-muted);
  line-height: 1.6;
}

.v4-consultation-history__new-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.v4-consultation-history__summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--v4-border);
  color: var(--v4-text-subtle);
  font-size: 0.78rem;
}

.v4-consultation-history__list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}

.v4-consultation-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--v4-border);
  border-radius: var(--v4-radius-md);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.v4-consultation-card.is-active {
  border-color: rgba(240, 209, 255, 0.64);
  background: rgba(217, 168, 255, 0.13);
}

.v4-consultation-card__main {
  min-width: 0;
  padding: 14px;
  text-align: left;
  color: var(--v4-text);
  background: transparent;
}

.v4-consultation-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.v4-consultation-card__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.v4-consultation-card__badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #1d1129;
  background: var(--v4-accent-strong);
  font-size: 0.7rem;
  font-weight: 700;
}

.v4-consultation-card__summary {
  margin: 8px 0 0;
  color: var(--v4-text-muted);
  line-height: 1.55;
  font-size: 0.88rem;
}

.v4-consultation-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
  color: var(--v4-text-subtle);
  font-size: 0.74rem;
}

.v4-consultation-card__actions {
  display: flex;
  align-items: stretch;
  border-left: 1px solid var(--v4-border);
}

.v4-consultation-card__delete-button {
  min-width: 58px;
  padding: 0 10px;
  color: var(--v4-danger);
  background: rgba(255, 255, 255, 0.045);
}

/* =========================
   Empty state
========================= */

.v4-empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  width: 100%;
  min-height: 280px;
  padding: 28px 20px;
  text-align: center;
}

.v4-empty-state__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--v4-border);
  border-radius: 50%;
  color: var(--v4-accent);
  background: rgba(255, 255, 255, 0.06);
}

.v4-empty-state__title {
  margin: 0;
  font-size: 1.2rem;
}

.v4-empty-state__description {
  max-width: 30em;
  margin: 10px auto 0;
  color: var(--v4-text-muted);
  line-height: 1.7;
}

.v4-empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

/* =========================
   Dialog
========================= */

.v4-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.v4-dialog {
  width: min(100%, 420px);
  padding: 20px;
  border: 1px solid var(--v4-border-strong);
  border-radius: var(--v4-radius-lg);
  color: var(--v4-text);
  background: #1c1728;
  box-shadow: var(--v4-shadow);
}

.v4-dialog__title {
  margin: 0;
  font-size: 1.18rem;
}

.v4-dialog__description {
  margin: 12px 0 0;
  color: var(--v4-text-muted);
  line-height: 1.7;
}

.v4-dialog__target {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--v4-border);
  border-radius: var(--v4-radius-sm);
  background: rgba(255, 255, 255, 0.06);
}

.v4-dialog__target-label {
  color: var(--v4-text-subtle);
  font-size: 0.72rem;
}

.v4-dialog__target-title {
  font-weight: 700;
}

.v4-dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.v4-dialog__danger-button {
  color: #321018;
  background: linear-gradient(180deg, #ffc1cb, var(--v4-danger));
  font-weight: 700;
}

/* =========================
   Settings
========================= */

.v4-settings-card {
  margin: 0 14px;
}

.v4-settings-card__title {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.v4-settings-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.v4-settings-list__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--v4-border);
}

.v4-settings-list__item:last-child {
  border-bottom: 0;
}

.v4-settings-list dt {
  color: var(--v4-text-muted);
}

.v4-settings-list dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.v4-settings-notes {
  margin: 0;
  padding-left: 1.2em;
  color: var(--v4-text-muted);
  line-height: 1.8;
}

.v4-settings-actions {
  padding: 0 14px;
}

/* =========================
   Desktop containment
========================= */

@media (min-width: 768px) {
  body {
    background: #08070c;
  }

  .v4-screen {
    max-width: 760px;
    min-height: 100dvh;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.42);
  }

  .v4-lobby-screen {
    padding-inline: 24px;
  }

  .v4-lobby-hero {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
  }

  .v4-room-shell {
    padding-inline: 18px;
  }

  .v4-message {
    max-width: 95%;
  }
}

@media (max-width: 420px) {
  .v4-current-consultation__header,
  .v4-consultation-history__header {
    flex-direction: column;
  }

  .v4-current-consultation__history-button,
  .v4-consultation-history__new-button {
    width: 100%;
  }

  .v4-consultation-card {
    grid-template-columns: 1fr;
  }

  .v4-consultation-card__actions {
    border-left: 0;
    border-top: 1px solid var(--v4-border);
  }

  .v4-consultation-card__delete-button {
    width: 100%;
    min-height: 38px;
  }
}


/* =========================
   v4 Lobby Restore from v2
   - Background
   - Lilith stage
   - Header / Main / Footer
   - Tap reaction / mini talk
========================= */

.v4-home-screen {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(214, 180, 122, 0.16), transparent 34%),
    linear-gradient(180deg, #1a1230 0%, #221538 42%, #1a132d 100%);
}

.v4-home-background {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: url("./assets/Hermes-Home-BG-001.webp");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0.95;
}

.v4-home-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(
      180deg,
      rgba(18, 12, 28, 0.22) 0%,
      rgba(18, 12, 28, 0.10) 28%,
      rgba(18, 12, 28, 0.42) 100%
    );
}

.v4-home-header {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 18px;
  pointer-events: none;
}

.v4-home-brand {
  color: #f3ddb0;
  font-family: "Times New Roman", serif;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.v4-home-subtitle {
  color: rgba(246, 230, 198, 0.92);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.v4-home-stage {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  align-items: flex-end;
  justify-content: center;
  padding: 8px 18px 0;
}

.v4-home-character-wrap {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 430px;
  height: 100%;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.v4-home-character-button {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.v4-home-character {
  display: block;
  width: min(88vw, 360px);
  max-height: 80vh;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.32));
  user-select: none;
  -webkit-user-drag: none;
}

.v4-home-bubble-wrap {
  position: absolute;
  left: 40%;
  top: 50%;
  z-index: 8;
  width: min(56vw, 250px);
  transform: translateX(-128px);
}

.v4-home-bubble {
  border: 1px solid rgba(132, 108, 168, 0.18);
  border-radius: 18px;
  padding: 14px 14px 12px;
  color: #1e1530;
  background: rgba(255, 250, 255, 0.94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.v4-home-bubble-text {
  font-size: 16px;
  line-height: 1.55;
  white-space: normal;
}

.v4-home-bubble-link {
  appearance: none;
  border: 0;
  margin-top: 10px;
  padding: 0;
  color: #6749a0;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
}

.v4-home-bottom-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--v4-safe-bottom));
  z-index: 10;
  padding: 14px 14px 16px;
  border: 1px solid rgba(255, 235, 205, 0.14);
  border-radius: 22px;
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.16),
      rgba(255, 248, 255, 0.08)
    );
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
}

.v4-home-nameplate {
  margin-bottom: 10px;
  color: rgba(248, 232, 200, 0.96);
  font-size: 18px;
  letter-spacing: 0.08em;
  text-align: center;
}

.v4-home-status {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 235, 205, 0.10);
  border-radius: 16px;
  background: rgba(19, 13, 31, 0.24);
}

.v4-home-status__label {
  color: rgba(246, 230, 198, 0.70);
  font-size: 12px;
}

.v4-home-status__title {
  overflow: hidden;
  color: rgba(255, 247, 234, 0.96);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-home-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.v4-home-primary-button,
.v4-home-secondary-button {
  appearance: none;
  min-height: 46px;
  border-radius: 999px;
  cursor: pointer;
}

.v4-home-primary-button {
  border: 1px solid rgba(241, 220, 181, 0.32);
  padding: 0 20px;
  color: #fff7ea;
  background:
    linear-gradient(
      180deg,
      rgba(93, 55, 143, 0.92),
      rgba(64, 35, 102, 0.94)
    );
  box-shadow: 0 8px 20px rgba(50, 26, 81, 0.35);
  font-size: 16px;
  font-weight: 700;
}

.v4-home-secondary-button {
  border: 1px solid rgba(255, 235, 205, 0.18);
  padding: 0 16px;
  color: #fff7ea;
  background: rgba(19, 13, 31, 0.38);
}

.v4-home-mini-talk {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.v4-home-mini-talk-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255, 235, 205, 0.18);
  border-radius: 999px;
  padding: 0 16px;
  outline: none;
  color: #f7f0ff;
  background: rgba(19, 13, 31, 0.42);
}

.v4-home-mini-talk-input::placeholder {
  color: rgba(247, 240, 255, 0.50);
}

.v4-home-mini-talk-input:focus {
  border-color: rgba(243, 221, 176, 0.42);
  box-shadow: 0 0 0 3px rgba(243, 221, 176, 0.10);
}

.v4-home-mini-talk-button {
  appearance: none;
  min-height: 42px;
  border: 1px solid rgba(241, 220, 181, 0.20);
  border-radius: 999px;
  padding: 0 16px;
  color: #fff7ea;
  background: rgba(76, 46, 118, 0.9);
  cursor: pointer;
}

@media (max-width: 420px) {
  .v4-home-header {
    padding-top: 16px;
  }

  .v4-home-brand {
    font-size: 32px;
  }

  .v4-home-character {
    width: min(92vw, 350px);
  }

  .v4-home-bubble-wrap {
    left: 42%;
    top: 48%;
    width: min(62vw, 238px);
    transform: translateX(-122px);
  }

  .v4-home-bottom-panel {
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--v4-safe-bottom));
    padding: 13px 13px 15px;
  }

  .v4-home-actions {
    grid-template-columns: 1fr 74px;
  }

  .v4-home-secondary-button {
    padding-inline: 12px;
  }

  .v4-home-mini-talk {
    gap: 8px;
  }

  .v4-home-mini-talk-button {
    padding-inline: 12px;
  }
}



/* =========================
   v4 Place Header Restore from v2
   - 3 column header
   - Gold centered title
   - Stable left / center / right layout
========================= */

.v4-place-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(100px, 180px) minmax(0, 1fr) minmax(100px, 180px);
  align-items: center;
  gap: 10px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid rgba(255, 235, 205, 0.12);
  background:
    linear-gradient(
      180deg,
      rgba(24, 17, 35, 0.94),
      rgba(15, 11, 22, 0.86)
    );
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

.v4-place-header__side {
  display: flex;
  align-items: center;
  min-width: 0;
}

.v4-place-header__side--left {
  justify-content: flex-start;
}

.v4-place-header__side--right {
  justify-content: flex-end;
}

.v4-place-header__center {
  min-width: 0;
  text-align: center;
}

.v4-place-header__eyebrow {
  margin: 0 0 3px;
  color: rgba(246, 230, 198, 0.74);
  font-family: "Times New Roman", serif;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

.v4-place-header__title {
  margin: 0;
  overflow: hidden;
  color: #f3ddb0;
  font-family: "Times New Roman", serif;
  font-size: 1.72rem;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow:
    0 2px 10px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(243, 221, 176, 0.14);
}

.v4-place-header__description {
  margin: 5px 0 0;
  overflow: hidden;
  color: rgba(246, 230, 198, 0.74);
  font-size: 0.78rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-place-header__button,
.v4-room-header__back-button,
.v4-room-header__settings-button,
.v4-settings-header__back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 235, 205, 0.18);
  border-radius: 999px;
  color: #fff7ea;
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.11),
      rgba(255, 248, 255, 0.055)
    );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 6px 16px rgba(0, 0, 0, 0.14);
  font-size: 0.88rem;
  white-space: nowrap;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.v4-place-header__button:hover,
.v4-room-header__back-button:hover,
.v4-room-header__settings-button:hover,
.v4-settings-header__back-button:hover {
  border-color: rgba(243, 221, 176, 0.36);
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.16),
      rgba(255, 248, 255, 0.075)
    );
}

.v4-place-header__button:active,
.v4-room-header__back-button:active,
.v4-room-header__settings-button:active,
.v4-settings-header__back-button:active {
  transform: scale(0.97);
}

.v4-place-header__spacer {
  display: block;
  width: 76px;
  height: 40px;
}

/* Override older room/settings header rules */

.v4-room-header__main,
.v4-settings-header {
  min-width: 0;
}

.v4-room-header__text,
.v4-settings-header__text,
.v4-room-header__eyebrow,
.v4-room-header__title,
.v4-room-header__description,
.v4-settings-header__eyebrow,
.v4-settings-header__title,
.v4-settings-header__description {
  all: unset;
}

/* Small screen tuning */

@media (max-width: 420px) {
  .v4-place-header {
    grid-template-columns: minmax(76px, 92px) minmax(0, 1fr) minmax(76px, 92px);
    gap: 7px;
    padding: 10px 11px 10px;
  }

  .v4-place-header__button,
  .v4-room-header__back-button,
  .v4-room-header__settings-button,
  .v4-settings-header__back-button {
    min-width: 72px;
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .v4-place-header__spacer {
    width: 72px;
    height: 38px;
  }

  .v4-place-header__eyebrow {
    font-size: 0.68rem;
  }

  .v4-place-header__title {
    font-size: 1.44rem;
  }

  .v4-place-header__description {
    margin-top: 4px;
    font-size: 0.70rem;
  }
}



/* =========================
   v4 Phase 4 Folder UI
   - Folder list
   - Folder consultation list
   - Unclassified group
   - Folder delete dialog notice
========================= */

/* =========================
   Folder list view
========================= */

.v4-folder-list-view {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  flex-direction: column;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.083), rgba(255, 255, 255, 0.048));
  box-shadow: var(--v4-shadow-room);
  overflow: hidden;
}

.v4-folder-list-view__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 15px 13px;
  border-bottom: 1px solid var(--v4-border-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
}

.v4-folder-list-view__title-block {
  min-width: 0;
}

.v4-folder-list-view__label {
  margin: 0 0 8px;
  color: rgba(239, 208, 255, 0.84);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.10em;
}

.v4-folder-list-view__title {
  margin: 0;
  color: var(--v4-text);
  font-size: 1.08rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.v4-folder-list-view__description {
  margin: 8px 0 0;
  color: var(--v4-text-subtle);
  line-height: 1.6;
  font-size: 0.88rem;
}

.v4-folder-list-view__new-consultation-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 235, 205, 0.20);
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  box-shadow:
    0 8px 20px rgba(215, 166, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.56);
  font-weight: 700;
  white-space: nowrap;
}

.v4-folder-list-view__create {
  flex: 0 0 auto;
  padding: 12px 14px;
  border-bottom: 1px solid var(--v4-border-soft);
  background: rgba(255, 255, 255, 0.025);
}

.v4-folder-list-view__list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(215, 166, 255, 0.04), transparent 30%);
}

/* =========================
   Folder create form
========================= */

.v4-folder-create {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.v4-folder-create__input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.v4-folder-create__input::placeholder {
  color: var(--v4-text-subtle);
}

.v4-folder-create__input:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

.v4-folder-create__button {
  min-width: 68px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 235, 205, 0.20);
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-weight: 700;
  white-space: nowrap;
}

/* =========================
   Folder item
========================= */

.v4-folder-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  border: 1px solid rgba(255, 255, 255, 0.105);
  border-radius: var(--v4-radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.078), rgba(255, 255, 255, 0.047));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.v4-folder-item:active {
  transform: scale(0.992);
}

.v4-folder-item.is-virtual {
  border-color: rgba(243, 221, 176, 0.20);
  background:
    linear-gradient(180deg, rgba(243, 221, 176, 0.105), rgba(255, 255, 255, 0.045));
}

.v4-folder-item.is-active {
  border-color: rgba(239, 208, 255, 0.52);
  background:
    linear-gradient(180deg, rgba(215, 166, 255, 0.18), rgba(255, 255, 255, 0.065));
}

.v4-folder-item__main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  min-width: 0;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--v4-text);
  background: transparent;
}

.v4-folder-item__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(239, 208, 255, 0.22);
  border-radius: 13px;
  color: var(--v4-accent-strong);
  background:
    radial-gradient(circle, rgba(215, 166, 255, 0.16), rgba(255, 255, 255, 0.055));
  font-size: 1.05rem;
}

.v4-folder-item.is-virtual .v4-folder-item__icon {
  border-color: rgba(243, 221, 176, 0.28);
  color: #f3ddb0;
  background:
    radial-gradient(circle, rgba(243, 221, 176, 0.18), rgba(255, 255, 255, 0.055));
}

.v4-folder-item__body {
  min-width: 0;
}

.v4-folder-item__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.v4-folder-item__title {
  margin: 0;
  overflow: hidden;
  color: var(--v4-text);
  font-size: 1rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-folder-item__active-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.v4-folder-item__meta {
  margin: 8px 0 0;
  color: var(--v4-text-subtle);
  font-size: 0.78rem;
}

.v4-folder-item__actions {
  display: flex;
  align-items: stretch;
  border-left: 1px solid var(--v4-border-soft);
}

.v4-folder-item__delete-button {
  min-width: 58px;
  padding: 0 10px;
  color: #ffc2cc;
  background: rgba(255, 143, 159, 0.055);
  transition:
    color 140ms ease,
    background 140ms ease;
}

.v4-folder-item__delete-button:hover {
  color: #ffe1e6;
  background: rgba(255, 143, 159, 0.12);
}

.v4-folder-list-view__empty-folder-note {
  padding: 16px;
  border: 1px dashed var(--v4-border-strong);
  border-radius: var(--v4-radius-md);
  color: var(--v4-text-muted);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.v4-folder-list-view__empty-folder-note p {
  margin: 0;
  line-height: 1.65;
}

.v4-folder-list-view__empty-folder-note p + p {
  margin-top: 6px;
}

/* =========================
   Folder consultation list
========================= */

.v4-folder-consultation-list {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  flex-direction: column;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.083), rgba(255, 255, 255, 0.048));
  box-shadow: var(--v4-shadow-room);
  overflow: hidden;
}

.v4-folder-consultation-list__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
  padding: 13px 14px;
  border-bottom: 1px solid var(--v4-border-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
}

.v4-folder-consultation-list__back-button,
.v4-folder-consultation-list__new-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: #fff7ea;
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.11),
      rgba(255, 248, 255, 0.055)
    );
  font-size: 0.82rem;
  white-space: nowrap;
}

.v4-folder-consultation-list__new-button {
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-weight: 700;
}

.v4-folder-consultation-list__title-block {
  min-width: 0;
  text-align: center;
}

.v4-folder-consultation-list__label {
  margin: 0 0 4px;
  color: rgba(239, 208, 255, 0.78);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.10em;
}

.v4-folder-consultation-list__title {
  margin: 0;
  overflow: hidden;
  color: var(--v4-text);
  font-size: 1.05rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-folder-consultation-list__description {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--v4-text-subtle);
  font-size: 0.76rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-folder-consultation-list__summary {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--v4-border-soft);
  color: var(--v4-text-subtle);
  font-size: 0.78rem;
}

.v4-folder-consultation-list__body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(215, 166, 255, 0.04), transparent 30%);
}

/* =========================
   Folder consultation empty
========================= */

.v4-folder-consultation-list__empty {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 280px;
  padding: 28px 18px;
  text-align: center;
}

.v4-folder-consultation-list__empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(239, 208, 255, 0.28);
  border-radius: 50%;
  color: var(--v4-accent-strong);
  background:
    radial-gradient(circle, rgba(215, 166, 255, 0.20), rgba(255, 255, 255, 0.06));
}

.v4-folder-consultation-list__empty-title {
  margin: 0;
  color: var(--v4-text);
  font-size: 1.08rem;
  line-height: 1.45;
}

.v4-folder-consultation-list__empty-description {
  max-width: 28em;
  margin: 0;
  color: var(--v4-text-muted);
  line-height: 1.7;
}

.v4-folder-consultation-list__empty-button {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 235, 205, 0.20);
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-weight: 700;
}

/* =========================
   Folder delete dialog notice
========================= */

.v4-dialog__notice {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid rgba(243, 221, 176, 0.18);
  border-radius: var(--v4-radius-sm);
  color: rgba(255, 247, 234, 0.88);
  background: rgba(243, 221, 176, 0.075);
}

.v4-dialog__notice p {
  margin: 0;
  line-height: 1.65;
  font-size: 0.86rem;
}

.v4-dialog__target-note {
  color: var(--v4-text-subtle);
  font-size: 0.82rem;
}

/* =========================
   Phase 4 small-screen tuning
========================= */

@media (max-width: 420px) {
  .v4-folder-list-view__header {
    flex-direction: column;
    align-items: stretch;
  }

  .v4-folder-list-view__new-consultation-button {
    min-height: 28px;
    padding: 6px;
    width: 100%;
  }

  .v4-folder-create {
    grid-template-columns: 1fr 64px;
  }

  .v4-folder-create__button {
    min-width: 64px;
    padding-inline: 10px;
  }

  .v4-folder-item {
    grid-template-columns: 1fr;
  }

  .v4-folder-item__actions {
    border-left: 0;
    border-top: 1px solid var(--v4-border-soft);
  }

  .v4-folder-item__delete-button {
    width: 100%;
    min-height: 38px;
  }

  .v4-folder-item__header {
    gap: 6px;
  }

  .v4-folder-item__active-badge {
    align-self: flex-start;
  }

  .v4-folder-consultation-list__header {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .v4-folder-consultation-list__title-block {
    text-align: left;
  }

  .v4-folder-consultation-list__back-button,
  .v4-folder-consultation-list__new-button {
    width: 100%;
  }

  .v4-folder-consultation-list__description {
    white-space: normal;
  }
}


/* =========================
   v4 Phase 4 Folder Rename
========================= */

.v4-folder-item__actions {
  display: grid;
  grid-template-columns: auto;
  min-width: 70px;
}

.v4-folder-item__rename-button,
.v4-folder-item__delete-button {
  min-width: 70px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.v4-folder-item__rename-button {
  color: rgba(255, 247, 234, 0.92);
  background: rgba(255, 255, 255, 0.055);
  border-bottom: 1px solid var(--v4-border-soft);
  transition:
    color 140ms ease,
    background 140ms ease;
}

.v4-folder-item__rename-button:hover {
  color: #fff7ea;
  background: rgba(255, 255, 255, 0.10);
}

@media (max-width: 420px) {
  .v4-folder-item__actions {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .v4-folder-item__rename-button,
  .v4-folder-item__delete-button {
    width: 100%;
    min-height: 40px;
  }

  .v4-folder-item__rename-button {
    border-bottom: 0;
    border-right: 1px solid var(--v4-border-soft);
  }
}


/* =========================
   v4 Phase 4 Consultation Rename
========================= */

.v4-consultation-card__actions {
  display: grid;
  grid-template-columns: auto;
  min-width: 70px;
}

.v4-consultation-card__rename-button,
.v4-consultation-card__delete-button {
  min-width: 70px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.v4-consultation-card__rename-button {
  color: rgba(255, 247, 234, 0.92);
  background: rgba(255, 255, 255, 0.055);
  border-bottom: 1px solid var(--v4-border-soft);
  transition:
    color 140ms ease,
    background 140ms ease;
}

.v4-consultation-card__rename-button:hover {
  color: #fff7ea;
  background: rgba(255, 255, 255, 0.10);
}

.v4-current-consultation__actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
}

.v4-current-consultation__rename-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--v4-border-soft);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.92);
  background: rgba(255, 255, 255, 0.075);
  font-size: 0.82rem;
  white-space: nowrap;
}

.v4-current-consultation__rename-button:hover {
  color: #fff7ea;
  background: rgba(255, 255, 255, 0.10);
}

@media (max-width: 420px) {
  .v4-consultation-card__actions {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .v4-consultation-card__rename-button,
  .v4-consultation-card__delete-button {
    width: 100%;
    min-height: 40px;
  }

  .v4-consultation-card__rename-button {
    border-bottom: 0;
    border-right: 1px solid var(--v4-border-soft);
  }

  .v4-current-consultation__actions {
    flex-direction: row;
  }

  .v4-current-consultation__rename-button,
  .v4-current-consultation__history-button {
    flex: 1;
    width: auto;
  }
}


/* =========================
   v4 Phase 4 Folder Header Rename
========================= */

.v4-folder-consultation-list__actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
}

.v4-folder-consultation-list__rename-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.92);
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.11),
      rgba(255, 248, 255, 0.055)
    );
  font-size: 0.82rem;
  white-space: nowrap;
}

.v4-folder-consultation-list__rename-button:hover {
  color: #fff7ea;
  background: rgba(255, 255, 255, 0.10);
}

@media (max-width: 420px) {
  .v4-folder-consultation-list__actions {
    width: 100%;
    flex-direction: row;
  }

  .v4-folder-consultation-list__rename-button,
  .v4-folder-consultation-list__new-button {
    flex: 1;
    width: auto;
  }
}


/* =========================
   v4 Phase 4 Consultation Move
========================= */

.v4-consultation-card__move {
  display: grid;
  gap: 4px;
  min-width: 112px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--v4-border-soft);
  background: rgba(255, 255, 255, 0.035);
}

.v4-consultation-card__move-label {
  color: var(--v4-text-subtle);
  font-size: 0.68rem;
  line-height: 1;
}

.v4-consultation-card__move-select {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--v4-text);
  background: rgba(18, 15, 26, 0.86);
  font-size: 0.76rem;
  outline: none;
}

.v4-consultation-card__move-select:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

@media (max-width: 420px) {
  .v4-consultation-card__move {
    grid-column: 1 / -1;
    min-width: 0;
    padding: 9px 10px;
  }

  .v4-consultation-card__move-select {
    min-height: 34px;
  }
}


/* =========================
   v4 Phase 5 Common UI
   - Action menu
   - Dialog shell helpers
   - Add card
   - Status badge
   - Target preview
   - Warning block
========================= */

/* Action menu */

.v4-action-menu-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.v4-action-menu-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.92);
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.11),
      rgba(255, 248, 255, 0.055)
    );
  font-size: 1.2rem;
  line-height: 1;
}

.v4-action-menu-button:hover,
.v4-action-menu-button.is-open {
  color: #fff7ea;
  border-color: rgba(243, 221, 176, 0.36);
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.16),
      rgba(255, 248, 255, 0.075)
    );
}

.v4-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 50;
  display: grid;
  min-width: 164px;
  padding: 6px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(33, 23, 46, 0.98), rgba(23, 17, 32, 0.98));
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
}

.v4-action-menu--right {
  right: 0;
}

.v4-action-menu--left {
  left: 0;
}

.v4-action-menu__item {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 11px;
  color: rgba(255, 247, 234, 0.92);
  background: transparent;
  font-size: 0.86rem;
  text-align: left;
}

.v4-action-menu__item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.v4-action-menu__item.is-danger {
  color: #ffc2cc;
}

.v4-action-menu__item.is-danger:hover {
  color: #ffe1e6;
  background: rgba(255, 143, 159, 0.12);
}

.v4-action-menu__item:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* Dialog shell */

.v4-dialog-shell {
  max-height: min(680px, calc(100dvh - 32px));
  overflow: hidden;
}

.v4-dialog__close-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--v4-border-soft);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.86);
  background: rgba(255, 255, 255, 0.065);
}

.v4-dialog__body {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  overflow-y: auto;
}

.v4-dialog__confirm-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 235, 205, 0.20);
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-weight: 700;
}

/* Target preview */

.v4-target-preview-card {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-sm);
  background: rgba(255, 255, 255, 0.055);
}

.v4-target-preview-card__label {
  color: var(--v4-text-subtle);
  font-size: 0.74rem;
}

.v4-target-preview-card__title {
  overflow: hidden;
  color: var(--v4-text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-target-preview-card__meta,
.v4-target-preview-card__note {
  color: var(--v4-text-muted);
  font-size: 0.82rem;
}

/* Warning block */

.v4-warning-block {
  padding: 11px 12px;
  border-radius: var(--v4-radius-sm);
  line-height: 1.65;
}

.v4-warning-block--warning {
  border: 1px solid rgba(243, 221, 176, 0.18);
  color: rgba(255, 247, 234, 0.90);
  background: rgba(243, 221, 176, 0.075);
}

.v4-warning-block--danger {
  border: 1px solid rgba(255, 143, 159, 0.22);
  color: #ffe1e6;
  background: rgba(255, 143, 159, 0.085);
}

.v4-warning-block__title {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.v4-warning-block__message {
  margin: 0;
  font-size: 0.86rem;
}

/* Add card */

.v4-add-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  align-items: center;
  padding: 14px;
  border: 1px dashed rgba(243, 221, 176, 0.28);
  border-radius: var(--v4-radius-md);
  color: rgba(255, 247, 234, 0.92);
  background:
    linear-gradient(180deg, rgba(243, 221, 176, 0.075), rgba(255, 255, 255, 0.035));
  text-align: left;
}

.v4-add-card:hover {
  border-color: rgba(243, 221, 176, 0.46);
  background:
    linear-gradient(180deg, rgba(243, 221, 176, 0.12), rgba(255, 255, 255, 0.05));
}

.v4-add-card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(243, 221, 176, 0.28);
  border-radius: 50%;
  color: #f3ddb0;
  background: rgba(243, 221, 176, 0.10);
  font-size: 1.25rem;
}

.v4-add-card__body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.v4-add-card__title {
  color: var(--v4-text);
  font-weight: 700;
}

.v4-add-card__description {
  color: var(--v4-text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

/* Status badge */

.v4-status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.v4-status-badge--default {
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
}

.v4-status-badge--subtle {
  color: rgba(255, 247, 234, 0.84);
  background: rgba(255, 255, 255, 0.085);
}

.v4-status-badge--warning {
  color: #2f210b;
  background: #f3ddb0;
}

.v4-status-badge--danger {
  color: #3a1018;
  background: #ffc2cc;
}

@media (max-width: 420px) {
  .v4-action-menu {
    min-width: 156px;
  }

  .v4-dialog-shell {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .v4-add-card {
    min-height: 68px;
  }
}

/* =========================
   v4 Phase 5 Consultation Card Action Menu
========================= */

.v4-consultation-card {
  position: relative;
}

.v4-consultation-card__main {
  padding-right: 54px;
}

.v4-consultation-card__actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  min-width: 0;
}

.v4-consultation-card__actions .v4-action-menu-container {
  display: inline-flex;
}

/* Phase 4 move select / old side buttons cleanup */

.v4-consultation-card__move {
  display: none;
}

.v4-consultation-card__rename-button,
.v4-consultation-card__delete-button {
  display: none;
}

/* =========================
   v4 Phase 5 Move Dialog
========================= */

.v4-move-dialog__options {
  display: grid;
  gap: 8px;
}

.v4-move-dialog__option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-sm);
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.v4-move-dialog__option:hover {
  border-color: rgba(243, 221, 176, 0.28);
  background: rgba(255, 255, 255, 0.085);
}

.v4-move-dialog__option.is-selected {
  border-color: rgba(239, 208, 255, 0.52);
  background:
    linear-gradient(180deg, rgba(215, 166, 255, 0.18), rgba(255, 255, 255, 0.065));
}

.v4-move-dialog__option-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.v4-move-dialog__option-name {
  overflow: hidden;
  color: var(--v4-text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-move-dialog__option-description {
  color: var(--v4-text-subtle);
  font-size: 0.82rem;
}

.v4-move-dialog__option-check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  color: #21132e;
  background:
    linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-size: 0.85rem;
  font-weight: 700;
}

.v4-dialog__inline-error {
  margin: 0;
  padding: 10px 11px;
  border: 1px solid rgba(255, 143, 159, 0.22);
  border-radius: var(--v4-radius-sm);
  color: #ffe1e6;
  background: rgba(255, 143, 159, 0.085);
  font-size: 0.86rem;
  line-height: 1.55;
}

@media (max-width: 420px) {
  .v4-consultation-card__main {
    padding-right: 50px;
  }

  .v4-consultation-card__actions {
    top: 9px;
    right: 9px;
  }

  .v4-move-dialog__option {
    padding: 11px;
  }
}


/* =========================
   v4 Phase 5 Action Menu Clipping Fix
========================= */

.v4-consultation-card {
  overflow: visible;
}

.v4-consultation-card__actions {
  z-index: 30;
}

.v4-consultation-card__actions .v4-action-menu {
  z-index: 80;
}

/* =========================
   v4 Phase 5 Action Menu Opaque / Layer Fix
========================= */

.v4-consultation-card {
  position: relative;
  z-index: 1;
}

.v4-consultation-card.is-menu-open {
  z-index: 60;
}

.v4-consultation-card.is-menu-open .v4-action-menu-container {
  z-index: 90;
}

.v4-consultation-card.is-menu-open .v4-action-menu {
  z-index: 100;
}

/* Make action menu visually opaque and prevent lower controls from showing through */

.v4-action-menu {
  background: #171120;
  border-color: rgba(243, 221, 176, 0.26);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: none;
  pointer-events: auto;
}

.v4-action-menu__item {
  background: #171120;
}

.v4-action-menu__item:hover {
  background: #261b35;
}

.v4-action-menu__item.is-danger:hover {
  background: #39202a;
}

/* =========================
   v4 Phase 5 Current Consultation Action Menu
========================= */

.v4-current-consultation__header {
  position: relative;
}

.v4-current-consultation__actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 40;
}

.v4-current-consultation__actions .v4-action-menu-container {
  z-index: 90;
}

.v4-current-consultation__actions .v4-action-menu {
  z-index: 100;
}

/* Hide old Phase 4 buttons if any remain in DOM */

.v4-current-consultation__rename-button,
.v4-current-consultation__history-button {
  display: none;
}

@media (max-width: 420px) {
  .v4-current-consultation__header {
    gap: 10px;
  }

  .v4-current-consultation__actions {
    align-self: flex-start;
  }
}

/* =========================
   v4 Phase 5 Folder Action Menu
========================= */

.v4-folder-item {
  position: relative;
  overflow: visible;
  z-index: 1;
}

.v4-folder-item.is-menu-open {
  z-index: 60;
}

.v4-folder-item__main {
  padding-right: 54px;
}

.v4-folder-item__actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  display: flex;
  min-width: 0;
  border-left: 0;
}

.v4-folder-item__actions .v4-action-menu-container {
  z-index: 90;
}

.v4-folder-item__actions .v4-action-menu {
  z-index: 100;
}

/* Hide old Phase 4 folder side buttons if any remain */

.v4-folder-item__rename-button,
.v4-folder-item__delete-button {
  display: none;
}

/* Folder header action menu */

.v4-folder-consultation-list__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 42px;
}

.v4-folder-consultation-list__actions .v4-action-menu-container {
  z-index: 90;
}

.v4-folder-consultation-list__actions .v4-action-menu {
  z-index: 100;
}

/* Hide old Phase 4 header buttons if any remain */

.v4-folder-consultation-list__rename-button,
.v4-folder-consultation-list__new-button {
  display: none;
}

@media (max-width: 420px) {
  .v4-folder-item__main {
    padding-right: 50px;
  }

  .v4-folder-item__actions {
    top: 9px;
    right: 9px;
  }

  .v4-folder-consultation-list__actions {
    justify-content: flex-start;
  }
}

/* =========================
   v4 Phase 5 Create Dialog / AddCard Migration
========================= */

/* Hide old folder create form if any remains */

.v4-folder-list-view__create,
.v4-folder-create {
  display: none;
}

/* Create dialog */

.v4-create-dialog__field {
  display: grid;
  gap: 7px;
}

.v4-create-dialog__label {
  color: var(--v4-text-subtle);
  font-size: 0.82rem;
  font-weight: 700;
}

.v4-create-dialog__input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.v4-create-dialog__input::placeholder {
  color: var(--v4-text-subtle);
}

.v4-create-dialog__input:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

.v4-create-dialog__helper {
  margin: 0;
  color: var(--v4-text-muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

/* AddCard spacing in folder / consultation lists */

.v4-folder-list-view__list > .v4-add-card,
.v4-folder-consultation-list__body > .v4-add-card {
  flex: 0 0 auto;
}

.v4-folder-consultation-list__body > .v4-add-card {
  margin-top: 2px;
}

/* Old empty button no longer used */

.v4-folder-consultation-list__empty-button {
  display: none;
}

/* =========================
   v4 Phase 5 Rename Dialog
========================= */

.v4-rename-dialog__field {
  display: grid;
  gap: 7px;
}

.v4-rename-dialog__label {
  color: var(--v4-text-subtle);
  font-size: 0.82rem;
  font-weight: 700;
}

.v4-rename-dialog__input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.v4-rename-dialog__input::placeholder {
  color: var(--v4-text-subtle);
}

.v4-rename-dialog__input:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

/* =========================
   v4 Phase 5 Delete Dialog
========================= */

.v4-delete-dialog .v4-target-preview-card {
  border-color: rgba(255, 143, 159, 0.18);
  background: rgba(255, 143, 159, 0.055);
}

.v4-delete-dialog .v4-dialog__body {
  gap: 13px;
}

.v4-delete-dialog .v4-dialog__danger-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 143, 159, 0.32);
  border-radius: 999px;
  color: #3a1018;
  background: #ffc2cc;
  font-weight: 700;
}

.v4-delete-dialog .v4-dialog__danger-button:hover {
  background: #ffe1e6;
}

.v4-delete-dialog .v4-dialog__danger-button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

/* =========================
   v4 Phase 5 Settings Screen Tuning
========================= */

 .v4-settings-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.v4-settings-header {
  flex: 0 0 auto;
  padding: 16px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.083), rgba(255, 255, 255, 0.048));
  box-shadow: var(--v4-shadow-room);
}

.v4-settings-header__label,
.v4-settings-section__label {
  margin: 0 0 8px;
  color: rgba(239, 208, 255, 0.84);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.v4-settings-header__title,
.v4-settings-section__title {
  margin: 0;
  color: var(--v4-text);
  line-height: 1.35;
}

.v4-settings-header__title {
  font-size: 1.35rem;
}

.v4-settings-section__title {
  font-size: 1.05rem;
}

.v4-settings-header__description,
.v4-settings-section__description {
  margin: 8px 0 0;
  color: var(--v4-text-subtle);
  font-size: 0.88rem;
  line-height: 1.65;
}

.v4-settings-section-block {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px;
}

.v4-settings-section {
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 14px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.066), rgba(255, 255, 255, 0.038));
  box-shadow: var(--v4-shadow-room);
}

.v4-settings-section--developer {
  flex: 1 1 auto;
  min-height: 0;
}

.v4-settings-placeholder {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--v4-border-strong);
  border-radius: var(--v4-radius-sm);
  color: var(--v4-text-muted);
  background: rgba(255, 255, 255, 0.035);
  line-height: 1.65;
}

.v4-settings-placeholder p {
  margin: 0;
}

.v4-settings-dev-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

/* .v4-settings-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-sm);
  background: rgba(255, 255, 255, 0.045);
} */
 .v4-settings-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 11px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-sm);
  background: rgba(255, 255, 255, 0.045);
}

.v4-settings-item__body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.v4-settings-item__label {
  color: var(--v4-text);
  font-size: 0.86rem;
  font-weight: 700;
}

.v4-settings-item__description {
  color: var(--v4-text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.v4-settings-item__value {
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.88);
  background: rgba(255, 255, 255, 0.075);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-settings-footer {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px 0 0;
}

.v4-settings-screen__nav-button {
  min-height: 44px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: #fff7ea;
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.11),
      rgba(255, 248, 255, 0.055)
    );
  font-weight: 700;
}

.v4-settings-screen__nav-button:hover {
  border-color: rgba(243, 221, 176, 0.34);
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 255, 0.16),
      rgba(255, 248, 255, 0.075)
    );
}

@media (max-width: 420px) {
  .v4-settings-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .v4-settings-item__value {
    width: fit-content;
  }
}

/* =========================
   v4 Phase 5 Settings Header Layout Fix
========================= */

.v4-settings-hero {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  min-height: 116px;
  padding: 18px 20px;
  border: 1px solid var(--v4-border-soft);
  border-radius: var(--v4-radius-lg);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.083),
      rgba(255, 255, 255, 0.048)
    );
  box-shadow: var(--v4-shadow-room);
}

.v4-settings-hero__side {
  min-width: 0;
  min-height: 44px;
}

.v4-settings-hero__center {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.v4-settings-hero__eyebrow {
  margin: 0;
  color: rgba(239, 208, 255, 0.84);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.v4-settings-hero__title {
  margin: 0;
  color: var(--v4-text);
  font-size: 1.8rem;
  line-height: 1.25;
}

.v4-settings-hero__description {
  max-width: 56ch;
  margin: 0;
  color: var(--v4-text-subtle);
  font-size: 0.92rem;
  line-height: 1.65;
}

@media (max-width: 420px) {
  .v4-settings-hero {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    min-height: auto;
    padding: 16px 14px;
  }

  .v4-settings-hero__title {
    font-size: 1.45rem;
  }

  .v4-settings-hero__description {
    font-size: 0.86rem;
  }
}

/* =========================
   v4 Phase 5 Dialog Close Button Removal
========================= */

.v4-dialog__header {
  justify-content: center;
  text-align: center;
}

.v4-dialog__title {
  width: 100%;
  text-align: center;
}

.v4-dialog__close-button {
  display: none;
}


/* =========================
   v4 Phase 5 Duplicate Label Cleanup
========================= */

.v4-current-consultation__folder-name {
  margin: 0 0 8px;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 9px;
  border: 1px solid rgba(243, 221, 176, 0.20);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.88);
  background: rgba(243, 221, 176, 0.075);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Safety: if old duplicate labels remain in DOM, hide them */

.v4-folder-list-view__label,
.v4-folder-consultation-list__label {
  display: none;
}


/* =========================
   v4 Phase 6 Network Access Toggle
========================= */

.v4-message-input-bar__network-toggle {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.78);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.v4-message-input-bar__network-toggle:hover {
  border-color: rgba(243, 221, 176, 0.32);
  color: rgba(255, 247, 234, 0.92);
  background: rgba(255, 255, 255, 0.08);
}

.v4-message-input-bar__network-toggle.is-active {
  border-color: rgba(176, 225, 255, 0.44);
  color: #e9f7ff;
  background: rgba(94, 181, 255, 0.16);
}

.v4-message-input-bar__network-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.v4-message-input-bar__network-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 247, 234, 0.34);
}

.v4-message-input-bar__network-toggle.is-active
  .v4-message-input-bar__network-dot {
  background: #8ed7ff;
  box-shadow: 0 0 10px rgba(142, 215, 255, 0.62);
}

@media (max-width: 420px) {
  .v4-message-input-bar__network-toggle {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }
}


/* =========================
   v4 Small Screen UI Adjustment
   Lobby simple bottom panel
========================= */

.v4-home-bottom-panel--simple {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 10px 14px 14px;
}

.v4-home-bottom-panel--simple .v4-home-primary-button {
  width: min(100%, 360px);
  min-height: 42px;
  justify-self: center;
  padding: 0 18px;
  font-size: 0.96rem;
}

.v4-home-bottom-panel--simple .v4-home-secondary-button,
.v4-home-bottom-panel--simple .v4-home-status,
.v4-home-bottom-panel--simple .v4-home-mini-talk {
  display: none;
}
/* v4 Theme 1-A: assistant response mode label */
.v4-message__response-mode {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 247, 234, 0.16);
  border-radius: 999px;
  color: var(--v4-text-subtle);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.68rem;
  line-height: 1.3;
  white-space: nowrap;
}

.v4-message__response-mode.is-network {
  border-color: rgba(184, 231, 255, 0.28);
  background: rgba(116, 196, 255, 0.10);
}

.v4-message__response-mode.is-network-failed {
  border-color: rgba(255, 214, 153, 0.28);
  background: rgba(255, 194, 102, 0.10);
}

/* =========================
   v4 Theme 1-B: Markdown message body
========================= */
.v4-message-markdown {
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: normal;
}

.v4-message-markdown > *:first-child {
  margin-top: 0;
}

.v4-message-markdown > *:last-child {
  margin-bottom: 0;
}

.v4-message-markdown p {
  margin: 0.55em 0;
}

.v4-message-markdown h1,
.v4-message-markdown h2,
.v4-message-markdown h3,
.v4-message-markdown h4 {
  margin: 0.95em 0 0.42em;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.v4-message-markdown h1 {
  font-size: 1.18rem;
}

.v4-message-markdown h2 {
  font-size: 1.08rem;
}

.v4-message-markdown h3,
.v4-message-markdown h4 {
  font-size: 1rem;
}

.v4-message-markdown ul,
.v4-message-markdown ol {
  margin: 0.55em 0;
  padding-left: 1.35em;
}

.v4-message-markdown li {
  margin: 0.25em 0;
  padding-left: 0.1em;
}

.v4-message-markdown strong {
  font-weight: 700;
}

.v4-message-markdown code {
  padding: 0.1em 0.34em;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.22);
}

.v4-message-markdown__pre {
  max-width: 100%;
  margin: 0.7em 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  overflow-x: auto;
  color: rgba(255, 247, 234, 0.94);
  background: rgba(0, 0, 0, 0.28);
  -webkit-overflow-scrolling: touch;
}

.v4-message-markdown__pre code,
.v4-message-markdown code.v4-message-markdown__code-block {
  display: block;
  min-width: max-content;
  padding: 0;
  border: 0;
  border-radius: 0;
  line-height: 1.62;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  background: transparent;
}

.v4-message-markdown a {
  color: rgba(207, 228, 255, 0.98);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
}

.v4-message-markdown blockquote {
  margin: 0.7em 0;
  padding: 0.1em 0 0.1em 0.85em;
  border-left: 3px solid rgba(255, 247, 234, 0.24);
  color: var(--v4-text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.v4-message-markdown blockquote p {
  margin: 0.42em 0;
}

.v4-message-markdown__hr {
  margin: 0.85em 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

@media (max-width: 420px) {
  .v4-message__meta {
    flex-wrap: wrap;
  }

  .v4-message-markdown {
    line-height: 1.68;
  }

  .v4-message-markdown h1 {
    font-size: 1.08rem;
  }

  .v4-message-markdown h2 {
    font-size: 1.02rem;
  }

  .v4-message-markdown h3,
  .v4-message-markdown h4 {
    font-size: 0.96rem;
  }

  .v4-message-markdown ul,
  .v4-message-markdown ol {
    padding-left: 1.15em;
  }

  .v4-message-markdown__pre {
    padding: 10px;
  }
}

/* =========================
   v4 Theme 2 POC-1 Voice Input
========================= */

.v4-message-input-bar__voice-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(255, 235, 205, 0.16);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.78);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.v4-message-input-bar__voice-button:hover {
  border-color: rgba(243, 221, 176, 0.32);
  color: rgba(255, 247, 234, 0.92);
  background: rgba(255, 255, 255, 0.08);
}

.v4-message-input-bar__voice-button.is-active {
  border-color: rgba(255, 205, 147, 0.46);
  color: #fff1da;
  background: rgba(255, 172, 88, 0.16);
}

.v4-message-input-bar__voice-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.v4-message-input-bar__voice-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.v4-message-input__voice-status {
  margin: 8px 0 0;
  color: var(--v4-text-subtle);
  font-size: 0.74rem;
  line-height: 1.5;
}

.v4-message-input__voice-status.is-listening,
.v4-message-input__voice-status.is-transcribing {
  color: rgba(255, 241, 218, 0.86);
}

.v4-message-input__voice-status.is-completed {
  color: rgba(191, 237, 216, 0.92);
}

.v4-message-input__voice-status.is-failed,
.v4-message-input__voice-status.is-unsupported,
.v4-message-input__voice-status.is-permission_denied {
  color: rgba(255, 194, 194, 0.92);
}

/* =========================
   v4 Theme 2 POC-1.5 Continuous Voice Input
========================= */

.v4-message-input__voice-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.v4-message-input__voice-preview {
  margin: 8px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(255, 235, 205, 0.12);
  border-radius: 12px;
  color: rgba(255, 247, 234, 0.82);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.78rem;
  line-height: 1.55;
  max-height: 128px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.v4-message-input__voice-preview-label {
  margin: 0 0 4px;
  color: rgba(255, 247, 234, 0.58);
  font-size: 0.7rem;
  font-weight: 700;
}

.v4-message-input__voice-preview-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.v4-message-input__voice-preview-text.is-interim {
  margin-top: 4px;
  color: rgba(255, 247, 234, 0.52);
}

/* =========================
   v4 Theme 2 Formal Voice Input UI
   案E': 二層グループ型 + 安全オーバーレイプレビュー型
========================= */

.v4-message-input {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: rgba(18, 15, 26, 0.72);
}

.v4-message-input__compose-group,
.v4-message-input__send-group {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 9px;
}

.v4-message-input__compose-group {
  overflow: visible;
}

.v4-message-input__group {
  display: flex;
  gap: 6px;
}

.v4-message-input__group-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(239, 208, 255, 0.86);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.v4-message-input__group-number {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #21132e;
  background: linear-gradient(180deg, #f7e4ff 0%, var(--v4-accent-strong) 100%);
  font-size: 0.76rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(217, 168, 255, 0.18);
}

.v4-message-input__voice-add-button {
  display: inline-flex;
  width: 100%;
  max-width: 140px;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(243, 221, 176, 0.22);
  border-radius: 999px;
  color: rgba(255, 247, 234, 0.94);
  background:
    linear-gradient(180deg, rgba(255, 248, 255, 0.12), rgba(255, 248, 255, 0.055));
  font-weight: 700;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.v4-message-input__voice-add-button:hover:not(:disabled) {
  border-color: rgba(243, 221, 176, 0.40);
  background:
    linear-gradient(180deg, rgba(255, 248, 255, 0.17), rgba(255, 248, 255, 0.085));
}

.v4-message-input__voice-add-button:active:not(:disabled) {
  transform: scale(0.99);
}

.v4-message-input__voice-add-icon {
  color: var(--v4-accent-strong);
  font-size: 1.08rem;
  line-height: 1;
}

.v4-message-input__voice-add-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v4-message-input__textarea {
  width: 100%;
  min-height: 48px;
  max-height: 132px;
  padding: 12px 13px;
  border: 1px solid var(--v4-border);
  border-radius: 16px;
  outline: none;
  overflow-y: auto;
  resize: none;
  color: var(--v4-text);
  background: rgba(255, 255, 255, 0.09);
  line-height: 1.55;
}

.v4-message-input__textarea::placeholder {
  color: var(--v4-text-subtle);
}

.v4-message-input__textarea:focus {
  border-color: rgba(240, 209, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(217, 168, 255, 0.14);
}

.v4-message-input__send-helper {
  margin: -2px 0 0;
  color: var(--v4-text-subtle);
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
}

.v4-message-input__send-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(94px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.v4-message-input__send-actions .v4-message-input-bar__network-toggle,
.v4-message-input__send-actions .v4-message-input__send-button {
  width: 100%;
  min-height: 42px;
}

.v4-message-input__send-group.is-disabled {
  opacity: 0.56;
}

.v4-message-input__send-group.is-disabled .v4-message-input__send-helper {
  color: rgba(255, 247, 234, 0.52);
}

.v4-message-input__voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  color: rgba(239, 208, 255, 0.88);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
}

.v4-message-input__voice-status.is-completed::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: #21132e;
  background: var(--v4-accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
}

.v4-message-input__voice-status.is-failed,
.v4-message-input__voice-status.is-permission_denied,
.v4-message-input__voice-status.is-unsupported {
  color: #ffd8df;
}

.v4-voice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.v4-voice-overlay {
  position: absolute;
  left: 9px;
  right: 9px;
  top: -20px;
  z-index: 901;
  display: grid;
  gap: 9px;
  border: 1px solid rgba(239, 208, 255, 0.36);
  border-radius: 18px;
  padding: 10px;
  color: var(--v4-text);
  background: #21172f;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.v4-voice-overlay__header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.v4-voice-overlay__listening-mark {
  flex: 0 0 auto;
  color: var(--v4-accent-strong);
  font-size: 0.75rem;
  letter-spacing: -0.08em;
  opacity: 0.92;
}

.v4-voice-overlay__status {
  flex: 1 1 auto;
  min-width: 0;
  color: rgba(255, 247, 234, 0.88);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.v4-voice-overlay__stop-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(243, 221, 176, 0.28);
  border-radius: 999px;
  color: #fff7ea;
  background:
    linear-gradient(180deg, rgba(115, 79, 158, 0.96), rgba(74, 47, 112, 0.98));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  font-weight: 800;
}

.v4-voice-overlay__body {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.065);
}

.v4-voice-overlay__label {
  margin: 0;
  color: rgba(239, 208, 255, 0.92);
  font-size: 0.74rem;
  font-weight: 800;
}

.v4-voice-overlay__preview {
  max-height: 112px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.v4-voice-overlay__preview-text,
.v4-voice-overlay__preview-empty {
  margin: 0;
  overflow-wrap: anywhere;
  color: rgba(255, 247, 234, 0.92);
  font-size: 0.88rem;
  line-height: 1.6;
}

.v4-voice-overlay__preview-text.is-interim {
  color: rgba(255, 247, 234, 0.58);
}

.v4-voice-overlay__preview-empty {
  color: var(--v4-text-subtle);
}

.v4-voice-overlay__note {
  margin: 2px 0 0;
  color: rgba(255, 247, 234, 0.58);
  font-size: 0.70rem;
  line-height: 1.45;
}

/* Hide legacy POC voice preview/actions if stale DOM or old CSS remains. */
.v4-message-input__voice-actions,
.v4-message-input__voice-preview {
  display: none;
}
