:root {
  --bg: #14151A;
  --panel: #1B1D23;
  --border: #2A2D36;
  --text: #EDEEF2;
  --text-muted: #8B8F9C;
  --accent: #FFB648;
  --accent-ink: #201400;
  --sent-bubble: #0B84FF;
  --received-bubble: #2E2F35;
  --radius-phone: 46px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px 40px;
}

/* Hero */

.hero {
  max-width: 640px;
  margin-bottom: 48px;
}

.wordmark {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  margin: 0 0 20px;
}

.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.15;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.hero .lede {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 52ch;
  margin: 0;
}

/* Workspace layout */

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 48px;
  align-items: start;
}

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

/* Controls panel */

.controls {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  background: var(--panel);
}

.field-group {
  margin-bottom: 18px;
}

.field-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-group input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 6px 2px;
  outline: none;
  transition: border-color 0.15s ease;
}

.field-group input:focus {
  border-bottom-color: var(--accent);
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-row .field-group {
  flex: 1;
}

.field-row .field-group.narrow {
  flex: 0 0 72px;
}

.messages-editor {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.messages-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.messages-editor-head label {
  font-size: 13px;
  color: var(--text-muted);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.message-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sender-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.sender-toggle button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}

.sender-toggle button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.remove-btn:hover {
  color: var(--text);
}

.message-row textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 36px;
}

.disclaimer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Preview */

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.phone {
  width: 320px;
  height: 660px;
  background: #000;
  border-radius: var(--radius-phone);
  border: 8px solid #000;
  box-shadow: 0 0 0 1.5px #3a3b40, 0 30px 60px -20px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  transition: box-shadow 0.3s ease;
}

.phone.flash {
  box-shadow: 0 0 0 1.5px var(--accent), 0 30px 60px -20px rgba(0,0,0,0.6);
}

.notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 22px;
  background: #000;
  border-radius: 0 0 16px 16px;
  z-index: 5;
}

.statusbar {
  height: 44px;
  flex: 0 0 44px;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 600;
}

.statusbar-icons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.carrier-label {
  font-size: 11px;
  font-weight: 500;
  color: #6b6b70;
  margin: 0 2px;
}

.battery-shell {
  width: 22px;
  height: 11px;
  border: 1px solid #000;
  border-radius: 3px;
  position: relative;
  display: inline-block;
  opacity: 0.9;
}

.battery-shell::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 3px;
  width: 2px;
  height: 5px;
  background: #000;
  border-radius: 0 1px 1px 0;
}

.battery-fill {
  display: block;
  height: 100%;
  background: #000;
  border-radius: 1px;
}

.chatbar {
  flex: 0 0 52px;
  background: #f7f7f8;
  border-bottom: 1px solid #e2e2e5;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 6px;
}

.chatbar-back {
  color: #0B84FF;
  font-size: 24px;
  width: 20px;
}

.chatbar-contact {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #9a9ba3;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.contact-name {
  font-size: 11px;
  color: #6b6b70;
  font-weight: 500;
}

.chatbar-spacer {
  width: 20px;
}

.thread {
  flex: 1;
  background: #fff;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bubble {
  max-width: 74%;
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.3;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble.sent {
  align-self: flex-end;
  background: var(--sent-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.received {
  align-self: flex-start;
  background: var(--received-bubble);
  color: #000;
  background: #E9E9EB;
  border-bottom-left-radius: 4px;
}

.inputbar {
  flex: 0 0 46px;
  background: #fff;
  border-top: 1px solid #e2e2e5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.inputbar-plus {
  color: #9a9ba3;
  font-size: 20px;
}

.inputbar-field {
  flex: 1;
  border: 1px solid #d8d8dc;
  border-radius: 14px;
  padding: 6px 12px;
  color: #b5b5ba;
  font-size: 14px;
}

.inputbar-mic {
  font-size: 14px;
  opacity: 0.6;
}

.preview-actions {
  text-align: center;
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 28px;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:focus-visible,
.ghost-btn:focus-visible,
.field-group input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 10px 0 0;
}

.footer {
  margin-top: 64px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .phone, .primary-btn { transition: none; }
}
