/* Juniper v6.4.0 - Quiet Pond Theme */

:root {
  --bg-primary: #0b2528;
  --bg-secondary: #163b3d;
  --bg-card: rgba(17, 52, 54, 0.94);
  --bg-input: rgba(0, 0, 0, 0.25);
  --accent-primary: #2d7d78;
  --accent-secondary: #b7dbc1;
  --accent-warm: #c58c56;
  --accent-success: #4d8f72;
  --accent-info: #75cbd0;
  --accent-danger: #a84434;
  --text-primary: #e8efe6;
  --text-secondary: #bfd2ce;
  --text-muted: #a9bfbb;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(117, 203, 208, 0.45);
}

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

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 50% -12%, rgba(117, 203, 208, 0.16), transparent 34%),
    linear-gradient(160deg, var(--bg-primary) 0%, #061719 100%);
  min-height: 100vh;
  padding: 10px;
  padding-bottom: 80px;
  color: var(--text-primary);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
header {
  text-align: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

header h1 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

header p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.juniper-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.version {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.card h2 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--accent-secondary);
}

/* Collapse */
.collapse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.voice-access-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  padding: 10px 12px;
  color: var(--text-secondary);
  background: rgba(117, 203, 208, 0.09);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.voice-access-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  background: var(--accent-info);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(117, 203, 208, 0.55);
}

.voice-access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: auto;
}

.voice-access-banner button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--text-primary);
  background: #245f5b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.voice-access-banner button:hover { background: #2b716c; }
.voice-access-banner button.quiet { color: var(--text-secondary); background: transparent; border-color: var(--border-color); }
.voice-access-banner button.quiet:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.07); }

@media (max-width: 390px) {
  .voice-access-banner { align-items: flex-start; flex-wrap: wrap; }
  .voice-access-actions { width: 100%; margin-left: 18px; }
}

.collapse-toggle {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
}

.collapse-header .arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.3s;
}

.collapse-toggle[aria-expanded="false"] .arrow {
  transform: rotate(-90deg);
}

.collapse-content {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s;
}

.collapse-content.collapsed {
  max-height: 0;
}

/* Inputs */
.custom-row {
  display: flex;
  gap: 8px;
}

.custom-input {
  flex: 1;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 1rem;
}

.custom-input::placeholder {
  color: var(--text-muted);
}

.custom-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.send-btn {
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--border-color);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 6px var(--accent-success);
}

.status-dot.speaking {
  background: var(--accent-info);
  animation: pulse 1s infinite;
}

