/* ============================================
   无碍心声 — 无障碍优先设计系统
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #2D5A3D;
  --color-bg: #F5ECD7;
  --color-accent: #E8A838;
  --color-text: #1A1A1A;
  --color-white: #FFFFFF;
  --color-soft-green: #B8D4C8;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* --- Typography & Body --- */
body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    'PingFang SC',
    'Hiragino Sans GB',
    'Microsoft YaHei',
    'Helvetica Neue',
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Layout --- */
main {
  max-width: 480px;
  width: 100%;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.subtitle {
  font-size: 1rem;
  color: var(--color-text);
  opacity: 0.72;
  margin-bottom: 2.5rem;
}

/* --- Screen Reader Only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Big Circular Button --- */
.big-button {
  /* Size — meets WCAG touch target (≥260px diameter) */
  width: 260px;
  height: 260px;
  min-width: 260px;
  min-height: 260px;

  border-radius: 50%;
  border: none;
  cursor: pointer;

  background-color: var(--color-accent);
  color: var(--color-white);

  font-family: inherit;
  font-size: 1.75rem;
  font-weight: 800;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 24px rgba(232, 168, 56, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.big-button:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 32px rgba(232, 168, 56, 0.5);
}

.big-button:active {
  transform: scale(0.97);
}

.big-button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 4px;
}

/* --- Recording State --- */
.big-button.recording {
  background-color: #C0392B;
  animation: pulse 1.5s ease-in-out infinite;
  box-shadow: 0 4px 32px rgba(192, 57, 43, 0.5);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .big-button.recording {
    animation: none;
  }

  .big-button {
    transition: none;
  }
}

/* --- 我的吐槽 Link --- */
.my-complaints-link {
  margin-top: 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease;
}

.my-complaints-link:hover {
  background-color: var(--color-soft-green);
}

.my-complaints-link:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Responsive: Small Devices (≤480px) --- */
@media (max-width: 480px) {
  main {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }
}

/* --- Complaints Panel --- */
.complaints-panel {
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--color-white);
  border-radius: 12px;
  text-align: left;
}

.complaints-empty {
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  padding: 1.5rem 0;
}

.complaints-list {
  list-style: none;
}

.complaint-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid #e8e8e8;
}

.complaint-item:last-child {
  border-bottom: none;
}

.complaint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.complaint-app {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
}

.complaint-type {
  font-size: 0.8rem;
  color: #666;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
}

.complaint-status {
  font-size: 0.75rem;
  color: #fff;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.complaint-text {
  font-size: 0.9rem;
  color: #444;
  line-height: 1.4;
  margin-bottom: 4px;
}

.complaint-time {
  font-size: 0.75rem;
  color: #aaa;
}

/* --- AI 结构化信息展示 --- */
.complaint-summary {
  font-size: 0.85rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: 4px;
  padding: 4px 8px;
  background: var(--color-soft-green);
  border-radius: 6px;
}

.complaint-severity {
  font-size: 0.8rem;
  color: #E8A838;
  font-weight: 600;
}

.complaint-fix {
  font-size: 0.8rem;
  color: #2D5A3D;
  margin-bottom: 4px;
  padding: 4px 8px;
  background: #edf5f0;
  border-radius: 6px;
}

/* --- AI PRD 分析结果面板 --- */
.prd-panel {
  width: 100%;
  max-width: 400px;
  margin-top: 1.5rem;
  background-color: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  text-align: left;
  animation: prdFadeIn 0.4s ease;
}

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

.prd-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  background-color: var(--color-primary);
  color: var(--color-white);
  font-weight: 700;
  font-size: 0.95rem;
}

.prd-icon {
  font-size: 1.1rem;
}

.prd-confidence {
  margin-left: auto;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.prd-confidence.high {
  background: rgba(52,168,83,0.4);
}

.prd-confidence.medium {
  background: rgba(232,168,56,0.4);
}

.prd-confidence.low {
  background: rgba(192,57,43,0.4);
}

.prd-content {
  padding: 1rem;
}

.prd-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.prd-row:last-child {
  border-bottom: none;
}

.prd-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  min-width: 80px;
  flex-shrink: 0;
}

.prd-value {
  font-size: 0.9rem;
  color: var(--color-text);
  word-break: break-word;
}

.prd-value.app-name {
  font-weight: 700;
  color: var(--color-primary);
}

.prd-value.severity-严重 {
  color: #C0392B;
  font-weight: 700;
}

.prd-value.severity-中等 {
  color: #E8A838;
  font-weight: 600;
}

.prd-value.severity-轻微 {
  color: #34a853;
}

.prd-snippet-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: #f8f6f0;
  border-radius: 8px;
  border: 1px solid #e0ddd5;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #444;
  white-space: pre-wrap;
  word-break: break-word;
}

.prd-snippet-title {
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.prd-close-btn {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.4rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
}

.prd-close-btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Live Transcript (实时转写显示) --- */
.live-transcript {
  width: 100%;
  max-width: 400px;
  min-height: 60px;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-align: left;
  position: relative;
}

.live-text {
  font-size: 1.1rem;
  color: var(--color-text);
  line-height: 1.5;
  word-break: break-word;
  min-height: 1.5rem;
}

/* 临时识别文字（灰色，表示还没确认） */
.live-text .interim {
  color: #999;
}

/* 最终确认文字（深色，已经确认） */
.live-text .final {
  color: var(--color-text);
  font-weight: 600;
}

.live-hint {
  font-size: 0.85rem;
  color: #aaa;
  text-align: center;
}

.live-transcript.active {
  border: 2px solid var(--color-accent);
}

.live-transcript.active .live-hint {
  display: none;
}

/* --- Toast (Visible Feedback Bubble) --- */
.toast {
  width: 100%;
  max-width: 400px;
  min-height: 0;
  padding: 0;
  margin-bottom: 1rem;
  background: transparent;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease, min-height 0.3s ease, padding 0.3s ease;
  pointer-events: none;
  overflow: hidden;
}

.toast.visible {
  opacity: 1;
  min-height: 2.5rem;
  padding: 0.6rem 1.2rem;
  background-color: var(--color-white);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
}

.toast.error {
  background-color: #FFF3F3;
  border: 1px solid #E8A0A0;
}

.toast.success {
  background-color: #F0FFF4;
  border: 1px solid #B8D4C8;
}

/* --- Text Input Fallback --- */
.text-input-fallback {
  width: 100%;
  max-width: 400px;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.complaint-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--color-soft-green);
  border-radius: 8px;
  background-color: var(--color-white);
  color: var(--color-text);
  resize: vertical;
  min-height: 80px;
}

.complaint-input:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
}

.submit-text-btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  background-color: var(--color-accent);
  color: var(--color-white);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.submit-text-btn:active {
  transform: scale(0.97);
}

.submit-text-btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- Responsive: Minimum Supported Width (≤320px) --- */
@media (max-width: 320px) {
  main {
    padding: 1rem 0.875rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 0.875rem;
    margin-bottom: 2rem;
  }
}
