:root {
  --orange:     #E8621A;
  --orange-lt:  #F47B38;
  --navy:       #0F1F3D;
  --cream:      #FDF6EE;
  --cream-dark: #F5E9D8;
  --white:      #FFFFFF;
  --text:       #1A1A1A;
  --text-mid:   #4A4A4A;
  --text-lt:    #7A7A7A;
  --success:    #2E7D32;
  --warning:    #E65100;
  --error:      #C62828;
  --radius:     10px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
  background: var(--navy);
  padding: 14px 24px;
}
.header-inner {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--orange);
}
.logo-sub {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
}

/* ---- Top tabs ---- */
.tab-nav {
  display: flex;
  background: var(--navy);
  border-bottom: 2px solid var(--orange);
  padding: 0 24px;
}
.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  padding: 12px 20px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--white); }
.tab-btn.active { color: var(--white); border-bottom-color: var(--orange); }

/* ---- Tab panels ---- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.hidden { display: none !important; }

/* ---- Generate layout ---- */
.generate-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 110px);
}

/* Left panel */
.left-panel {
  width: 35%;
  min-width: 280px;
  background: var(--white);
  border-right: 1px solid var(--cream-dark);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-mid);
}
.optional { color: var(--text-lt); font-weight: 400; }

input[type="text"],
textarea {
  border: 1.5px solid #e0d8ce;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--cream);
  resize: vertical;
  transition: border-color 0.15s;
  width: 100%;
}
input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--orange);
  background: var(--white);
}

/* Chips */
.chips-section { margin-top: 4px; }
.chips-label {
  font-size: 0.82rem;
  color: var(--text-lt);
  margin-bottom: 8px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--cream-dark);
  border: 1.5px solid #e0d8ce;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
}

/* Right panel */
.right-panel {
  flex: 1;
  padding: 28px 28px;
  display: flex;
  flex-direction: column;
}

/* Output states */
.output-empty, .output-loading, .output-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  color: var(--text-lt);
  text-align: center;
  padding: 60px 20px;
}
.output-error { color: var(--error); }

/* Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--cream-dark);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Buttons ---- */
.btn-primary {
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 13px 22px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
.btn-primary:hover { background: var(--orange-lt); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 1.5px solid #d0c8be;
  border-radius: var(--radius);
  padding: 11px 20px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }

.btn-success {
  background: var(--success);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 11px 22px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-success:hover { opacity: 0.85; }

/* Copy button feedback */
.copy-btn.copied { background: var(--success) !important; }

/* ---- Inner tabs ---- */
.inner-tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--cream-dark);
  padding-bottom: 0;
}
.inner-tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-lt);
  padding: 8px 18px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.inner-tab-btn:hover { color: var(--text); }
.inner-tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }

.inner-tab-panel { display: none; }
.inner-tab-panel.active { display: block; }

/* ---- Tweet cards ---- */
#tweets-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.tweet-card {
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius);
  padding: 14px;
}
.tweet-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tweet-num {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-lt);
}
.tweet-copy-link {
  font-size: 0.8rem;
  color: var(--orange);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
}
.tweet-copy-link:hover { text-decoration: underline; }
.tweet-card textarea {
  border: 1px solid #e8e0d6;
  border-radius: 6px;
  padding: 8px;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 72px;
  background: var(--cream);
}
.char-counter {
  text-align: right;
  font-size: 0.78rem;
  margin-top: 5px;
  font-weight: 500;
}
.char-counter.green { color: var(--success); }
.char-counter.orange { color: var(--warning); }
.char-counter.red { color: var(--error); }

/* ---- Slides grid ---- */
.slides-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.slide-card {
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius);
  padding: 14px;
}
.slide-num {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-lt);
  margin-bottom: 8px;
}
.slide-card label {
  font-size: 0.78rem;
  color: var(--text-mid);
  font-weight: 500;
  margin-top: 8px;
  display: block;
}
.slide-card input[type="text"] {
  font-size: 0.88rem;
  padding: 7px 10px;
}
.slide-card textarea {
  font-size: 0.88rem;
  padding: 7px 10px;
  min-height: 60px;
}

/* Caption & hashtags */
.caption-section {
  margin-bottom: 16px;
}
.caption-section label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-mid);
  display: block;
  margin-bottom: 6px;
}
#caption-text {
  width: 100%;
  font-size: 0.9rem;
  min-height: 90px;
}

