/**
 * Main Styles
 * Application-specific styles using CSS custom properties and rem units
 */

/* CSS Custom Properties (Variables) */
:root {
  /* Colors */
  --color-bg-primary: rgba(239, 235, 230, 1);
  --color-bg-secondary: rgba(255, 255, 255, 1);
  --color-bg-accent: rgba(60, 89, 22, 1);
  --color-bg-accent-light: rgba(50, 83, 38, 0.1);

  --color-text-primary: rgba(16, 35, 32, 1);
  --color-text-secondary: rgba(168, 171, 175, 1);
  --color-text-inverse: rgba(255, 255, 255, 1);
  --color-text-accent: rgba(50, 83, 38, 1);
  --color-text-black: rgba(0, 0, 0, 1);

  --color-border: rgba(237, 237, 236, 1);
  --color-border-accent: rgba(58, 92, 23, 1);

  /* Typography */
  --font-size-xs: 0.32rem;
  --font-size-sm: 0.373rem;
  --font-size-base: 0.4rem;
  --font-size-md: 0.426rem;
  --font-size-lg: 0.453rem;

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.2;
  --line-height-base: 1.4;
  --line-height-relaxed: 1.5;

  /* Spacing */
  --spacing-xs: 0.08rem;
  --spacing-sm: 0.134rem;
  --spacing-md: 0.267rem;
  --spacing-lg: 0.4rem;
  --spacing-xl: 0.534rem;

  /* Border Radius */
  --radius-sm: 15px;
  --radius-md: 18px;
  --radius-lg: 22px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-inset: inset 0px -1px 0px 0px var(--color-border);
  --shadow-inset-top: inset 0px 1px 0px 0px var(--color-border);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
}

/* App Container */
.app {
  position: relative;
  width: 10rem;
  min-height: 21.654rem;
  background-color: var(--color-bg-primary);
  overflow-x: hidden;
  margin: 0 auto;
  padding-bottom: 1.6rem;
}

/* Header */
.header {
  background-color: var(--color-bg-secondary);
}

/* Status Bar */
.status-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.054rem 0 0.027rem 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-black);
}

.status-bar__left {
  display: flex;
  align-items: center;
  gap: 0.107rem;
}

.status-bar__signal {
  width: 0.427rem;
  height: 0.267rem;
}

.status-bar__carrier {
  font-family: 'SF Pro Text', -apple-system, sans-serif;
  line-height: 0.374rem;
}

.status-bar__wifi {
  width: 0.32rem;
  height: 0.24rem;
  margin-left: 0.027rem;
}

.status-bar__time {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'SF Pro Text', -apple-system, sans-serif;
  font-weight: var(--font-weight-semibold);
  line-height: 0.374rem;
  white-space: nowrap;
}

.status-bar__right {
  display: flex;
  align-items: center;
  gap: 0.107rem;
}

.status-bar__location {
  width: 0.214rem;
  height: 0.32rem;
}

.status-bar__battery-icon {
  width: 0.72rem;
  height: 0.32rem;
}

.status-bar__battery-percent {
  font-family: 'PingFang SC', sans-serif;
  font-weight: var(--font-weight-medium);
  line-height: 0.454rem;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.294rem;
  position: relative;
  padding: 0.134rem 0;
}

.navbar__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-black);
  line-height: 0.64rem;
  margin: 0;
}

/* Hero Section */
.hero {
  background-image: url(../images/hero-bg.png);
  background-size: cover;
  background-position: center;
  padding: 0.614rem 1.707rem 3.707rem 1.68rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.user-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 2.267rem;
}

.user-profile__avatar-wrapper {
  border-radius: var(--radius-full);
  border: 0.9px solid var(--color-border-accent);
  padding: 0.054rem 0.08rem 0.08rem 0.054rem;
  margin-bottom: 0.054rem;
}

.user-profile__avatar {
  border-radius: var(--radius-full);
  background-image: url(../images/avatar.png);
  background-size: cover;
  background-position: center;
  width: 1.68rem;
  height: 1.68rem;
}

.user-profile__name {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  text-align: center;
  white-space: nowrap;
  line-height: 0.534rem;
}

.hero__decoration {
  width: 6.614rem;
  height: 3.12rem;
  margin-top: 0.587rem;
}

