/* ───────────────────────────────────────────────────────────────────────────
   Shelf's palette. Monochrome, so the interface never argues with a shop's own
   brand — the only colour on screen belongs to a logo. Defined once here and
   used by both the chat window and the home screen.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --ink:       #16181A;   /* near-black, faint cool bias */
  --ink-soft:  #34383C;
  --body:      #55595E;
  --faint:     #8B9095;
  --fainter:   #A8ACB1;
  --rule:      rgba(22, 24, 26, 0.11);
  --rule-soft: rgba(22, 24, 26, 0.06);
  --card:      #FFFFFF;
  --ground:    #F0F1F2;
  --wash:      #F5F6F7;
  --shadow:    rgba(22, 24, 26, 0.06);
  --good:      #1D6B4A;   /* semantic only: success states */
  --good-bg:   #EAF3EE;
  --bad:       #A4292B;
  --bad-line:  rgba(164, 41, 43, 0.28);
  --bad-bg:    #FBEFEF;
  --warn:      #7A5314;
  --warn-line: rgba(122, 83, 20, 0.30);
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--ground);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  /* Wider than 800: this is where long product copy and blog posts are read
     and approved, and the old 541px column made that harder than it needed
     to be. Still capped — full-width prose is worse, not better. */
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

header {
  padding: 18px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 16px;
  /* Stays put while the transcript scrolls: the way back to the home screen —
     and to what is worth doing next — should never be somewhere up the page. */
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-main {
  display: flex;
  flex-direction: column;
}

#reset-btn {
  padding: 6px 14px;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 12px;
  color: var(--body);
  cursor: pointer;
  white-space: nowrap;
}

#reset-btn:hover {
  border-color: var(--faint);
  color: var(--body);
}

#team-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--wash);
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

#team-banner-text {
  flex: 1;
  min-width: 0;
}

#team-link {
  color: var(--ink);
  word-break: break-all;
}

#team-copy-btn, #team-dismiss-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

#team-copy-btn {
  background: var(--ink);
  color: white;
  border: none;
}

#team-dismiss-btn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--body);
}

.logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 13px;
  color: var(--body);
  margin-top: 2px;
}

#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.assistant-avatar {
  background: var(--ink);
  color: #fff;
  letter-spacing: 0;
}

.message-content {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

/* What the merchant typed is usually one line; what Shelf produced is the
   thing being read. They should not be the same width. */
.message.user .message-content { max-width: 64%; }

.message.user .message-content {
  align-items: flex-end;
}

.message.user .bubble {
  max-width: 100%;
}

.message.assistant .bubble {
  max-width: 100%;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Reading size, for the side that does the writing. */
.message.assistant .bubble {
  font-size: 15.5px;
  line-height: 1.68;
  padding: 15px 20px;
}

.message.assistant .bubble .h2,
.message.assistant .bubble .h3 {
  display: block;
  font-weight: 700;
  color: var(--ink);
  margin: 18px 0 6px;
}
.message.assistant .bubble .h2 { font-size: 16.5px; }
.message.assistant .bubble .h3 { font-size: 15.5px; }

.message.assistant .bubble hr.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 18px 0;
}

.message.user .bubble {
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.bubble.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.bubble.thinking span {
  width: 7px;
  height: 7px;
  background: var(--fainter);
  border-radius: 50%;
  display: inline-block;
  animation: dot-pulse 1.2s infinite ease-in-out;
}

.bubble.thinking span:nth-child(2) { animation-delay: 0.2s; }
.bubble.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1;   }
}

.thinking-tip {
  font-size: 12px;
  color: var(--body);
  margin-top: 6px;
  padding-left: 4px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#input-area {
  padding: 12px 16px 16px;
  background: #fff;
  border-top: 1px solid var(--rule);
}

#input-wrapper {
  border: 1.5px solid var(--rule);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}

#input-wrapper:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(22, 24, 26, 0.10);
}

#user-input {
  width: 100%;
  padding: 14px 16px 8px;
  border: none;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  display: block;
  background: transparent;
}