.hashtags-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.hashtag-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.hashtag-group-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-lt);
  width: 44px;
  flex-shrink: 0;
  padding-top: 6px;
}
.hashtag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.hashtag-chip {
  background: var(--navy);
  color: var(--white);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hashtag-chip .remove-chip {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}
.hashtag-chip .remove-chip:hover { color: var(--white); }

.ig-actions {
  display: flex;
  gap: 12px;
}
.ig-actions .btn-primary { width: auto; }

/* ---- Image tab ---- */
#image-container {
  margin-bottom: 16px;
}

/* 6-image grid */
.img-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}
.img-grid-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.img-grid-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-lt);
  align-self: flex-start;
}
.img-grid-item img {
  width: 100%;
  border-radius: 8px;
  border: 1.5px solid var(--cream-dark);
  display: block;
}
.btn-dl-img {
  font-size: 0.78rem;
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
  align-self: flex-start;
}
.btn-dl-img:hover { text-decoration: underline; }
.img-grid-placeholder {
  background: var(--cream-dark);
  border-radius: 8px;
  padding: 24px 8px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-lt);
  border: 1.5px dashed #c0b8ae;
}

/* Slide thumbnails inside slide cards */
.slide-thumb {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slide-thumb img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--cream-dark);
}
.slide-dl-link {
  font-size: 0.75rem;
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
}
.slide-dl-link:hover { text-decoration: underline; }

.image-placeholder {
  background: var(--cream-dark);
  border: 2px dashed #c0b8ae;
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-lt);
  font-size: 0.9rem;
  max-width: 480px;
}

.image-prompt-section {
  margin-bottom: 14px;
}
.image-prompt-section label {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-mid);
  display: block;
  margin-bottom: 6px;
}
#image-prompt-text {
  width: 100%;
  font-size: 0.85rem;
  min-height: 80px;
}

.image-actions {
  display: flex;
  gap: 12px;
}
.image-actions .btn-primary { width: auto; }

/* ---- Mark as posted bar ---- */
.mark-posted-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius);
  gap: 16px;
}
.posted-checks {
  display: flex;
  gap: 20px;
}
.posted-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.posted-checks input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--success);
  cursor: pointer;
}

/* Flash message */
.flash {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 1000;
  animation: slideUp 0.2s ease;
}
.flash.success { background: var(--success); }
.flash.error { background: var(--error); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- History ---- */
.history-wrap {
  padding: 28px 32px;
}
.history-wrap h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: var(--navy);
}
.history-empty {
  color: var(--text-lt);
  padding: 40px 0;
  text-align: center;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.history-table th {
  background: var(--navy);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 12px 16px;
  text-align: left;
}
.history-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--cream-dark);
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr.expanded-row td { padding: 0; }

.badge {
  display: inline-block;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 500;
}
.badge-pending { background: #FFF3E0; color: var(--warning); }
.badge-posted  { background: #E8F5E9; color: var(--success); }

.history-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border: 1.5px solid #d0c8be;
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.15s;
}
.btn-sm:hover { border-color: var(--orange); color: var(--orange); }
.btn-sm-orange {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
}
.btn-sm-orange:hover { background: var(--orange-lt); border-color: var(--orange-lt); color: var(--white); }

.expanded-content {
  background: var(--cream);
  padding: 16px 20px;
  border-top: 1px solid var(--cream-dark);
  font-size: 0.85rem;
}
.expanded-content strong { color: var(--navy); display: block; margin-top: 10px; margin-bottom: 4px; }
.expanded-content p { color: var(--text-mid); line-height: 1.5; }

/* ---- How To Post ---- */
.howtopost-wrap {
  padding: 28px 32px;
  max-width: 700px;
}
.howtopost-wrap h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  margin-bottom: 28px;
  color: var(--navy);
}
.howto-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  border: 1.5px solid var(--cream-dark);
}
.howto-section h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
  margin-bottom: 14px;
}
.howto-section ol, .howto-section ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.howto-section li {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-mid);
}
.howto-section ul { margin-top: 6px; }
.howto-section code {
  background: var(--cream-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--navy);
}