.status-dot.loading {
  background: var(--accent-warm);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stop-btn {
  padding: 8px 16px;
  background: var(--accent-danger);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
}

/* Main Buttons */
.main-btn-wrapper {
  position: relative;
  margin-bottom: 8px;
}

.main-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.main-btn.intro {
  background: linear-gradient(135deg, var(--accent-primary), #4a7339);
}

.main-btn.verify {
  background: linear-gradient(135deg, var(--accent-warm), #8b6540);
}

.edit-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.3);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.6;
}

.edit-btn:hover {
  opacity: 1;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  padding: 10px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: center;
}

.tab.active {
  background: var(--bg-secondary);
  color: var(--accent-secondary);
  border-color: var(--border-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Hotkey Grid - FIXED: No more jumping on hover */
.hotkey-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hotkey-btn {
  padding: 12px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: center;
  /* FIXED: Set minimum height to prevent jumping */
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: border-color 0.2s;
}

.hotkey-btn:active {
  transform: scale(0.95);
}

.hotkey-btn.yes {
  background: rgba(107, 155, 90, 0.2);
  border-color: rgba(107, 155, 90, 0.5);
}

.hotkey-btn.no {
  background: rgba(196, 92, 74, 0.2);
  border-color: rgba(196, 92, 74, 0.5);
}

.hotkey-btn .icon {
  font-size: 1.1rem;
  display: block;
  margin-bottom: 4px;
}

.hotkey-btn .label {
  display: block;
}

.hotkey-btn .full-text {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 4px;
  /* FIXED: Always reserve space, just hide with opacity */
  opacity: 0;
  transition: opacity 0.2s;
  height: 14px;
}

@media (hover: hover) {
  .hotkey-btn:hover .full-text {
    /* FIXED: Show with opacity instead of display */
    opacity: 1;
  }
  .hotkey-btn:hover {
    border-color: var(--accent-primary);
  }
}

/* Quick Scripts */
.quick-scripts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.quick-script-btn {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-script-btn:hover {
  border-color: var(--accent-primary);
}

/* Toolbar - FIXED: Consistent button sizing */
.toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.toolbar-btn {
  padding: 10px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  /* FIXED: Consistent height */
  min-height: 52px;
  transition: border-color 0.2s, color 0.2s;
}

.toolbar-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.toolbar-btn .tb-icon {
  font-size: 1.1rem;
}

/* Scripts Grid */
.scripts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.script-card {
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.script-card-content {
  display: block;
  width: 100%;
  padding: 12px;
  padding-right: 34px;
  color: var(--text-primary);
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.script-card:hover {
  border-color: var(--accent-primary);
}

.script-card .script-icon {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.script-card .script-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.script-card .script-preview {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-card .delete-script {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: var(--accent-danger);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 0.7rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.script-card:hover .delete-script,
.script-card:focus-within .delete-script {
  display: flex;
}

.no-scripts {
  grid-column: span 2;
  text-align: center;
  padding: 25px;
  color: var(--text-muted);
}

/* History */
.history-list {
  max-height: 120px;
  overflow-y: auto;
}

.history-item {
  display: block;
  width: 100%;
  border: 0;
  text-align: left;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.empty-message {
  color: var(--text-muted);
  padding: 10px;
}

.history-item:hover {
  background: rgba(255,255,255,0.05);
}

.history-item .time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.clear-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.footer a {
  color: inherit;
  text-underline-offset: 3px;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 400px) {
  .hotkey-grid,
  .voice-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .scripts-grid {
    grid-template-columns: 1fr;
  }
  .form-row,
  .form-row.three {
    grid-template-columns: 1fr;
  }
  .toolbar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Dragonfly-on-the-pond identity and roomier touch controls. */
.container { max-width: 540px; }

header { padding: 18px 0 16px; margin-bottom: 16px; }
header h1 { font-size: 1.75rem; }
.juniper-icon {
  width: 64px;
  height: 64px;
  background: radial-gradient(circle at 50% 68%, rgba(117, 203, 208, 0.2), transparent 64%);
  border-radius: 45% 55% 50% 50%;
}
.dragonfly { width: 100%; height: 100%; overflow: visible; }
.pond-ripple { fill: none; stroke: rgba(117, 203, 208, 0.32); stroke-width: 1.2; }
.dragonfly-body { transform-origin: 36px 35px; animation: dragonfly-hover 3.8s ease-in-out infinite; }
.wing { fill: rgba(183, 219, 193, 0.24); stroke: #9dd9d5; stroke-width: 1.3; }
.dragonfly-head { fill: #d8b47b; }
.dragonfly-tail { fill: none; stroke: #d8b47b; stroke-width: 4; stroke-linecap: round; }

@keyframes dragonfly-hover {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-3px) rotate(1deg); }
}

.card { padding: 18px; margin-bottom: 14px; }
.send-btn { min-height: 52px; padding: 15px 24px; }
.stop-btn { min-height: 44px; padding: 10px 18px; }
.main-btn-wrapper { margin-bottom: 12px; }
.main-btn { min-height: 58px; padding: 16px 52px; }
.edit-btn { width: 40px; height: 40px; }
.tabs { gap: 8px; margin-bottom: 14px; }
.tab { min-height: 48px; padding: 12px 8px; }
.hotkey-grid { gap: 12px; }
.hotkey-btn { min-height: 88px; padding: 14px 8px; }
.hotkey-btn .full-text { opacity: 0.82; }
.quick-scripts { gap: 10px; }
.quick-script-btn { min-height: 44px; padding: 10px 14px; }
.toolbar { gap: 10px; margin-top: 16px; }
.toolbar-btn { min-height: 64px; padding: 12px 8px; }
.clear-btn { min-height: 44px; padding: 9px 14px; }
.collapse-toggle { min-width: 44px; min-height: 44px; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-info);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .dragonfly-body,
  .status-dot.speaking,
  .status-dot.loading { animation: none; }
}

/* Watercolor hero: artwork stays decorative so the app name remains real text. */
.hero-banner {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(183, 219, 193, 0.28);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  isolation: isolate;
}

.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% center;
  z-index: -2;
}

.hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7, 29, 31, 0.94) 0%, rgba(7, 29, 31, 0.74) 38%, rgba(7, 29, 31, 0.05) 72%);
  z-index: -1;
}

.hero-copy {
  width: 58%;
  min-height: 190px;
  padding: 22px 18px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
}

.hero-banner h1 {
  justify-content: flex-start;
  font-family: Georgia, 'Palatino Linotype', serif;
  font-size: 2.35rem;
  font-style: italic;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}
.hero-banner p { color: #e3f2ee; font-size: 0.92rem; }
.hero-banner .version { color: #c5dcd6; margin-top: 7px; }

.card h2,
.modal-header h2,
.section-title {
  font-family: Georgia, 'Palatino Linotype', serif;
  letter-spacing: 0.01em;
}

@media (max-width: 430px) {
  .hero-banner { min-height: 168px; }
  .hero-art { object-position: 64% center; }
  .hero-banner::after { background: linear-gradient(90deg, rgba(7, 29, 31, 0.95) 0%, rgba(7, 29, 31, 0.76) 48%, rgba(7, 29, 31, 0.08) 82%); }
  .hero-copy { width: 68%; min-height: 168px; padding: 18px 12px 16px 18px; }
  .hero-banner h1 { font-size: 1.9rem; }
}