#input-footer {
  display: flex;
  align-items: center;
  padding: 6px 10px 10px;
  gap: 6px;
}

#input-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

#upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--faint);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

#upload-btn:hover {
  color: var(--ink);
  background: var(--wash);
}

#send-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#send-btn:hover {
  background: var(--ink-soft);
}

#send-btn:disabled {
  /* Keep the glyph readable: dimming the real colour beats swapping in a
     near-white fill, which made the button a blank square for the whole of
     every reply. */
  background: var(--ink);
  opacity: 0.32;
  cursor: not-allowed;
}

/* Suggestion chips */
#suggestions {
  padding: 0 0 24px;
}

.welcome-intro {
  text-align: center;
  padding: 20px 32px 4px;
  color: var(--body);
  font-size: 15px;
  line-height: 1.6;
}

.suggestions-label {
  font-size: 12px;
  color: var(--body);
  margin-bottom: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.suggestion-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.suggestion-chip:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Content chips — blue */

/* eBay chip — amber */

/* SEO chip — green */

/* Sales chip — teal */

/* Marketing chip — rose */

/* Blog chip — purple */

.chip-icon {
  font-size: 16px;
  line-height: 1;
  margin-bottom: 2px;
}

.chip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.chip-sub {
  font-size: 11px;
  color: var(--body);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .suggestions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Custom shortcut slot */
#custom-shortcut {
  position: relative;
}

.custom-add-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  width: 100%;
  height: 100%;
  background: #fff;
  border: 1px dashed var(--rule);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}

.custom-add-btn:hover {
  border-color: var(--faint);
}

.custom-add-icon {
  font-size: 16px;
  font-weight: 300;
  color: var(--fainter);
  line-height: 1;
  margin-bottom: 2px;
}

/* When shortcut is set — looks like a normal chip with an edit button */
.custom-shortcut-set .custom-add-btn {
  border-style: solid;
  border-color: var(--rule);
  padding-right: 36px; /* room for edit icon */
}

.custom-shortcut-set .custom-add-icon {
  display: none;
}

.custom-edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fainter);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.custom-edit-btn:hover {
  color: var(--body);
  background: var(--wash);
}

/* Inline form */
.custom-form {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-form.hidden {
  display: none;
}

.custom-form input {
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.custom-form input:focus {
  border-color: var(--ink);
}

.custom-form-actions {
  display: flex;
  gap: 6px;
}

.custom-form-actions button {
  flex: 1;
  padding: 6px 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

#custom-save-btn {
  background: var(--ink);
  color: #fff;
}

#custom-cancel-btn {
  background: none;
  border: 1px solid var(--rule) !important;
  color: var(--body);
}

/* Download button in chat */
.download-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--ink);
  color: #fff !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
}

.download-btn:hover {
  background: var(--ink-soft);
}

/* Pending draft notice — appears at session load when a saved draft exists */
.pending-draft-notice {
  background: #fffbeb;
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-draft-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--warn);
}

.pending-draft-sub {
  font-size: 13px;
  color: var(--warn);
}

.pending-draft-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Publish / Discard confirm bar — appears below AI bubble when changes are pending */
.confirm-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-left: 0;
}

.confirm-publish-btn,
.confirm-discard-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

.confirm-publish-btn {
  background: var(--good);
  color: #fff;
}

.confirm-publish-btn:hover {
  background: var(--good);
  transform: translateY(-1px);
}

.confirm-discard-btn {
  background: var(--wash);
  color: var(--body);
  border: 1px solid var(--rule);
}

.confirm-discard-btn:hover {
  background: var(--rule);
}

/* Prompt library */
.prompt-library {
  background: #fff;
  border-top: 1px solid var(--rule);
  max-height: 320px;
  overflow-y: auto;
  transition: max-height 0.2s ease, opacity 0.2s ease;
  opacity: 1;
}

.prompt-library.hidden {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  border-top: none;
}

.prompt-library-inner {
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prompt-category-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--body);
  margin-bottom: 6px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-chip {
  background: var(--wash);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--body);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.prompt-chip:hover {
  background: var(--wash);
  border-color: var(--rule);
  color: var(--ink);
}

