:root {
  --wx-green: #07c160;
  --wx-green-dark: #06ad56;
  --wx-green-soft: #e8f8ef;
  --wx-green-soft-hover: #d4f2e0;
  --wx-green-border: #9edfb8;
  --wx-green-glow: rgba(7, 193, 96, 0.18);
  --bg: #f0f2f4;
  --bg-chat: #f0f2f4;
  --panel: #f7f8f9;
  --surface: #fff;
  --line: #e3e6ea;
  --text: #1a1a1a;
  --muted: #7a828a;
  --bubble-other: #fff;
  --bubble-mine: #95ec69;
  --danger: #fa5151;
  --danger-soft: #fff0f0;
  --danger-soft-hover: #ffe3e3;
  --danger-border: #ffb4b4;
  --btn-disabled-bg: #f0f0f0;
  --btn-disabled-text: #b0b0b0;
  --btn-disabled-border: #e0e0e0;
  --btn-disabled-primary-bg: #059a4c;
  --control-h: 40px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 8px;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[v-cloak] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

button:active:not(:disabled) {
  opacity: 0.88;
}

/* Brand mark */
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--wx-green);
  color: #fff;
  font-size: 26px;
}

.brand-mark.lg {
  width: 80px;
  height: 80px;
  font-size: 38px;
  border-radius: var(--radius-lg);
  margin: 0 auto 20px;
}

/* Loading */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--panel);
}

.loading-text {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.loading-sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.loading-bar {
  width: 120px;
  height: 3px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.loading-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--wx-green);
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  background: var(--panel);
}

.app-shell button,
.app-shell a.icon-btn,
.app-shell label.icon-btn {
  opacity: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0;
  width: var(--control-h);
  height: var(--control-h);
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn .bi {
  color: inherit;
  line-height: 1;
}

.icon-btn.accent,
.icon-btn.primary {
  border-color: var(--wx-green);
  background: var(--wx-green);
  color: #fff;
}

.icon-btn.accent:hover,
.icon-btn.primary:hover {
  background: var(--wx-green-dark);
  border-color: var(--wx-green-dark);
}

.icon-btn.accent .bi,
.icon-btn.primary .bi {
  color: #fff;
}

.icon-btn.danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn.danger:hover {
  background: var(--danger-soft-hover);
  border-color: var(--danger);
}

.icon-btn:disabled,
.welcome-btn:disabled,
.tab-btn:disabled,
.file-sub-btn:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: var(--btn-disabled-bg);
  color: var(--btn-disabled-text);
  border-color: var(--btn-disabled-border);
}

.tab-btn.active:disabled,
.file-sub-btn.active:disabled {
  background: var(--btn-disabled-primary-bg);
  color: #fff;
  border-color: var(--btn-disabled-primary-bg);
}

.icon-btn.accent:disabled,
.icon-btn.primary:disabled,
.welcome-btn.primary:disabled {
  background: var(--btn-disabled-primary-bg);
  color: #fff;
  border-color: var(--btn-disabled-primary-bg);
}

.icon-btn.danger:disabled {
  background: var(--danger-soft);
  color: #f0a0a0;
  border-color: var(--danger-border);
}

.icon-btn.sm {
  width: 34px;
  height: 34px;
  font-size: 15px;
}

.icon-btn.xs {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.icon-btn.lg {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

/* Header & tabs — workspace top bar */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.space-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.space-meta-icon {
  color: var(--wx-green);
  font-size: 16px;
  flex-shrink: 0;
}

.space-code {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
  color: var(--wx-green-dark);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-meta-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tab-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 0;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 0;
}

.tab-btn {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  min-height: 36px;
  min-width: 72px;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn .bi {
  color: inherit;
  font-size: 17px;
}

.tab-btn.active {
  color: #fff;
  background: var(--wx-green);
  font-weight: 600;
}

.tab-btn.active .bi {
  color: #fff;
}

.tab-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 600;
}

.space-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--wx-green);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
}

.space-copy:hover {
  background: var(--wx-green-dark);
}

.space-copy.muted {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* Welcome — split layout */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: 0;
  background: var(--panel);
  overflow: hidden;
}

.welcome-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

.welcome-rail {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow-y: auto;
}

.welcome-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0;
}

.welcome-brand .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 22px;
  flex-shrink: 0;
}

.welcome-brand-text {
  min-width: 0;
  flex: 1;
}

