:root {
  --color-primary: #0184ff;
  --color-text-primary: #000000;
  --color-text-secondary: #666666;
  --color-text-tertiary: #999999;
  --color-bg-primary: #f7f4ee;
  --color-bg-secondary: #f0ece4;
  --color-border: #e0e0e0;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --font-sans: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  line-height: 1.75;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* Header */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
  letter-spacing: 0.05em;
}
.page-header .subtitle {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* Chapter section */
.chapter {
  margin-bottom: 3rem;
}

.subgroup {
  padding: 2rem 0;
  border-top: 2px solid #c4bfb5;
}
.section-title + .subgroup {
  padding-top: 0.5rem;
  border-top: none;
}
.subgroup:last-child {
  padding-bottom: 0;
}
.subgroup .prompt-box,
.subgroup .download-card {
  margin-bottom: 0.75rem;
}
.subgroup > *:last-child {
  margin-bottom: 0;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-primary);
  margin: 0 0 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* PromptBox */
.prompt-box {
  position: relative;
  margin: 0 0 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background-color: var(--color-bg-primary);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.prompt-box__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem 0.6rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 52px;
}
.prompt-box__title {
  font-weight: 600;
  line-height: 1.2;
}
.prompt-box__copy {
  background-color: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 84px;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.prompt-box__copy.copied {
  background-color: #4CAF50;
  border-color: #4CAF50;
  color: #ffffff;
}
.prompt-box__body { position: relative; }
.prompt-box__content {
  width: 100%;
  background-color: var(--color-bg-primary);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  padding: 1rem 1.25rem;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 360px;
  overflow-y: auto;
}
.prompt-box__content::-webkit-scrollbar { width: 6px; }
.prompt-box__content::-webkit-scrollbar-track { background: transparent; }
.prompt-box__content::-webkit-scrollbar-thumb { background: var(--color-text-tertiary); border-radius: 999px; }
.prompt-box__mask {
  position: absolute;
  inset: 0;
  background-color: rgba(247, 244, 238, 0.95);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 1rem;
  border-radius: 0 0 12px 12px;
  backdrop-filter: blur(2px);
  transition: background-color 0.2s ease;
}
.prompt-box__mask:hover { background-color: rgba(247, 244, 238, 0.8); }

/* Download Card */
.download-card {
  display: flex;
  align-items: center;
  background-color: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1rem 1.25rem;
  gap: 1rem;
  margin: 0 0 0.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow 0.15s ease;
}
.download-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.download-card__info { flex: 1; }
.download-card__name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 0.25rem;
}
.download-card__desc {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin: 0;
}
.download-card__btn {
  padding: 0.65rem 1.4rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.15s ease;
}
.download-card__btn:hover { background: #0066cc; }

/* Channel */
.channel { margin-top: 3rem; }
.channel-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.channel-title .section-number { background: #f59e0b; }

.composer {
  margin-bottom: 1.25rem;
}
.composer__textarea {
  width: 100%;
  resize: none;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: #fff;
  padding: 0.75rem 0.875rem;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.composer__textarea:focus { border-color: #bcbcbc; }
.composer__textarea.dragging { border-color: var(--color-primary); background: #eaf4ff; }
.composer__hint {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin: 0.4rem 0 0;
}
.composer__status {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-all;
}
.composer__status--loading,
.composer__status--success,
.composer__status--error { display: flex; }
.composer__status--loading {
  background: #eaf4ff;
  color: #0066cc;
  border: 1px solid #bfdcff;
}
.composer__status--success {
  background: #e7f6ec;
  color: #1e7b3c;
  border: 1px solid #b8e0c4;
}
.composer__status--error {
  background: #fdecec;
  color: #b3261e;
  border: 1px solid #f5c2c0;
}
.composer__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #bfdcff;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}
.composer__textarea:disabled {
  background: #f5f1ea;
  cursor: not-allowed;
}

.feed-empty {
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

.msg {
  position: relative;
  border-bottom: 1px solid rgba(224, 224, 224, 0.6);
  padding: 0.75rem 0;
}
.msg:last-child { border-bottom: none; }
.msg.pinned {
  background: rgba(1, 132, 255, 0.05);
  border: 1px solid rgba(1, 132, 255, 0.2);
  border-radius: 10px;
  padding: 0.5rem 0.75rem 0.75rem;
  margin-bottom: 0.5rem;
}
.msg__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}
.msg__time { display: inline-flex; align-items: center; gap: 0.3rem; }
.msg__pin-dot { color: var(--color-primary); }
.msg__actions {
  display: flex;
  gap: 0.25rem;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.msg:hover .msg__actions { visibility: visible; opacity: 1; }
.msg__action-btn {
  border: none;
  background: transparent;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  border-radius: 4px;
}
.msg__action-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--color-text-primary); }
.msg__action-btn.delete:hover { color: #ef4444; }

.msg__body {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.msg__text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fff;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-primary);
}
.msg__text a { color: var(--color-primary); text-decoration: underline; }
.msg__copy {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: var(--font-sans);
}
.msg__copy.copied { background: #4CAF50; border-color: #4CAF50; color: #fff; }
.msg__file {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  text-decoration: none;
  font-weight: 500;
}
.msg__file:hover { background: #f5f5f0; }

/* Confirm Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade 0.15s ease;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--color-bg-primary);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.25rem;
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: modal-pop 0.18s ease;
}
@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 0.4rem;
}
.modal__body {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0 0 1.25rem;
  line-height: 1.6;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.modal__btn {
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-primary);
  transition: background 0.15s, border-color 0.15s;
}
.modal__btn:hover { background: rgba(0, 0, 0, 0.04); }
.modal__btn--danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.modal__btn--danger:hover { background: #dc2626; border-color: #dc2626; }

/* Pre-learn section */
.pre-learn { margin-top: 2rem; }
.pre-learn__badge { background: #10b981; }
.pre-learn__link {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border: none;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: var(--card-shadow);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.pre-learn__link:hover {
  background: #0066cc;
  box-shadow: 0 6px 16px rgba(1, 132, 255, 0.3);
}
.pre-learn__link:active { transform: translateY(1px); }