/* Tabs Navigation */
.tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: var(--color-bg-secondary);
  box-shadow: 0 -0.027rem 0.107rem rgba(0, 0, 0, 0.05);
  padding: 0.267rem 0.534rem;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.tab {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.134rem;
  padding: 0.134rem 0.4rem;
  border-radius: var(--radius-lg);
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

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

.tab__icon {
  width: 0.64rem;
  height: 0.64rem;
  flex-shrink: 0;
}

.tab__label {
  font-size: var(--font-size-base);
  color: var(--color-text-accent);
  font-weight: var(--font-weight-medium);
  text-align: center;
  white-space: nowrap;
  line-height: 0.56rem;
}

/* Divider */
.divider {
  width: 10rem;
  height: 0.907rem;
  background-image: url(../images/divider.png);
  background-size: cover;
}

/* Main Content */
.main-content {
  position: absolute;
  left: 0.32rem;
  top: 9.227rem;
  width: 9.36rem;
  padding: 0.427rem 0.534rem 0.667rem;
    background: linear-gradient( 180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.9) 100%);
    border-radius: 24px;
    border: 1px solid #FFFFFF;
    backdrop-filter: blur(2px);
}

/* Form */
.form {
  position: relative;
}

/* Form Field */
.form-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 8.294rem;
  padding: 0.347rem 0.027rem 0.374rem 0;
  box-shadow: var(--shadow-inset);
}

.form-field__label {
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  line-height: 0.56rem;
  white-space: nowrap;
}