.welcome-title {
  margin: 0;
  font-size: 24px;
  text-align: left;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.welcome-desc {
  margin: 8px 0 0;
  max-width: none;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.welcome-entry {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entry-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.entry-mode-btn {
  min-height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.entry-mode-btn.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.entry-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.entry-input + .entry-input {
  margin-top: 0;
}

.entry-input:focus {
  outline: none;
  border-color: var(--wx-green);
  background: var(--surface);
}

.entry-input::placeholder {
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

.visibility-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0;
}

.visibility-switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  min-width: 2em;
  text-align: center;
  transition: color 0.12s ease;
}

.visibility-switch-label.active {
  color: var(--text);
  font-weight: 600;
}

.visibility-switch-track {
  position: relative;
  width: 52px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.visibility-switch-track.on {
  background: var(--wx-green);
  border-color: var(--wx-green);
}

.visibility-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  transition: transform 0.15s ease;
  box-sizing: border-box;
}

.visibility-switch-track.on .visibility-switch-thumb {
  transform: translateX(22px);
  border-color: transparent;
}

.entry-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.entry-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.entry-action-block {
  width: 100%;
}

.entry-action:hover {
  border-color: var(--wx-green-border);
  background: var(--wx-green-soft);
}

.entry-action.primary {
  border-color: var(--wx-green);
  background: var(--wx-green);
  color: #fff;
}

.entry-action.primary:hover:not(:disabled) {
  border-color: var(--wx-green-dark);
  background: var(--wx-green-dark);
}

.entry-action:disabled {
  cursor: not-allowed;
  background: var(--btn-disabled-primary-bg);
  border-color: var(--btn-disabled-primary-bg);
  color: #fff;
}

.entry-secondary-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 4px;
}

.entry-link {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  cursor: pointer;
}

.entry-link:hover {
  color: var(--wx-green-dark);
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome-actions-stack {
  width: 100%;
}

.welcome-actions-stack .welcome-btn {
  width: 100%;
}

.welcome-actions.row-actions {
  flex-direction: row;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.welcome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 500;
  min-height: 48px;
  white-space: nowrap;
  cursor: pointer;
}

.welcome-btn-lg {
  min-height: 52px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  gap: 10px;
  border-radius: var(--radius-md);
}

.welcome-btn-lg .bi {
  font-size: 20px;
}

.welcome-btn.sm {
  min-height: 34px;
  min-width: 34px;
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.welcome-btn.sm.primary {
  min-width: 72px;
  padding: 6px 16px;
}

.welcome-btn .bi {
  font-size: 18px;
  color: var(--muted);
}

.welcome-btn.primary {
  border-color: var(--wx-green);
  background: var(--wx-green);
  color: #fff;
}

.welcome-btn.primary:hover:not(:disabled) {
  background: var(--wx-green-dark);
  border-color: var(--wx-green-dark);
}

.welcome-btn.primary .bi {
  color: #fff;
}

.welcome-public-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: none;
  border-radius: 0;
  overflow: hidden;
}

.welcome-public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.welcome-public-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.welcome-public-title .bi-globe2 {
  color: var(--wx-green);
  font-size: 18px;
}

.welcome-public-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.welcome-public-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
  font-size: 12px;
  font-weight: 700;
}

.welcome-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.welcome-refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.welcome-public-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.welcome-public-empty .bi {
  font-size: 32px;
  color: var(--line);
  margin-bottom: 4px;
}

.welcome-public-empty p {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.welcome-public-empty span {
  font-size: 13px;
}

.welcome-public-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  max-height: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}

.welcome-public-row {
  display: grid;
  grid-template-columns: minmax(100px, 140px) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.welcome-public-row:hover {
  background: var(--panel);
}

.welcome-public-id-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.welcome-public-id {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
  color: var(--wx-green-dark);
}

.welcome-public-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(13, 110, 253, 0.12);
  color: #0d6efd;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.welcome-public-note {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.welcome-public-note.muted {
  color: var(--muted);
}

.welcome-public-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.welcome-public-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.welcome-public-row-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.welcome-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-label {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
}

.panel-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  line-height: 1.5;
}

.password-display {
  padding: 20px 16px;
  border-radius: var(--radius-md);
  background: var(--wx-green-soft);
  border: 1px dashed var(--wx-green-border);
  font-size: clamp(26px, 8vw, 32px);
  font-weight: 700;
  text-align: center;
  letter-spacing: clamp(4px, 2vw, 8px);
  font-variant-numeric: tabular-nums;
  color: var(--wx-green-dark);
}

.password-display.muted {
  font-size: 16px;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 500;
  border-style: solid;
  background: var(--panel);
  border-color: var(--line);
}

.password-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.password-input.text-input {
  letter-spacing: 2px;
  font-size: 18px;
}

.password-input.numeric-input {
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
}

/* Dialog (wd-* avoids Bootstrap .modal-dialog pointer-events:none) */
.wd-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.4);
}

