@import url("rra-tokens.css");

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  height: 100%;
}

body.rra-app,
.rra-app {
  margin: 0;
  font-family: var(--rra-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--rra-fg);
  background: var(--rra-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.rra-app {
  height: 100vh;
}

.rra-app header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rra-border);
  background: var(--rra-surface-raised);
  flex-shrink: 0;
}

.rra-app .brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.rra-app .brand .title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.rra-app .brand .subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--rra-muted);
  letter-spacing: 0.01em;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.drafts-meter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 7px;
  border: 1px solid var(--rra-border);
  border-radius: 999px;
  background: var(--rra-surface);
  cursor: default;
  font: inherit;
  line-height: 1;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  max-width: 7.5rem;
  flex-shrink: 0;
}

.drafts-meter:not(.empty):not(.loading):not(.clickable) {
  pointer-events: none;
}

.drafts-meter.clickable {
  cursor: pointer;
  pointer-events: auto;
}

.drafts-meter.clickable:hover {
  border-color: var(--rra-accent-ring);
  background: var(--rra-accent-soft);
  box-shadow: var(--rra-shadow-xs);
}

.drafts-meter:focus-visible {
  outline: 2px solid var(--rra-accent-ring);
  outline-offset: 2px;
}

.drafts-meter-balance {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.drafts-meter-count {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rra-fg);
  min-width: 1ch;
}

.drafts-meter-track {
  position: relative;
  width: 52px;
  height: 6px;
  border-radius: 999px;
  background: var(--rra-border);
  overflow: hidden;
  flex-shrink: 0;
}

.drafts-meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f48c06 0%, var(--rra-accent) 55%, #ff6b35 100%);
  box-shadow: 0 0 8px rgba(232, 93, 4, 0.35);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.drafts-meter-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(20% - 1px),
    rgba(255, 255, 255, 0.55) calc(20% - 1px),
    rgba(255, 255, 255, 0.55) 20%
  );
  pointer-events: none;
  opacity: 0.65;
}

.drafts-meter.low .drafts-meter-fill {
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.35);
}

.drafts-meter-buy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.drafts-meter-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.drafts-meter-buy-label {
  font-size: 11px;
  font-weight: 700;
  color: #9a3412;
}

.drafts-meter.empty {
  max-width: none;
  border-color: #fcd34d;
  background: #fffbeb;
  padding: 5px 10px 5px 8px;
}

.drafts-meter.empty .drafts-meter-balance {
  display: none;
}

.drafts-meter.empty .drafts-meter-buy {
  display: inline-flex;
}

.drafts-meter:not(.empty) .drafts-meter-buy {
  display: none;
}

.drafts-meter.loading .drafts-meter-fill {
  width: 40% !important;
  animation: drafts-meter-pulse 1.1s ease-in-out infinite;
}

.drafts-meter.loading .drafts-meter-count {
  opacity: 0.45;
}

@keyframes drafts-meter-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scaleX(0.85);
    transform-origin: left center;
  }

  50% {
    opacity: 1;
    transform: scaleX(1);
  }
}


.rra-app #context {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rra-border);
  background: var(--rra-surface);
  flex-shrink: 0;
}

.rra-app #mode-bar {
  display: flex;
  gap: 3px;
  margin-bottom: 10px;
  background: var(--rra-border);
  border-radius: var(--rra-radius);
  padding: 3px;
}

.mode-btn {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  background: transparent !important;
  border: none !important;
  color: #7c8593 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

.mode-btn:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  color: var(--rra-fg) !important;
}

.mode-btn.active {
  background: #ffffff !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08) !important;
  color: var(--rra-fg) !important;
  font-weight: 600 !important;
  border: none !important;
}

#goal-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

#goal-select {
  flex: 1;
  min-width: 0;
}

#load-bar {
  display: flex;
  gap: 6px;
}

#load {
  flex: 1;
  border: 1px solid var(--rra-border) !important;
  box-shadow: none !important;
}

#clear {
  white-space: nowrap;
}

.rra-app #thread-summary {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.rra-app #thread-summary.thread-loaded {
  background: var(--rra-surface-raised);
  border: 1px solid var(--rra-border);
  border-radius: var(--rra-radius-sm);
  padding: 8px 10px;
  color: var(--rra-fg);
}

.rra-app #thread-summary.readonly {
  border-left: 3px solid #9aa3b2;
  padding-left: 8px;
}

#history-list {
  margin-top: 8px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  border: 1px solid var(--rra-border);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  background: #fafafa;
}

.history-item .title {
  display: block;
  font-weight: 600;
  margin-bottom: 3px;
}

.history-item .meta {
  display: block;
  color: var(--rra-muted);
  font-size: 12px;
}

.empty-history {
  border: 1px dashed var(--rra-border);
  border-radius: 8px;
  color: var(--rra-muted);
  padding: 8px;
  font-size: 12px;
}

.onboarding-card {
  padding: 16px 14px;
  color: #a8b0bc;
  font-size: 13px;
  line-height: 1.6;
}