/* ---- Login overlay ---- */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}
#login-overlay.hidden { display: none; }

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 44px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  color: var(--orange);
}
.login-sub {
  font-size: 0.88rem;
  color: var(--text-lt);
  margin-bottom: 24px;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid #dadce0;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-google:hover {
  background: #f8f8f8;
  border-color: #bbb;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
.login-error {
  color: var(--error);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 12px;
}

/* ---- User email in header ---- */
.user-email {
  margin-left: auto;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ---- Logout button ---- */
.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: rgba(255,255,255,0.65);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-logout:hover { border-color: rgba(255,255,255,0.7); color: var(--white); }

/* ---- Mobile responsive ---- */
@media (max-width: 700px) {
  .generate-layout {
    flex-direction: column;
    min-height: unset;
  }
  .left-panel {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--cream-dark);
    padding: 20px 16px;
  }
  .right-panel {
    padding: 20px 16px;
  }
  .slides-grid {
    grid-template-columns: 1fr;
  }
  .img-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mark-posted-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .posted-checks {
    flex-direction: column;
    gap: 10px;
  }
  .mark-posted-bar .btn-success {
    width: 100%;
  }
  .ig-actions {
    flex-direction: column;
  }
  .ig-actions .btn-primary,
  .ig-actions .btn-secondary {
    width: 100%;
  }
  .image-actions {
    flex-direction: column;
  }
  .image-actions .btn-primary,
  .image-actions .btn-secondary {
    width: 100%;
  }
  .tab-nav {
    padding: 0 8px;
  }
  .tab-btn {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  .history-wrap {
    padding: 20px 16px;
  }
  .history-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .howtopost-wrap {
    padding: 20px 16px;
  }
  .login-card {
    padding: 36px 24px;
  }
}

/* Video tab */
.video-hint {
  font-size: 0.85rem;
  color: var(--text-mid);
  margin-bottom: 16px;
  line-height: 1.5;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
#inner-video {
  padding: 20px 0;
  text-align: center;
}
#inner-video .btn-primary,
#inner-video .btn-secondary {
  width: auto;
}

/* Slide card generation */
.card-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--cream-dark);
}
.cards-hint {
  font-size: 0.82rem;
  color: var(--text-lt);
  margin-bottom: 12px;
  line-height: 1.5;
}
.card-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.card-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.card-item img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  display: block;
  object-fit: cover;
}
.btn-dl-card {
  font-size: 0.78rem;
  color: var(--navy);
  text-decoration: none;
  font-weight: 500;
  text-align: center;
  padding: 2px 0;
}
.btn-dl-card:hover { text-decoration: underline; }
.card-placeholder {
  background: var(--cream-dark);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-lt);
}
.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Google Drive button */
.btn-drive {
  background: var(--white);
  color: #1a73e8;
  border: 1.5px solid #1a73e8;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-drive:hover:not(:disabled) { background: #e8f0fe; }
.btn-drive:disabled { opacity: 0.6; cursor: default; }
.btn-drive.drive-saved {
  color: var(--success);
  border-color: var(--success);
  background: #e6f4ea;
}

/* Voiceover script textarea */
.vo-script-section {
  text-align: left;
  margin-bottom: 18px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.vo-script-section label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.vo-script-section textarea {
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.55;
  padding: 10px 12px;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius);
  resize: vertical;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--white);
}
.vo-script-section textarea:focus {
  outline: none;
  border-color: var(--orange);
}

/* ---- Medium tab ---- */
.medium-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 8px;
}
.medium-section .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.medium-section label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.medium-section input[type="text"],
.medium-section textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.93rem;
  color: var(--text);
  background: var(--white);
  resize: vertical;
}
.medium-section input[type="text"]:focus,
.medium-section textarea:focus {
  outline: none;
  border-color: var(--orange);
}

/* ---- AI Agent floating widget ---- */
#ai-agent {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 997;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.ai-toggle-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--navy);
  border: 2.5px solid var(--orange);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
  transition: transform 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ai-toggle-btn:hover {
  background: var(--orange);
  color: var(--white);
  transform: scale(1.08);
}

.ai-panel {
  width: 340px;
  height: 460px;
  background: var(--white);
  border-radius: 14px;
  border: 1.5px solid var(--cream-dark);
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aiSlideUp 0.2s ease;
}
.ai-panel.hidden { display: none; }

@keyframes aiSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  padding: 12px 16px;
  flex-shrink: 0;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--white);
}
.ai-panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 0 2px rgba(76,175,80,0.3);
}
.ai-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.ai-close-btn:hover { color: var(--white); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
}

.ai-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 0.87rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.user {
  background: var(--orange);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.ai-msg.ai {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--cream-dark);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.ai-msg.loading {
  color: var(--text-lt);
  font-style: italic;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--cream-dark);
  background: var(--white);
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  border: 1.5px solid var(--cream-dark);
  border-radius: 20px;
  padding: 8px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--cream);
  outline: none;
  transition: border-color 0.15s;
}
.ai-input:focus { border-color: var(--orange); background: var(--white); }

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--orange);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  flex-shrink: 0;
  transition: background 0.15s;
}
.ai-send-btn:hover { background: var(--orange-lt); }
.ai-send-btn:disabled { background: #ccc; cursor: not-allowed; }

@media (max-width: 700px) {
  .ai-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    height: min(460px, calc(100dvh - 120px));
  }
  .ai-input { font-size: 1rem; }
}