.wd-dialog {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: min(85vh, 560px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  pointer-events: auto;
}

.wd-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.wd-dialog-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.wd-dialog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}

.wd-dialog-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.wd-dialog-footer .welcome-btn {
  flex: 1;
  min-height: 44px;
}

.vanity-modal .wd-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Legacy modal aliases (password sheet etc.) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.4);
}

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: min(85vh, 560px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.modal-footer .welcome-btn {
  flex: 1;
  min-height: 44px;
}

.vanity-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Password sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.sheet-panel {
  width: 100%;
  max-height: min(70vh, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.sheet-body .welcome-btn {
  width: 100%;
  min-height: 44px;
}

.visibility-toggle {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visibility-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 500;
  min-height: 52px;
  cursor: pointer;
}

.visibility-btn.active {
  border-color: var(--wx-green);
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
  font-weight: 600;
}

.created-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.created-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.visibility-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

.visibility-badge.public {
  background: #eff6ff;
  color: #2563eb;
}

.visibility-badge.private {
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
}

.password-display.secondary {
  font-size: clamp(18px, 5vw, 22px);
  letter-spacing: 2px;
}

.visibility-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.visibility-tag.public {
  background: #eff6ff;
  color: #2563eb;
}

.visibility-tag.private {
  background: rgba(255, 255, 255, 0.7);
  color: var(--wx-green-dark);
}

.vanity-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: #fff4e5;
  color: #d97706;
  flex-shrink: 0;
}

.space-sub-id {
  margin: 6px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.vanity-pick-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.vanity-pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.vanity-pick-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.vanity-pick-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.vanity-pick-option.active {
  border-color: var(--wx-green);
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
}

.vanity-pick-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.vanity-pick-option:hover:not(.active) {
  border-color: var(--wx-green);
}

.vanity-selected-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
  font-size: 14px;
  text-align: center;
}

.vanity-selected-hint strong {
  font-size: 18px;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.empty-state.compact {
  padding: 16px 0;
  text-align: center;
  color: var(--muted);
}

.password-input:focus {
  outline: none;
  border-color: var(--wx-green);
  background: var(--surface);
}

.welcome-back {
  margin-top: 4px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  min-height: var(--control-h);
  cursor: pointer;
}

/* Main panels */
.app-main {
  flex: 1;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.messages-panel {
  background: var(--bg-chat);
}

.message-list .empty-state {
  min-height: 40vh;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-chat);
}

.message-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 16px;
  animation: msg-in 0.2s ease;
}

.message-item.mine {
  align-items: flex-end;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble {
  max-width: min(72%, 640px);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bubble-other);
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-item.mine .bubble {
  background: var(--bubble-mine);
  border-color: #7ad952;
}

.bubble-image {
  padding: 4px;
  background: transparent !important;
  border: none;
}

.bubble-file-wrap {
  padding: 0;
  background: var(--bubble-other) !important;
  overflow: hidden;
}

.message-item.mine .bubble-file-wrap {
  background: var(--bubble-mine) !important;
}

.bubble-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-width: 160px;
  max-width: min(280px, 75vw);
  color: inherit;
  text-decoration: none;
}

.bubble-file .bi {
  font-size: 22px;
  flex-shrink: 0;
  color: var(--wx-green-dark);
}

.bubble-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.bubble-file-size {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.bubble-invalid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.message-image {
  display: block;
  max-width: min(280px, 65vw);
  max-height: min(280px, 42vh);
  border-radius: var(--radius-md);
  cursor: zoom-in;
}

.time {
  margin-top: 4px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Composer — full width */
.composer {
  display: flex;
  width: 100%;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  box-sizing: border-box;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
}

.composer-btn {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: var(--control-h);
  max-height: 120px;
  line-height: 1.45;
  background: var(--panel);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--wx-green);
  background: var(--surface);
}

/* Files panel */
.files-panel {
  background: var(--panel);
}

.files-panel > .empty-state {
  flex: 1;
}

.files-toolbar {
  display: flex;
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  padding: 0 16px;
  box-sizing: border-box;
}

.files-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
}

.upload-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  flex: 1 1 220px;
  min-width: 0;
}

.upload-icon {
  width: var(--control-h);
  height: var(--control-h);
  font-size: 20px;
  border-radius: var(--radius-sm);
}

.upload-hint {
  font-size: 12px;
  color: var(--muted);
}

.file-subnav {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  flex: 0 0 auto;
  background: transparent;
  border-bottom: none;
}

.file-sub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  min-width: 100px;
}

