/* ===== TOKENS ===== */
:root {
  --ink:           #2A7A4B;
  --ink-2:         #3a3a48;
  --ink-3:         #7a7a8c;
  --ink-4:         #a8a8b8;
  --canvas:        #F5F7F5;
  --white:         #ffffff;
  --border:        rgba(17,17,24,0.08);
  --border-md:     rgba(17,17,24,0.14);
  --border-strong: rgba(17,17,24,0.22);
  --accent:        #4CAF7D;
  --accent-h:      #1C5435;
  --accent-lt:     #E6F4EC;
  --accent-mid:    #C8DDD0;
  --teal:          #2A7A4B;
  --teal-lt:       #E6F4EC;
  --gold:          #9a6200;
  --gold-lt:       #fef5e0;
  --r:             8px;
  --r-md:          14px;
  --r-lg:          22px;
  --shadow:        0 2px 12px rgba(17,17,24,0.07);
}

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

body {
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--canvas);
  color: #111118;
  line-height: 1.6;
}

/* ===== APP HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--ink);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 2.5rem;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-badge {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.app-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  line-height: 1.3;
}

.app-tagline {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.70);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.hidden {
  display: none !important;
}

/* ===== PHASES ===== */
.phase {
  background: var(--white);
  border-radius: var(--r-md);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: fadeUp 0.25s ease;
}

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

.phase-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.phase-desc {
  font-size: 14px;
  color: var(--ink-3);
  margin-top: -14px;
  margin-bottom: 20px;
}

h2 {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 20px;
  line-height: 1.2;
}

/* ===== FORM ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group > label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--ink-2);
}

/* ===== RADIO CARDS ===== */
.radio-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.radio-card {
  cursor: pointer;
  display: flex;
}

.radio-card input {
  display: none;
}

.radio-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 14px 16px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r-md);
  background: var(--white);
  transition: all 0.18s;
}

.radio-content strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.radio-content span {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

.radio-card:hover .radio-content {
  background: var(--accent-lt);
  border-color: var(--accent-mid);
}

.radio-card input:checked + .radio-content {
  background: var(--accent-lt);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42,122,75,0.15);
}

.radio-card input:checked + .radio-content strong {
  color: var(--ink);
}

/* ===== INPUTS ===== */
input[type="text"],
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  font-size: 14px;
  font-family: inherit;
  color: #111118;
  background: var(--white);
  transition: border-color 0.15s;
  resize: vertical;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--ink-4);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== HELPER TEXT ===== */
.helper-text {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 10px;
  background: var(--canvas);
  padding: 12px 14px;
  border-radius: var(--r);
  border-left: 3px solid var(--accent);
  line-height: 1.6;
}

.helper-text ul {
  margin-top: 6px;
  padding-left: 1.25rem;
}

.helper-text li {
  margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  pointer-events: none;
  transform: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--ink-2);
  border: 1px solid var(--border-md);
  padding: 11px 22px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--canvas);
  border-color: var(--border-strong);
}

/* ===== CHAT ===== */
.chat-header {
  margin-bottom: 16px;
}

.chat-header p {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 4px;
}

.chat-messages {
  max-height: 400px;
  overflow-y: auto;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.message {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.message.assistant {
  align-items: flex-start;
}

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

.message-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.assistant .message-bubble {
  background: var(--canvas);
  color: #111118;
  border: 1px solid var(--border);
}

.message.user .message-bubble {
  background: var(--ink);
  color: #fff;
}

.message-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-area textarea {
  resize: none;
  min-height: 80px;
}

.chat-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== DOCUMENT OUTPUT ===== */
.document-output {
  background: var(--canvas);
  border: 1px solid var(--border-md);
  border-radius: var(--r-md);
  padding: 24px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  font-family: 'Georgia', serif;
  max-height: 500px;
  overflow-y: auto;
  margin-bottom: 16px;
  color: #111118;
}

.output-actions {
  display: flex;
  gap: 10px;
}

.copy-feedback {
  margin-top: 8px;
  color: var(--teal);
  font-weight: 600;
  font-size: 13px;
}

/* ===== LOADING ===== */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(247,246,242,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(4px);
  gap: 16px;
}

.loading p {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 14px;
}

.loading-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ===== FILE UPLOAD ===== */
.label-optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-4);
  margin-left: 6px;
}

.file-upload-box {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r);
  background: var(--canvas);
  overflow: hidden;
  transition: all 0.15s;
}

.file-upload-box:has(label:hover) {
  border-color: var(--accent);
  background: var(--accent-lt);
}

.file-upload-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px;
  cursor: pointer;
  width: 100%;
}

.file-input-hidden {
  display: none;
}

.file-upload-cta {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.file-upload-formats {
  font-size: 12px;
  color: var(--ink-4);
}

.file-upload-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.file-upload-selected span {
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-clear {
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all 0.15s;
}

.file-clear:hover {
  border-color: var(--border-strong);
  color: var(--ink-2);
}

.file-note {
  font-size: 12px;
  color: var(--ink-4);
  margin-top: 8px;
  line-height: 1.5;
}

/* ===== PROCESS OVERVIEW ===== */
.process-overview {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.overview-intro {
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.65;
  margin-bottom: 20px;
}

.process-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.process-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.step-body {
  font-size: 14px;
  color: #111118;
  line-height: 1.55;
}

.step-body strong {
  color: var(--ink-2);
  font-weight: 600;
}

.overview-notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overview-notice {
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: var(--r);
}

.notice-time {
  background: var(--gold-lt);
  color: var(--gold);
  border: 1px solid #f5d99a;
}

.notice-privacy {
  background: var(--teal-lt);
  color: var(--teal);
  border: 1px solid rgba(13,107,82,0.2);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .app-header {
    padding: 0 1.25rem;
  }

  .container {
    padding: 24px 16px 60px;
  }

  .phase {
    padding: 20px;
  }

  .radio-group {
    grid-template-columns: 1fr 1fr;
  }

  .chat-buttons {
    flex-direction: column;
  }

  .output-actions {
    flex-direction: column;
  }
}
