/* Upscale Designers & Sourcing — Architectural / Interiors Studio Palette
   Zero external CDN/font dependencies (fast in US, China & Vietnam) */

:root {
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface-alt: #F2EFE9;
  --surface-hover: #ECE8DF;
  --ink: #1C1E21;
  --ink-muted: #5B616A;
  --ink-subtle: #828891;
  --border: #E4DFD4;
  --border-strong: #D0C9BA;
  --primary: #234B8A;
  --primary-hover: #1B3B6E;
  --primary-soft: #EBF1FA;
  --accent: #B08A48;
  --accent-soft: #F7F1E3;
  --success: #1F7A4C;
  --success-soft: #E7F5EE;
  --warning: #B4690E;
  --warning-soft: #FDF3E2;
  --danger: #B93232;
  --danger-soft: #FCEBEB;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(28, 30, 33, 0.06);
  --shadow: 0 4px 16px rgba(28, 30, 33, 0.08);
  --shadow-lg: 0 12px 36px rgba(28, 30, 33, 0.14);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-muted);
}

/* Auth / Setup Screen */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top right, rgba(35,75,138,0.07), transparent 45%),
              radial-gradient(circle at bottom left, rgba(176,138,72,0.09), transparent 45%),
              var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.auth-brand-sub {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.auth-lang-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Top Navigation Shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 18px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}

.brand-link:hover { text-decoration: none; }

.brand-name {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-tag {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(35, 75, 138, 0.18);
}

.nav-count {
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--ink-muted);
  padding: 1px 7px;
  border-radius: 99px;
}

.nav-tab.active .nav-count {
  background: var(--primary);
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-toggle {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12.5px;
}

.user-pill-name {
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Content */
.main {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 18px 48px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--surface-alt); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { filter: brightness(0.94); }

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { filter: brightness(0.93); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.93); }

.btn-soft {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}
.btn-soft:hover:not(:disabled) { background: #dde7f7; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }

/* Inputs & Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 75, 138, 0.12);
}

.textarea { min-height: 76px; resize: vertical; }

.search-input {
  max-width: 320px;
  flex: 1;
  min-width: 200px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent { background: var(--accent-soft); color: #7C5E28; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--ink-muted); }

.unread-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 15.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.project-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.project-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
}

.project-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 2px 0 0;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.stage-mini-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  margin-top: 2px;
}

.stage-mini-seg {
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}
.stage-mini-seg.done { background: var(--success); }
.stage-mini-seg.current { background: var(--primary); }

/* 8-Stage Interactive Stepper */
.stepper-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.step-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface);
}

.step-btn.is-done {
  background: #F4FAF6;
  border-color: #B7DEC8;
  color: var(--ink);
}

.step-btn.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.step-btn.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(35, 75, 138, 0.22);
}

.step-btn.is-selected .step-num,
.step-btn.is-selected .step-tag { color: rgba(255,255,255,0.88); }

.step-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.step-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.step-label {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
}

.step-tag {
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* Split Stage Workspace: Structured Panel + Dedicated Stage Chat */
.stage-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 18px;
  align-items: start;
}

/* Dedicated Stage Chat Panel */
.chat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 640px;
  position: sticky;
  top: 78px;
  overflow: hidden;
}

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-header-title {
  font-weight: 700;
  font-size: 14.5px;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FAF9F6;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--ink-subtle);
  padding: 24px;
  max-width: 280px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.msg-row.mine .msg-bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.msg-thumb {
  width: 110px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
}

.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.chat-composer {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-readonly-banner {
  padding: 11px 14px;
  background: var(--accent-soft);
  color: #7C5E28;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  border-top: 1px solid var(--border);
}

.composer-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-row textarea {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  resize: none;
}

/* File Rows & Galleries */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  flex-wrap: wrap;
}

.file-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.file-mini-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}

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

.file-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.photo-tile img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.photo-tile-cap {
  padding: 5px 7px;
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Entity Item Cards inside Stage Panels */
.sub-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #FCFBF9;
  margin-bottom: 10px;
}

.sub-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Tables (Vendors / Users) */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data-table th, table.data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.data-table tr:last-child td { border-bottom: none; }

/* Notice / Callout Banner */
.notice {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.notice-info { background: var(--primary-soft); border-color: rgba(35,75,138,0.22); color: #1B3B6E; }
.notice-warn { background: var(--warning-soft); border-color: rgba(180,105,14,0.25); color: #7A4809; }
.notice-success { background: var(--success-soft); border-color: rgba(31,122,76,0.25); color: #165937; }
.notice-danger { background: var(--danger-soft); border-color: rgba(185,50,50,0.25); color: #8A2222; }

/* Modal & Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 24, 30, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 14, 18, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.lightbox-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 13px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 340px;
}

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

.empty-state {
  text-align: center;
  padding: 46px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--ink-muted);
}

.mono-box {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 960px) {
  .stage-workspace {
    grid-template-columns: 1fr;
  }
  .chat-card {
    position: static;
    height: 520px;
  }
  .stepper {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar-inner { padding: 8px 12px; }
  .main { padding: 14px 12px 36px; }
  .projects-grid { grid-template-columns: 1fr; }
  .user-pill-name { display: none; }
  .stepper { grid-template-columns: repeat(2, minmax(125px, 1fr)); }
}


/* 4-language toggle responsive & AI Writing Assistant */
.lang-toggle {
  white-space: nowrap;
  flex-shrink: 0;
}
.lang-btn {
  white-space: nowrap;
}
.lang-short {
  display: none;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-help-btn {
  font-weight: 600;
}
.ai-writer-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.ai-tab-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.ai-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.ai-tpl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.ai-tpl-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-alt);
}
.ai-tpl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.ai-tpl-preview {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-muted);
  white-space: pre-wrap;
}

@media (max-width: 600px) {
  .lang-full { display: none; }
  .lang-short { display: inline; }
  .topbar .lang-btn { padding: 4px 7px; font-size: 11.5px; }
  .auth-lang-row .lang-btn { padding: 4px 8px; font-size: 12px; }
  .topbar-right { gap: 6px; }
}

/* Mobile single-column stacking & overflow safety */
.card { min-width: 0; }
.notice { overflow-wrap: anywhere; word-break: break-word; }
.btn { max-width: 100%; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
}