#price-template-btn {
  padding: 0 10px;
  height: 28px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--body);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s;
}

#price-template-btn:hover {
  background: var(--wash);
}

#prompt-library-btn {
  padding: 0 10px;
  height: 28px;
  background: var(--wash);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--body);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

#prompt-library-btn:hover {
  background: var(--rule);
  color: var(--ink);
}

#prompt-library-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ── Voice profile banner ── */
#voice-banner {
  background: var(--good-bg);
  border-bottom: 1px solid var(--good-line);
  padding: 7px 16px;
  font-size: 12px;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-dot {
  width: 7px;
  height: 7px;
  background: var(--good);
  border-radius: 50%;
  flex-shrink: 0;
}

#voice-tone-text {
  flex: 1;
  color: var(--good);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.voice-btn {
  background: none;
  border: 1px solid var(--good);
  border-radius: 5px;
  padding: 2px 9px;
  font-size: 11px;
  color: var(--good);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

.voice-btn:hover {
  background: var(--card);
}

#voice-detail {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--good-line);
}

#voice-detail-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--good);
  line-height: 1.5;
}

.vd-key {
  display: inline-block;
  font-weight: 600;
  min-width: 60px;
  color: var(--good);
  margin-right: 4px;
}

.vd-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--good-line);
  color: var(--good);
  font-style: italic;
  line-height: 1.5;
}

/* One treatment for every shortcut chip. Five colours made the screen look
   like a toolbar full of unrelated things; the icon carries the difference. */
.chip-blue, .chip-amber, .chip-green, .chip-teal, .chip-purple {
  background: var(--card);
  border-color: var(--rule);
}
.chip-blue:hover, .chip-amber:hover, .chip-green:hover,
.chip-teal:hover, .chip-purple:hover {
  background: var(--wash);
  border-color: var(--ink-soft);
}
.chip-blue .chip-icon, .chip-amber .chip-icon, .chip-green .chip-icon,
.chip-teal .chip-icon, .chip-purple .chip-icon { color: var(--ink); }

/* ── Running inside Shopify's admin iframe ──────────────────────────────────
   The shell is height:100vh, which is right in its own tab: the page never
   scrolls and only the message list moves. Inside an iframe 100vh means the
   FRAME's height, so anything taller than the frame is simply unreachable —
   the screen will not go up or down. Framed, the shell becomes auto-height and
   the document scrolls normally. The class is set by chat.js. */
.framed, .framed body { height: auto; min-height: 100vh; }
.framed #app { height: auto; min-height: 100vh; }
.framed #chat-window { overflow: visible; }
.framed #messages { overflow: visible; }

/* ── Shared masthead, matching the home screen ──────────────────────────── */
.mast-home { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.mast-home .mast-mark { width: 32px; height: 28px; display: block; }
.mast-home .mast-name {
  font-size: 22px; font-weight: 800; letter-spacing: -0.035em; color: #000; line-height: 1;
}
.mast-links { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mast-links a, .mast-links #reset-btn {
  font-size: 12.5px; color: var(--body); text-decoration: none;
  padding: 7px 11px; border-radius: 8px; white-space: nowrap;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.mast-links a:hover, .mast-links #reset-btn:hover { color: var(--ink); background: var(--wash); }
.mast-links #reset-btn { border: 1px solid var(--rule); }


/* ── Inside the home screen's job panel ─────────────────────────────────────
   The panel already shows where you are and how to get back, so the chat's own
   masthead would be a duplicate of both. */
.embedded header { display: none; }
.embedded, .embedded body { height: auto; min-height: 100vh; }
.embedded #app { height: auto; min-height: 100vh; }


/* ── Inside the job panel ───────────────────────────────────────────────────
   76px of the viewport went to a brand-voice indicator and a share-with-your-
   team invitation before any of the work was visible. Neither belongs in front
   of a job; both remain on the standalone chat page. */
.embedded #voice-banner,
.embedded #team-banner { display: none !important; }