.onboarding-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c0c8d4;
  margin: 0 0 10px;
}

.onboarding-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding-steps li {
  padding-left: 2px;
}

.onboarding-steps strong {
  color: #8d96a4;
  font-weight: 600;
}

.muted {
  color: var(--rra-muted);
}

.hidden {
  display: none !important;
}

.warn {
  color: #c0392b;
  font-size: 12px;
}

.rra-app #chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--rra-bg);
  min-height: 0;
}

#chat.history-list-view {
  padding-top: 10px;
}

.history-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #6c7583;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}



.history-page-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.history-chat-item {
  border: 1px solid var(--rra-border);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.history-chat-item:hover {
  background: #fafafa;
}

.history-chat-item .title {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}

.history-chat-item .meta {
  display: block;
  color: var(--rra-muted);
  font-size: 12px;
}



.bubble {
  padding: 9px 11px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 92%;
}

.bubble.user {
  align-self: flex-end;
  background: var(--rra-user-bubble);
  border: 1px solid #e0e7ff;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--rra-assistant-bubble);
  border: 1px solid var(--rra-border);
}

.bubble.assistant.structured {
  width: 92%;
  max-width: 92%;
  padding: 8px;
}

.bubble.assistant.thinking {
  min-height: 42px;
}

.draft-incomplete {
  padding: 12px 14px;
  border-radius: var(--rra-radius-sm, 8px);
  border: 1px solid var(--rra-border, #e8eaef);
  background: var(--rra-surface, #f7f8fa);
}

.draft-incomplete-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 650;
  color: var(--rra-fg, #141417);
}

.draft-incomplete-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--rra-muted, #6b7280);
}

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

.thinking-label {
  font-size: 13px;
  color: #5f6a79;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8e99aa;
  animation: thinkingPulse 1s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes thinkingPulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.draft-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.draft-card {
  background: var(--rra-surface-raised);
  border: 1px solid var(--rra-border);
  border-radius: var(--rra-radius);
  padding: 10px;
  box-shadow: var(--rra-shadow-xs);
}

.draft-card.dm {
  border-left: 4px solid #2f6df6;
}

.draft-card.reply {
  border-left: 4px solid #ff6a00;
}

.draft-card.comment {
  border-left: 4px solid #0c8a58;
}

.draft-head {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}



.draft-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f0f3f8;
  color: #4d5664;
}

.draft-badge.dm {
  background: #eaf1ff;
  color: #1f4ec4;
}

.draft-badge.reply {
  background: #fff0e5;
  color: #b24a00;
}

.draft-badge.comment {
  background: #e7f7ef;
  color: #0a6f47;
}

.draft-title {
  font-weight: 600;
  font-size: 13px;
}

.draft-target {
  font-size: 12px;
  color: #0079d3;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  line-height: 1;
}

.draft-target:hover {
  color: #005fa3;
  text-decoration-style: solid;
}

/* ---- Toast notification ---- */

.rra-toast {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #1a1a1b;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 14px;
  border-radius: 8px;
  max-width: 280px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 9999;
}

.rra-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.draft-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
}

.draft-preview {
  font-size: 12px;
  color: #5f6a79;
}

.draft-content {
  margin-top: 8px;
}

.draft-card.collapsed .draft-content {
  display: none;
}

.draft-card:not(.collapsed) .draft-preview {
  display: none;
}

.draft-rationale {
  margin: 8px 0 0;
  font-size: 12px;
  color: #657183;
}

.draft-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}



.draft-remainder,
.draft-pending {
  font-size: 12px;
}

.copy-host {
  position: relative;
}

.copy-snippet {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 1px solid #d7dce5;
  background: #ffffff;
  color: #4d5664;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0.88;
}

.copy-snippet:hover {
  opacity: 1;
  background: #f8f9fc;
}

.bubble.assistant>.copy-snippet {
  top: 8px;
  right: 8px;
}

.bubble.assistant li.copy-host,
.bubble.assistant pre.copy-host,
.bubble.assistant p.copy-host {
  padding-right: 56px;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 0 0 8px 20px;
  padding: 0;
}

.bubble li {
  margin: 2px 0;
}

.bubble blockquote {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-left: 3px solid #d4d7dd;
  background: #eef1f5;
  border-radius: 6px;
}

.bubble pre {
  margin: 0 0 8px;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: 8px;
  background: #1f2430;
  color: #e6edf3;
  white-space: pre;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.bubble :not(pre)>code {
  background: #eceff4;
  border-radius: 4px;
  padding: 1px 4px;
}

.bubble a {
  color: #1f62ff;
  text-decoration: underline;
}

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
  margin: 0 0 8px;
  line-height: 1.25;
}

.rra-app footer {
  border-top: 1px solid var(--rra-border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--rra-surface-raised);
  flex-shrink: 0;
}

#composer-options {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#composer-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

#instruction-toggle {
  flex-shrink: 0;
}

