@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --ink: #1b1d1f;
  --muted: #6b6f73;
  --panel: #f4efe6;
  --panel-strong: #fffaf3;
  --accent: #2fbf9a;
  --accent-dark: #179476;
  --bubble-blue: #0a84ff;
  --bubble-gray: #e5e5ea;
  --surface: #ffffff;
  --border: #ded7cc;
  --shadow: rgba(15, 18, 22, 0.18);
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

.preview-editable {
  cursor: text;
}

.preview-editing {
  outline: 2px dashed rgba(47, 191, 154, 0.4);
  outline-offset: 2px;
  background: rgba(47, 191, 154, 0.08);
  border-radius: 6px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f9f1e7 0%, #e6f2ec 45%, #f7e5d2 100%);
  padding: 48px 24px 72px;
  position: relative;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: -20% 0 0 0;
  background: radial-gradient(circle at 20% 10%, rgba(47, 191, 154, 0.25), transparent 45%),
              radial-gradient(circle at 80% 0%, rgba(255, 159, 28, 0.25), transparent 40%),
              radial-gradient(circle at 50% 60%, rgba(30, 138, 255, 0.2), transparent 55%);
  z-index: 0;
  pointer-events: none;
}

.page-header {
  max-width: 1180px;
  margin: 0 auto 32px;
  position: relative;
  z-index: 1;
}

.title-stack {
  display: grid;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 12px;
  margin: 0;
  color: var(--muted);
}

h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(32px, 5vw, 52px);
  margin: 0;
}

.subtitle {
  font-size: 16px;
  margin: 0;
  color: var(--muted);
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 36px;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border-radius: 28px;
  padding: 24px;
  display: grid;
  gap: 20px;
  box-shadow: 0 20px 60px rgba(26, 24, 20, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.panel-block {
  background: var(--panel-strong);
  padding: 20px;
  border-radius: 20px;
  display: grid;
  gap: 16px;
  border: 1px solid var(--border);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Space Grotesk', sans-serif;
  background: #fff;
  color: var(--ink);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 191, 154, 0.2);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(23, 148, 118, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(23, 148, 118, 0.3);
}

.message-list {
  display: grid;
  gap: 16px;
}

.message-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.message-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.message-title {
  font-weight: 600;
}

.message-actions {
  display: flex;
  gap: 8px;
}

.message-actions button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.message-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.preview {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.email-preview {
  width: min(440px, 92vw);
}

.email-shell {
  width: 100%;
  background: #f5f6f8;
  border-radius: 28px;
  border: 1px solid #e2e5ea;
  box-shadow: 0 26px 70px rgba(15, 18, 22, 0.16);
  overflow: hidden;
}

.email-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #edf0f4;
  border-bottom: 1px solid #e1e4e8;
}

.email-close {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid #d6d9de;
  background: #fff;
  font-size: 16px;
  cursor: pointer;
  color: #2b2f33;
  display: grid;
  place-items: center;
}

.email-subject {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #1f2327;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-card {
  background: #fff;
  margin: 16px;
  border-radius: 22px;
  padding: 18px;
  border: 1px solid #e6e7ea;
  box-shadow: 0 18px 40px rgba(18, 24, 33, 0.1);
  display: grid;
  gap: 12px;
}

.email-sender {
  display: flex;
  gap: 12px;
  align-items: center;
}

.email-from {
  font-weight: 600;
  font-size: 14px;
  color: #1f2327;
}

.email-to {
  font-size: 12px;
  color: #7a8087;
}

.email-rule {
  height: 1px;
  background: #edf0f2;
  width: 100%;
}

.email-notice {
  font-size: 12px;
  color: #7f858c;
  text-align: center;
  background: #f7f8fa;
  border: 1px dashed #d9dce1;
  padding: 8px 10px;
  border-radius: 10px;
}

.email-thread {
  display: grid;
  gap: 12px;
}

.email-thread-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.email-thread-info {
  display: grid;
  gap: 2px;
}

.email-thread-name {
  font-weight: 600;
  font-size: 14px;
  color: #1f2327;
}

.email-thread-time {
  font-size: 12px;
  color: #8b8f94;
}

.email-message {
  display: grid;
  gap: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: #2b2f33;
}

.email-line {
  margin: 0;
}

.email-body {
  white-space: pre-wrap;
}

.email-signature {
  font-weight: 600;
}

.email-replies {
  display: grid;
  gap: 16px;
}

.email-reply {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #edf0f2;
}

.email-ticket,
.email-footer {
  font-size: 12px;
  color: #8b8f94;
}

.email-actions {
  display: flex;
  gap: 10px;
}

.email-action {
  border: 1px solid #e1e4e8;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #2b2f33;
}

.phone {
  width: min(380px, 92vw);
  aspect-ratio: 9 / 19.2;
  background: var(--surface);
  border-radius: 36px;
  border: 1px solid #e5dfd6;
  box-shadow: 0 26px 70px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.status-time {
  font-size: 13px;
  font-weight: 600;
  margin-left: 16px;
  line-height: 1;
}

.status-icons {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  color: #111;
  height: 18px;
  margin-right: 2px;
  transform: translateY(1px);
}

.status-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  position: relative;
}

.status-icon ion-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.status-icon--battery {
  width: 26px;
  height: 18px;
  align-self: flex-end;
}

.status-icon--battery ion-icon {
  width: 22px;
  height: 20px;
  transform: translateY(-1px);
}

.battery-percent {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  color: #111;
  line-height: 1;
  transform: translateY(0);
  pointer-events: none;
}

.nav-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 16px 8px;
}

.nav-center {
  position: relative;
  display: grid;
  justify-items: center;
}

.nav-btn {
  border: none;
  background: #f2f2f7;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  justify-self: end;
}

.nav-btn ion-icon {
  font-size: 16px;
}

.chevron {
  width: 8px;
  height: 8px;
  border-left: 2px solid #111;
  border-bottom: 2px solid #111;
  transform: rotate(45deg);
}

.back-pill {
  border: none;
  background: #f2f2f7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #111;
  justify-self: start;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
  margin-top: -50px;
}

.back-count {
  line-height: 1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d9e2f1, #c6cfdf);
  border: 1px solid #d0d8e5;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
}

.avatar--lg {
  width: 52px;
  height: 52px;
  justify-self: center;
  z-index: 2;
}

.avatar.avatar--sm {
  width: 36px;
  height: 36px;
}

.avatar::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.avatar::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 14px;
  border-radius: 12px 12px 6px 6px;
  background: #fff;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.contact-center {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding-bottom: 6px;
}

