:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f8ef;
  --text: #333;
  --text-secondary: #888;
  --border: #eee;
  --bg: #f5f5f5;
  --card: #fff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(56px + var(--safe-bottom));
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #10b981 100%);
  color: #fff;
  padding: 20px 16px 24px;
  text-align: center;
}

.header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.header-sub {
  margin: 6px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

/* Views */
.view {
  display: none;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Progress */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--progress, 10%);
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Question card */
.question-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: var(--shadow);
  min-height: 280px;
}

.question-num {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.question-text {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
}

.answer-area textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.answer-area textarea:focus {
  border-color: var(--primary);
}

.closing-message {
  text-align: center;
  padding: 24px 8px;
}

.closing-emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.closing-text {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.required-hint {
  font-size: 12px;
  color: #e74c3c;
  margin-top: 8px;
}

/* Nav buttons */
.nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

/* Tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}

.tab.active {
  color: var(--primary);
}

.tab-icon {
  font-size: 20px;
}

.tab-label {
  font-size: 11px;
}

/* Records */
.records-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.records-count {
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
}

.records-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.records-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.records-empty[hidden],
.records-list:not(:empty) + .records-empty {
  display: none;
}

.record-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}

.record-card:active {
  transform: scale(0.98);
}

.record-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.record-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.record-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.record-preview {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  animation: modalIn 0.25s ease;
}

.modal-detail {
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-hint {
  margin: 8px 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.modal-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
}

.modal-input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.detail-time {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 16px;
}

.detail-answers {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.detail-a {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

/* Desktop */
@media (min-width: 481px) {
  body {
    background: #e8e8e8;
  }

  #app {
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.1);
    background: var(--bg);
  }

  .tabbar {
    left: 50%;
    transform: translateX(-50%);
  }
}