.file-sub-btn .bi {
  color: inherit;
}

.file-sub-btn.active {
  border-color: var(--wx-green);
  color: #fff;
  background: var(--wx-green);
}

.file-sub-btn.active .bi {
  color: #fff;
}

.file-count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.06);
  font-size: 11px;
  line-height: 18px;
  font-weight: 600;
}

.file-sub-btn.active .file-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* File grid (images) */
.file-grid {
  list-style: none;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  align-content: start;
}

.file-grid-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.file-grid-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--panel);
}

.file-grid-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-grid-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
}

.file-grid-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.file-grid-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* File list (documents) */
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.file-item:hover {
  background: var(--panel);
}

.file-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--wx-green-soft);
  color: var(--wx-green-dark);
  font-size: 18px;
  flex-shrink: 0;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.file-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state .bi {
  font-size: 40px;
  color: var(--line);
  margin-bottom: 4px;
}

.empty-state p {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.empty-state span {
  font-size: 13px;
}

.empty-tip {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
}

/* Image preview */
.image-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.88);
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.preview-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.preview-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.image-preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Toasts */
.toast-stack {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(calc(100% - 24px), 360px);
  pointer-events: none;
}

.toast-item {
  padding: 11px 18px;
  border-radius: var(--radius-md);
  background: #333;
  color: #fff;
  font-size: 14px;
  text-align: center;
  animation: toast-in 0.2s ease;
}

.toast-success {
  background: var(--wx-green);
}

.toast-error {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (min-width: 900px) {
  .welcome-layout {
    display: grid;
    grid-template-columns: minmax(320px, 400px) 1fr;
    height: 100%;
  }

  .welcome-rail {
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 32px 28px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
    height: 100%;
  }

  .welcome-public-section {
    height: 100%;
  }

  .welcome-public-header {
    padding: 16px 24px;
  }

  .welcome-public-row {
    grid-template-columns: 160px minmax(0, 1fr) auto auto;
    padding: 12px 24px;
  }

  .app-header {
    padding: 10px 24px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .tab-nav {
    min-width: 220px;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 20px 24px;
  }

  .file-item {
    padding: 12px 24px;
  }

  .message-list {
    padding: 20px 24px 8px;
  }

  .composer {
    padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  }

  .files-toolbar {
    padding: 0 24px;
  }
}

@media (min-width: 768px) {
  .visibility-toggle {
    flex-direction: row;
  }

  .visibility-btn {
    flex: 1;
  }

  .sheet-overlay {
    align-items: center;
  }

  .sheet-panel {
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    max-width: 420px;
    margin: 24px;
  }

  .message-image {
    max-width: 320px;
    max-height: 320px;
  }

  .bubble {
    max-width: min(70%, 720px);
  }
}

@media (min-width: 1200px) {
  .welcome-layout {
    grid-template-columns: minmax(340px, 420px) 1fr;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
  }

  .bubble {
    max-width: min(58%, 800px);
  }
}

@media (max-width: 899px) {
  .welcome-screen {
    overflow-y: auto;
  }

  .welcome-layout {
    height: auto;
    min-height: 100%;
  }

  .welcome-public-section {
    min-height: 420px;
  }

  .welcome-public-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id actions"
      "note note"
      "meta meta";
    gap: 8px 12px;
    padding: 14px 16px;
  }

  .welcome-public-id-cell {
    grid-area: id;
  }

  .welcome-public-note {
    grid-area: note;
  }

  .welcome-public-meta {
    grid-area: meta;
    flex-wrap: wrap;
  }

  .welcome-public-row-actions {
    grid-area: actions;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .space-meta {
    flex: 1 1 calc(100% - 52px);
    order: 1;
  }

  .app-header > .icon-btn.accent {
    order: 2;
  }

  .tab-nav {
    flex: 1 1 100%;
    order: 3;
  }

  .tab-label {
    display: none;
  }

  .tab-btn {
    padding: 8px 10px;
    min-width: 0;
  }

  .bubble {
    max-width: 88%;
  }

  .space-code {
    letter-spacing: 1px;
    font-size: 15px;
  }

  .welcome-rail {
    padding: 20px 16px;
  }

  .file-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
  }

  .file-sub-btn {
    flex: 1;
    min-width: 0;
  }

  .file-subnav {
    flex: 1 1 100%;
  }
}