.contact-number {
  background: #f2f2f7;
  padding: 8px 14px 6px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #111;
  margin-top: -6px;
  position: relative;
  z-index: 1;
}

.contact-number::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid #111;
  border-bottom: 2px solid #111;
  transform: rotate(-45deg);
  opacity: 0.6;
}

.contact-label {
  font-size: 11px;
  color: #8e8e93;
  line-height: 1.2;
}

.thread {
  flex: 1;
  padding: 8px 14px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thread-meta {
  text-align: center;
  font-size: 11px;
  color: #8e8e93;
  line-height: 1.2;
}

.bubble-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-row {
  display: flex;
}

.bubble-row--me {
  justify-content: flex-end;
}

.bubble-row--them {
  justify-content: flex-start;
}

.bubble {
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.32;
  border-radius: 18px;
  max-width: 75%;
  position: relative;
  word-wrap: break-word;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
}

.bubble--me {
  background: var(--bubble-blue);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble--them {
  background: var(--bubble-gray);
  color: #000;
  border-bottom-left-radius: 6px;
}

.bubble-tail {
  position: absolute;
  bottom: -5px;
  width: 17px;
  height: 18px;
  pointer-events: none;
}

.bubble-tail-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bubble-tail--me {
  right: 0;
  color: var(--bubble-blue);
}

.bubble-tail--them {
  left: -4.28px;
  color: var(--bubble-gray);
  transform: scaleX(-1);
}

.bubble-meta {
  font-size: 11px;
  color: #8e8e93;
  margin-top: -4px;
}

.bubble-meta--me {
  text-align: right;
  padding-right: 6px;
}

.bubble-meta--them {
  text-align: left;
  padding-left: 6px;
}

.composer {
  border-top: 1px solid #efefef;
  padding: 10px 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}

.composer-plus {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f2f2f7;
  border: 1px solid #e0e0e6;
  display: grid;
  place-items: center;
  font-weight: 400;
  font-size: 20px;
  color: #000;
  line-height: 1;
}

.composer-input {
  flex: 1;
  background: #f2f2f7;
  border: 1px solid #e2e2e7;
  border-radius: 999px;
  padding: 6px 10px 6px 14px;
  font-size: 12px;
  color: #b0b4b9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composer-field {
  flex: 1;
  min-height: 18px;
  outline: none;
  color: #111;
  font-size: 12px;
  line-height: 1.3;
  white-space: pre-wrap;
}

.composer-field:empty::before {
  content: attr(data-placeholder);
  color: #b0b4b9;
}

.composer-mic {
  display: grid;
  place-items: center;
  color: #a0a0a6;
  width: auto;
  height: auto;
  border: none;
  background: transparent;
  padding-right: 2px;
}

.composer-mic ion-icon {
  font-size: 16px;
}

.bubble-text {
  display: inline;
}

.bubble-text--editing {
  outline: none;
  cursor: text;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .preview {
    order: -1;
  }
}

@media (max-width: 600px) {
  body {
    padding: 28px 16px 48px;
  }

  .panel {
    padding: 18px;
  }

  .phone {
    width: min(360px, 94vw);
  }
}