.form-field__input {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  text-align: right;
  line-height: 0.56rem;
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-field__input::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

.form-field__input:focus {
  color: var(--color-text-primary);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.form-field__input:focus::placeholder {
  opacity: 0.6;
}

.form-field__picker {
  display: flex;
  align-items: center;
  gap: 0.08rem;
  cursor: pointer;
}

.form-field__picker-value {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 0.56rem;
  white-space: nowrap;
}

.form-field__picker-icon {
  width: 0.16rem;
  height: 0.294rem;
}

/* Toggle Groups */
.form-toggles {
  display: flex;
  justify-content: space-between;
  width: 8.294rem;
  margin-top: 0.16rem;
}

.toggle-group {
  display: flex;
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: 0.08rem;
  gap: 0.08rem;
}

.toggle-group__option {
  padding: 0.134rem 0.374rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  text-align: center;
  white-space: nowrap;
  line-height: 0.534rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.toggle-group__option--active {
  background-color: var(--color-bg-accent);
  color: var(--color-text-inverse);
}

.toggle-group__option:hover:not(.toggle-group__option--active) {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Form Divider */
.form-divider {
  width: 8.187rem;
  height: 0.96rem;
  background: url(../images/form-divider.png) 100% no-repeat;
  background-size: 100% 100%;
  align-self: center;
  margin: 0.987rem auto 0;
  position: relative;
}

/* Submit Button */
.btn-submit {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8.187rem;
  height: 1.227rem;
background: linear-gradient( 0deg, #466C39 0%, rgba(74,109,58,0.69) 100%);
box-shadow: 8px 6px 48px 0px rgba(105,144,120,0.41);
border-radius: 23px;
border-image: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
backdrop-filter: blur(4px);
  border: none;
  padding: 0.347rem 0;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.btn-submit:hover {
  transform: translate(-50%, -50%) translateY(-0.027rem);
  box-shadow: 0 0.08rem 0.4rem rgba(0, 0, 0, 0.2);
}

.btn-submit:active {
  transform: translate(-50%, -50%);
  opacity: 0.9;
}

.btn-submit:focus-visible {
  outline: 2px solid var(--color-bg-accent);
  outline-offset: 2px;
}

.btn-submit span {
  font-size: var(--font-size-md);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-bold);
  text-align: center;
  white-space: nowrap;
  line-height: 0.587rem;
}

/* Responsive Design - For larger screens */
@media screen and (min-width: 768px) {
  .app {
    max-width: 10rem;
    box-shadow: 0 0 2rem rgba(0, 0, 0, 0.1);
  }
}

/* Loading State */
.form.is-loading .btn-submit {
  pointer-events: none;
  opacity: 0.6;
}

.form.is-loading .btn-submit::after {
  content: '';
  position: absolute;
  width: 0.4rem;
  height: 0.4rem;
  border: 2px solid var(--color-text-inverse);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Loading Modal */
.loading-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-modal.is-active {
  display: flex;
}

.loading-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
}

.loading-modal__content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-bg-secondary);
  border-radius: 0.32rem;
  padding: 0.8rem 1.2rem;
  box-shadow: 0 0.107rem 0.534rem rgba(0, 0, 0, 0.15);
}

.loading-modal__spinner {
  width: 2.587rem;
  height: 2.587rem;
  animation: loading-spin 2s linear infinite;
}

@keyframes loading-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-modal__text {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* DateTime Picker */
.datetime-picker {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.datetime-picker.is-active {
  display: block;
}

.datetime-picker__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.datetime-picker__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg-secondary);
  border-radius: 0.4rem 0.4rem 0 0;
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* Picker Header */
.datetime-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.534rem;
  border-bottom: 1px solid var(--color-border);
}

.datetime-picker__calendar-toggle {
  /* Reuse toggle-group styles from main form */
}

.datetime-picker__confirm {
  font-size: var(--font-size-sm);
  background-color: var(--color-bg-accent);
  color: var(--color-text-inverse);
  border: none;
  padding: 0.134rem 0.374rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-align: center;
  white-space: nowrap;
  line-height: 0.534rem;
}

.datetime-picker__confirm:active {
  opacity: 0.9;
}

.datetime-picker__title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

/* Picker Body */
.datetime-picker__body {
  position: relative;
  padding: 0.534rem 0;
}

.datetime-picker__columns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.267rem;
  padding: 0 0.534rem;
}

.datetime-picker__column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.datetime-picker__label {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin-bottom: 0.267rem;
  text-align: center;
}

.datetime-picker__scroller {
  width: 100%;
  height: 5.6rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
  position: relative;
}

/* Hide scrollbar */
.datetime-picker__scroller::-webkit-scrollbar {
  display: none;
}

.datetime-picker__scroller {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.datetime-picker__list {
  padding: 2.4rem 0;
}

.datetime-picker__item {
  height: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  scroll-snap-align: center;
  transition: all var(--transition-fast);
}

.datetime-picker__item.is-selected {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-bold);
  font-size: 0.533rem;
}

/* Indicator - selection highlight */
.datetime-picker__indicator {
  position: absolute;
  left: 0.534rem;
  right: 0.534rem;
  bottom: 2.934rem; /* body-padding-bottom(0.534) + (scroller-height(5.6) - indicator-height(0.8)) / 2 */
  height: 0.8rem;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  pointer-events: none;
}

/* =========================================================================
 * Global Audio Player (听全文悬浮播放器)
 * ========================================================================= */
.global-audio-player {
  position: fixed;
  /* 默认位置：底部居中 */
  bottom: 2.133rem;
  left: 50%;
  transform: translateX(-50%);
  width: 9.36rem;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 0.107rem 0.64rem rgba(0, 0, 0, 0.15);
  padding: 0.32rem 0.427rem;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: left 0.3s ease, top 0.3s ease, bottom 0.3s ease, right 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.global-audio-player.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* 拖拽时取消过渡 */
.global-audio-player.dragging {
  transition: none;
}

.audio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.267rem;
}

.audio-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 0.16rem;
}

.audio-title::before {
  content: '';
  display: inline-block;
  width: 0.427rem;
  height: 0.427rem;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%234a6d3a"><path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/></svg>');
  background-size: cover;
}

.audio-close {
  background: none;
  border: none;
  font-size: 0.64rem;
  color: var(--color-text-secondary);
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.32rem;
}

.audio-play-btn {
  width: 1.067rem;
  height: 1.067rem;
  border-radius: 50%;
  background: var(--color-bg-accent);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.audio-play-btn svg {
  width: 0.533rem;
  height: 0.533rem;
  fill: currentColor;
}

.audio-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.audio-progress-bar {
  -webkit-appearance: none;
  width: 100%;
  height: 0.107rem;
  background: var(--color-border);
  border-radius: 0.053rem;
  outline: none;
  margin: 0.16rem 0;
}

.audio-progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.427rem;
  height: 0.427rem;
  border-radius: 50%;
  background: var(--color-bg-accent);
  cursor: pointer;
  box-shadow: 0 0.053rem 0.107rem rgba(0,0,0,0.2);
}

.audio-time {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

/* =========================================================================
 * Markdown Rendered Content Styles (for marked.js output)
 * ========================================================================= */
.markdown-body {
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  line-height: var(--line-height-relaxed);
  text-align: justify;
  word-wrap: break-word;
}

.markdown-body p {
  margin-top: 0;
  margin-bottom: 0.32rem;
}

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

.markdown-body strong {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-accent);
}

.markdown-body em {
  font-style: italic;
  color: var(--color-text-accent);
}

.markdown-body ul, 
.markdown-body ol {
  margin: 0.16rem 0 0.32rem 0.64rem;
  padding: 0;
}

.markdown-body li {
  margin-bottom: 0.16rem;
}

.markdown-body blockquote {
  border-left: 0.107rem solid var(--color-bg-accent);
  margin: 0.32rem 0;
  padding: 0.16rem 0.32rem;
  background-color: var(--color-bg-accent-light);
  border-radius: 0 0.16rem 0.16rem 0;
  color: var(--color-text-secondary);
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4, 
.markdown-body h5, 
.markdown-body h6 {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-top: 0.64rem;
  margin-bottom: 0.32rem;
  line-height: var(--line-height-tight);
}

.markdown-body hr {
  height: 1px;
  background-color: var(--color-border);
  border: none;
  margin: 0.64rem 0;
}

.markdown-body a {
  color: var(--color-bg-accent);
  text-decoration: underline;
}