:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: #202938;
  background: #f8fafc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, textarea { font: inherit; }
button { cursor: pointer; }
.wrap { max-width: 1310px; margin: auto; padding: 28px 28px 40px; }
.header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 0 0 24px; border-bottom: 1px solid #e8ecf2; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.2px; color: #1e293b; white-space: nowrap; }
.brand-icon { width: 33px; height: 33px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: #2563eb; font-size: 19px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.sync-status { display: flex; gap: 8px; align-items: center; white-space: nowrap; font-size: 12px; color: #64748b; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; display: inline-block; }
.sync-status.online .status-dot { background: #16a34a; }
.sync-status.offline .status-dot { background: #ef4444; }
.link-button { background: #fff; border: 1px solid #d9e2ee; color: #334155; padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 650; }
.link-button:hover { background: #eff6ff; border-color: #93c5fd; }
.intro { margin: 28px 0 26px; }
h1 { font-size: clamp(22px, 2.6vw, 30px); margin: 0 0 9px; font-weight: 750; letter-spacing: -.9px; }
.intro p { font-size: 14px; color: #64748b; margin: 0; line-height: 1.7; }
.intro strong { color: #334155; }
.intro-art {
  margin: 0;
  display: inline-block;
  width: 100%;
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -.35px;
  text-align: center;
  font-style: italic;
  transform: rotate(-1.3deg) skewX(-4deg);
  transform-origin: center;
  background: linear-gradient(92deg, #ff4fa3 0%, #ff74bf 24%, #bf6cff 60%, #7c5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 12px 24px rgba(236, 72, 153, .18), 0 4px 12px rgba(124, 92, 255, .18);
  font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive, sans-serif;
  filter: saturate(1.14);
}

.panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.03fr); gap: 19px; align-items: stretch; }
.pane { display: flex; flex-direction: column; min-width: 0; background: white; border: 1px solid #e2e8f0; border-radius: 15px; box-shadow: 0 3px 16px rgba(15, 23, 42, .025); overflow: hidden; }
.pane-head { min-height: 91px; padding: 20px 20px 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pane-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.step { background: #eaf1ff; color: #1d4ed8; font-size: 13px; font-weight: 750; border-radius: 10px; width: 39px; height: 39px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.phone-step { background: #e8f8ef; color: #15803d; }
h2 { font-size: 16px; font-weight: 730; margin: 0 0 5px; letter-spacing: -.2px; }
.pane-head p { margin: 0; color: #94a3b8; font-size: 12px; }
.text-button { color: #64748b; border: none; padding: 7px 2px; background: none; white-space: nowrap; font-size: 12px; }
.text-button:hover { color: #e11d48; }
#mail-input { display: block; flex: 1; width: calc(100% - 40px); margin: 0 20px; min-height: 395px; resize: vertical; padding: 17px; background: #fbfdff; border: 1px solid #e1e8f0; border-radius: 10px; outline: none; font-size: 14px; line-height: 2.05; color: #334155; }
#mail-input:focus { border-color: #7baeff; box-shadow: 0 0 0 3px rgba(59,130,246,.08); }
#mail-input::placeholder { color: #a9b6c6; }
.pane-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 20px; font-size: 11px; color: #94a3b8; min-height: 58px; }
#editor-count { color: #64748b; white-space: nowrap; }
.count-pill { font-weight: 750; border-radius: 999px; background: #f1f5f9; color: #64748b; font-size: 12px; padding: 6px 10px; }
.email-list { margin: 0 20px; height: 395px; overflow: auto; background: #fff; border: 1px solid #edf1f6; border-radius: 10px; }
.email-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 59px; padding: 10px 12px 10px 15px; border-bottom: 1px solid #f1f5f9; }
.email-row:last-child { border-bottom: none; }
.email-row:nth-child(even) { background: #fcfdff; }
.email-name { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 550; color: #334155; user-select: text; }
.copy-button { flex-shrink: 0; background: #ecfdf3; color: #15803d; border: 1px solid #c7f1d8; border-radius: 8px; font-weight: 720; padding: 9px 14px; font-size: 12px; min-width: 88px; }
.copy-button:hover { background: #dcfce7; }
.copy-button.copied { background: #dcfce7; }
.empty { height: 100%; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #94a3b8; text-align: center; gap: 9px; padding: 20px; }
.empty-icon { display: grid; place-items: center; height: 52px; width: 52px; background: #f1f5f9; border-radius: 15px; font-size: 28px; color: #cbd5e1; margin-bottom: 5px; }
.empty strong { color: #64748b; font-size: 14px; }
.empty p { font-size: 12px; margin: 0; }
footer { margin: 28px auto 0; color: #94a3b8; text-align: center; font-size: 11px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 26px; transform: translate(-50%, 14px); padding: 12px 19px; background: #1e293b; color: white; border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); white-space: nowrap; max-width: calc(100% - 24px); text-align: center; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
@media(max-width: 760px) {
  .wrap { padding: 16px 13px 32px; }
  .header { padding-bottom: 16px; }
  .brand { font-size: 18px; }
  .brand-icon { width: 31px; height: 31px; }
  .header-actions { gap: 8px; }
  .sync-status { font-size: 0; gap: 0; }
  .status-dot { width: 9px; height: 9px; }
  .link-button { padding: 9px 10px; font-size: 12px; }
  .intro { margin: 22px 2px 20px; }
  h1 { font-size: 23px; line-height: 1.25; }
  .intro p { font-size: 13px; }
  .intro-art { font-size: clamp(26px, 8.4vw, 36px); line-height: 1.24; }
  .panes { display: flex; flex-direction: column; gap: 14px; }
  .copy-pane { order: 1; }
  .editor-pane { order: 2; }
  .pane-head { padding: 15px; min-height: 75px; }
  .pane-title { gap: 10px; }
  .step { width: 35px; height: 35px; }
  h2 { font-size: 14px; }
  .email-list { height: auto; min-height: 210px; max-height: 62vh; margin: 0 14px; }
  .pane-footer { padding: 13px 15px; min-height: 48px; }
  #mail-input { margin: 0 14px; width: calc(100% - 28px); min-height: 200px; max-height: 50vh; }
  .empty { min-height: 210px; }
  footer { line-height: 1.6; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
/* v2.1 – iPhone & hosting diagnostics */
[hidden] { display: none !important; }
.connection-info { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.room-pill { color: #334155; background: #eaf1ff; font-size: 12px; border-radius: 8px; padding: 7px 11px; max-width: 100%; overflow-wrap: anywhere; }
.status-detail { color: #b42318; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.retry-button { border: 1px solid #fecaca; background: #fff1f2; color: #9f1239; border-radius: 8px; font-size: 12px; padding: 7px 12px; cursor: pointer; }
#mail-input:disabled, .text-button:disabled { opacity: .65; cursor: not-allowed; }
.editor-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mobile-actions { display: none; }
.conflict-panel { margin-top: 16px; border: 1px solid #fbd38d; background: #fffaf0; padding: 15px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.conflict-panel p { margin: 5px 0 12px; color: #805a1a; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conflict-actions button { padding: 9px 12px; border-radius: 8px; border: 1px solid #d9e2ee; background: white; cursor: pointer; }
.manual-copy { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.manual-card { width: min(100%, 420px); background: #fff; border-radius: 15px; padding: 22px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.manual-card h2 { font-size: 18px; }
.manual-card p { color: #64748b; font-size: 13px; line-height: 1.7; }
.manual-card textarea { width: 100%; font-size: 16px; padding: 12px; border: 1px solid #bfd2e5; border-radius: 10px; overflow-wrap: anywhere; resize: vertical; }
.manual-card button { margin-top: 12px; width: 100%; padding: 10px; border: 0; background: #2563eb; color: white; border-radius: 9px; font-weight: 650; }
@media (max-width: 760px) {
  .sync-status { font-size: 11px; gap: 5px; white-space: normal; }
  .header { flex-wrap: wrap; }
  .header-actions { min-width: 0; }
  .connection-info { margin-top: 12px; }
  .intro { margin-top: 15px; }
  .editor-pane .editor-body { display: none; }
  .editor-pane.mobile-editor-open .editor-body { display: flex; }
  .editor-pane .pane-head { min-height: 60px; }
  .editor-pane .text-button { display: none; }
  .editor-pane.mobile-editor-open .text-button { display: block; }
  .mobile-actions { display: block; margin-top: 12px; }
  .mobile-actions button { width: 100%; }
  .email-row { min-height: 55px; gap: 8px; padding: 9px 9px 9px 11px; }
  .email-name { font-size: 14px; -webkit-user-select: text; user-select: text; }
  .copy-button { font-size: 13px; padding: 10px 14px; min-height: 41px; touch-action: manipulation; }
  .toast { white-space: normal; width: max-content; line-height: 1.5; }
}


/* v3.6 – Compact iPhone layout: one-line title and 10 email rows in view. */
@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .wrap { padding: 10px 10px 22px; }
  .header { gap: 5px; flex-wrap: nowrap; padding: 0 0 9px; }
  .brand { font-size: 16px; letter-spacing: -.45px; gap: 6px; flex-shrink: 0; }
  .brand-icon { width: 27px; height: 27px; border-radius: 7px; font-size: 16px; }
  .header-actions { gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; }
  .sync-status { font-size: 10px; gap: 4px; min-width: 0; white-space: nowrap; }
  .status-dot { width: 7px; height: 7px; flex: 0 0 auto; }
  .header .link-button { font-size: 11px; font-weight: 650; padding: 7px 8px; white-space: nowrap; border-radius: 8px; }
  .connection-info { margin-top: 7px; gap: 5px; }
  .room-pill { padding: 5px 8px; font-size: 11px; border-radius: 6px; }
  .intro { margin: 9px 0 11px; }
  .intro-art {
    display: block;
    width: 100%;
    max-width: 100%;
    font-size: clamp(15px, 4.85vw, 21px);
    letter-spacing: -.2px;
    font-weight: 800;
    line-height: 1.4;
    white-space: nowrap;
    text-overflow: clip;
    text-align: center;
    transform: rotate(-1deg) skewX(-3deg);
  }
  .panes { gap: 10px; }
  .pane { border-radius: 12px; }
  .copy-pane .pane-head { padding: 9px 10px; min-height: 52px; gap: 7px; }
  .copy-pane .pane-title { gap: 8px; }
  .copy-pane .step { width: 29px; height: 29px; border-radius: 7px; font-size: 11px; }
  .copy-pane h2 { font-size: 14px; margin: 0; }
  .copy-pane .pane-head p { display: none; }
  .copy-pane .count-pill { font-size: 11px; padding: 4px 8px; }
  .copy-pane .email-list {
    --mail-row-height: 46px;
    height: 462px; /* 10 rows x 46px plus outer border */
    max-height: calc(100dvh - 175px);
    min-height: 0;
    margin: 0 8px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 8px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .copy-pane .email-row {
    height: var(--mail-row-height);
    min-height: var(--mail-row-height);
    max-height: var(--mail-row-height);
    padding: 2px 7px 2px 9px;
    gap: 5px;
  }
  .copy-pane .email-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: normal;
  }
  .copy-pane .copy-button {
    min-width: 86px;
    width: 86px;
    min-height: 36px;
    height: 41px;
    max-height: 41px;
    font-size: 12px;
    line-height: 1;
    padding: 0 7px;
    border-radius: 7px;
  }
  .copy-pane .pane-footer { display: none; }
  .editor-pane .pane-head { padding: 10px; }
  .mobile-actions { margin-top: 8px; }
  .mobile-actions .link-button { padding: 8px 10px; }
  footer { margin-top: 10px; font-size: 10px; }
}
@media (max-width: 360px) {
  .brand { font-size: 14px; }
  .header .link-button { padding: 6px; font-size: 10px; }
  .sync-status { font-size: 0; }
  .intro-art { font-size: 4.45vw; letter-spacing: -.8px; }
  .copy-pane .email-name { font-size: 12px; }
  .copy-pane .copy-button { min-width: 80px; width: 80px; }
}

/* v3.9 – lightweight feature tabs and per-room notes. */
.feature-tabs { display:flex; align-items:flex-end; gap:7px; margin:17px 0 0; padding:0; border-bottom:1px solid #e2e8f0; }
.feature-tab { appearance:none; display:inline-flex; align-items:center; justify-content:center; min-height:43px; padding:11px 19px; border:1px solid #e2e8f0; border-bottom:0; border-radius:12px 12px 0 0; background:#edf2fa; color:#526078; font-weight:750; font-size:14px; cursor:pointer; }
.feature-tab:hover { background:#e9eefa; color:#1e40af; }
.feature-tab.active { position:relative; top:1px; background:white; color:#1d4ed8; border-color:#d9e2ef; box-shadow:0 -2px 9px rgba(30,64,175,.035); }
.feature-tab:focus-visible { outline:3px solid #93c5fd; outline-offset:2px; }
.feature-panel { min-width:0; }
.note-card { margin-top:20px; padding:20px; border:1px solid #e2e8f0; background:white; border-radius:15px; box-shadow:0 3px 16px rgba(15,23,42,.025); }
.note-head { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:15px; }
.note-heading { display:flex; align-items:center; gap:11px; }
.note-symbol { display:grid; place-items:center; width:40px; height:40px; font-size:22px; border-radius:12px; background:#fff0fa; }
.note-heading h2 { margin:0 0 4px; font-size:18px; }
.note-heading p { margin:0; color:#94a3b8; font-size:12px; }
.note-actions { display:flex; gap:7px; flex-wrap:wrap; }
.note-action-button { border:1px solid #d9e2ee; background:#f8fafc; color:#334155; border-radius:9px; padding:9px 12px; font-size:12px; font-weight:700; }
.note-action-button:disabled { opacity:.5; cursor:not-allowed; }
.note-action-button:hover:not(:disabled) { background:#eff6ff; }
.note-clear { color:#a43e54; }
#note-text { display:block; width:100%; min-height:420px; padding:19px; background:#fbfdff; border:1px solid #dfe7f1; border-radius:11px; outline:none; resize:vertical; font-size:16px; line-height:1.7; color:#263449; white-space:pre-wrap; }
#note-text:focus { border-color:#b79aff; box-shadow:0 0 0 3px rgba(168,85,247,.08); }
#note-text:disabled { opacity:.7; cursor:wait; }
#note-text::placeholder { color:#9baabd; }
.note-footer { display:flex; justify-content:space-between; gap:10px; margin-top:11px; font-size:12px; color:#94a3b8; }
.note-save-state { color:#15803d; }
.note-save-state.pending { color:#9a6700; }
.note-save-state.error { color:#b42318; }
.note-error, .note-conflict { margin-top:13px; padding:13px; font-size:13px; border:1px solid #fecaca; background:#fff7f7; border-radius:10px; color:#9f1239; line-height:1.5; }
.note-conflict p { margin:5px 0 10px; }
.note-conflict-actions { display:flex; flex-wrap:wrap; gap:8px; }
.note-conflict-actions button { border:1px solid #d9e2ee; background:white; border-radius:8px; padding:9px 12px; font-size:12px; font-weight:700; }
body.note-mode .sync-status, body.note-mode #status-detail, body.note-mode #retry { display:none; }
@media (max-width:760px) {
  .feature-tabs { margin:8px 0 0; gap:5px; }
  .feature-tab { flex:1; min-height:36px; padding:8px 10px; font-size:13px; border-radius:9px 9px 0 0; }
  .note-card { padding:12px; margin-top:10px; border-radius:12px; }
  .note-head { gap:10px; margin-bottom:11px; }
  .note-heading { gap:8px; }
  .note-heading h2 { font-size:15px; }
  .note-heading p { font-size:11px; }
  .note-symbol { width:32px; height:32px; font-size:19px; }
  .note-actions { width:100%; }
  .note-action-button { flex:1; }
  #note-text { min-height:55dvh; font-size:16px; padding:13px; }
  .copy-pane .email-list { max-height:calc(100dvh - 214px); }
}

/* v3.10 – nút Paste một chạm, tự tạo dòng mới trong Ghi chú. */
.note-paste-primary { background:#ecfdf5; border-color:#a7f3d0; color:#047857; font-weight:800; }
.note-paste-primary:hover:not(:disabled) { background:#d1fae5; border-color:#6ee7b7; }
.note-paste-help { margin:0 0 12px; padding:10px 12px; border:1px solid #bfe3d3; background:#f0fdf7; border-radius:10px; font-size:12px; color:#355349; line-height:1.45; }
.note-paste-help label { display:block; margin-bottom:7px; }
#note-paste-input { width:100%; height:44px; min-height:44px; border:1px solid #8dd4b3; border-radius:8px; padding:10px 12px; background:white; font-size:16px; line-height:22px; resize:none; }
#note-paste-input:focus { outline:2px solid #5abf95; outline-offset:1px; }
@media (max-width:760px) {
  .note-paste-primary { flex:1 0 100%; min-height:45px; font-size:15px; }
  .note-actions .note-action-button:not(.note-paste-primary) { flex:1; }
  .note-paste-help { padding:10px; }
}