#instruction-toggle.active {
  background: #fff3ee !important;
  color: var(--color-primary) !important;
  border-style: solid !important;
  border-color: #ffc6ae !important;
}

#comment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #d8dde5;
  border-radius: 999px;
  font-size: 13px;
  color: #7c8593;
  background: #f7f8fa;
  cursor: pointer;
  user-select: none;
  transition: all 120ms ease;
  white-space: nowrap;
  flex-shrink: 0;
}

#comment-toggle input {
  margin: 0;
}

#comment-toggle.active {
  color: #8f2f00;
  border-color: #ffc6ae;
  background: #fff3ee;
}

#comment-toggle:not(.active) {
  opacity: 0.7;
}

#model-select {
  flex-shrink: 0;
  max-width: 150px;
}

#input {
  width: 100%;
  resize: vertical;
}

#generate-btn {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- Chat List: Save + Help buttons on draft cards ---- */

.draft-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  position: relative;
}

.draft-help-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #2c3340;
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  padding: 8px 11px;
  border-radius: 8px;
  max-width: 230px;
  z-index: 200;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.draft-help-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 10px;
  border: 5px solid transparent;
  border-top-color: #2c3340;
}

/* ---- Chat List: header button ---- */

#chatlist-btn.active {
  background: #fff3ee !important;
  color: var(--color-primary) !important;
}

/* ---- Chat List: warning banner ---- */

.chatlist-warning {
  background: #fff5f5;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  color: #922;
  font-size: 12px;
  padding: 8px 10px;
}

/* ---- Chat List: meta row ---- */

.chatlist-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---- Chat List: detail context card ---- */

.chatlist-context-card {
  border: 1px solid var(--rra-border);
  border-radius: 10px;
  background: #f9fafc;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

.chatlist-context-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.chatlist-orig-label {
  font-size: 11px;
  color: var(--rra-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.chatlist-original-draft {
  white-space: pre-wrap;
  font-size: 12px;
  color: #3d4a5c;
  border-left: 3px solid #dfe3ea;
  padding-left: 8px;
  margin-bottom: 8px;
}

.chatlist-thread-summary {
  font-size: 12px;
}

.chatlist-thread-summary summary {
  cursor: pointer;
  color: var(--rra-muted);
  user-select: none;
}

.chatlist-thread-summary pre {
  margin-top: 6px;
  font: inherit;
  font-size: 11px;
  white-space: pre-wrap;
  color: #3d4a5c;
  background: #f0f2f6;
  padding: 6px 8px;
  border-radius: 6px;
}

/* ---- Feedback modal ---- */

#feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

#feedback-overlay.hidden {
  display: none;
}

#feedback-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px 16px 14px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

.feedback-heading {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 4px;
}

.feedback-sub {
  font-size: 13px;
  color: var(--rra-muted);
  margin: 0 0 12px;
}

#feedback-moods {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.mood-btn.selected {
  border-color: var(--color-primary) !important;
  background: #fff3ee !important;
  color: var(--color-primary) !important;
}

#feedback-text {
  width: 100%;
  margin-bottom: 12px;
}

.feedback-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#feedback-send {
  flex: 1;
  font-weight: 600;
}

#feedback-later {
  white-space: nowrap;
}

/* ---- Refined controls (over daisyUI defaults) ---- */

.rra-app .btn {
  font-weight: 600;
  border-radius: var(--rra-radius-sm);
  min-height: 2.125rem;
  box-shadow: none;
}

.rra-app .btn:not(.btn-primary):not(.btn-ghost):not(.btn-error) {
  border: 1px solid var(--rra-border-strong);
  background: var(--rra-surface-raised);
  color: var(--rra-fg);
}

.rra-app .btn:not(.btn-primary):not(.btn-ghost):not(.btn-error):hover {
  background: var(--rra-surface);
  border-color: var(--rra-border-strong);
}

.rra-app .btn-primary {
  background: var(--rra-accent);
  border-color: var(--rra-accent);
  color: #fff;
}

.rra-app .btn-primary:hover {
  background: var(--rra-accent-hover);
  border-color: var(--rra-accent-hover);
}

.rra-app .btn-ghost {
  color: var(--rra-muted);
}

.rra-app .btn-ghost:hover {
  background: var(--rra-surface);
  color: var(--rra-fg);
}

.rra-app .select,
.rra-app .textarea {
  border-color: var(--rra-border-strong);
  border-radius: var(--rra-radius-sm);
  font-size: 13px;
}

.rra-app .textarea {
  background: var(--rra-surface-raised);
}

/* Use background-color only so daisyUI’s select chevron (background-image) stays */
.rra-app .select {
  background-color: var(--rra-surface-raised);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(1px + 50%),
    calc(100% - 11px) calc(1px + 50%);
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.75rem;
  color: var(--rra-fg);
}

.rra-app .select:focus,
.rra-app .textarea:focus {
  outline: 2px solid var(--rra-accent-ring);
  outline-offset: 0;
}

.rra-app #generate-btn {
  font-size: 14px;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  border-radius: var(--rra-radius);
}