/* ===== CSS 变量（DeepSeek 浅色设计语言） ===== */
:root {
  --bg: #F5F5F7;
  --card-bg: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --brand: #0e1116;
  --brand-text: #FFFFFF;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --transition: 220ms cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

/* ===== 全局重置 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== 页面容器 ===== */
.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== 头部 ===== */
.header {
  padding: 16px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-back {
  display: none;
  position: absolute;
  left: 16px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  font-family: var(--font);
  transition: opacity var(--transition);
}

.header-back:active {
  opacity: 0.5;
}

.header-back.visible {
  display: block;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

/* ===== 主内容区 ===== */
.main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* 满屏布局容器（意见箱页面） */
.main-box {
  display: flex;
  flex-direction: column;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ===== 首页大卡片容器 ===== */
.home-panel {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.home-item {
  display: block;
  width: 100%;
  padding: 36px 24px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.home-item:active {
  background: #F5F5F7;
}

.home-item-divider {
  height: 1px;
  background: var(--border);
  margin: 0 24px;
}

.home-item-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.home-item-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.home-item-arrow {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

/* 首页说明区域 */
.home-info {
  margin-top: 24px;
  padding: 0 4px;
}

.home-info-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

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

.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--brand);
}

.form-textarea {
  min-height: 140px;
  resize: vertical;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

/* ===== 按钮 ===== */
.btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-text);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn:disabled {
  background: #E5E7EB;
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== 空状态 ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-text {
  font-size: 15px;
  margin-bottom: 4px;
}

.empty-sub {
  font-size: 13px;
}

/* ===== 弹窗遮罩 ===== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.overlay.show {
  display: flex;
}

/* ===== 弹窗 ===== */
.dialog {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px 20px 20px;
  width: calc(100% - 48px);
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.dialog-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.dialog-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.dialog-input:focus {
  border-color: var(--brand);
}

.dialog-input::placeholder {
  color: var(--text-muted);
}

.dialog-error {
  font-size: 13px;
  color: #EF4444;
  margin-bottom: 12px;
  display: none;
}

.dialog-error.show {
  display: block;
}

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

.dialog-btn {
  flex: 1;
  padding: 12px 0;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.dialog-btn:active {
  transform: scale(0.98);
}

.dialog-btn-cancel {
  background: var(--bg);
  color: var(--text-secondary);
}

.dialog-btn-confirm {
  background: var(--brand);
  color: var(--brand-text);
}

.dialog-btn-confirm:disabled {
  background: #E5E7EB;
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== 创建页面表单 ===== */
.create-form {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.create-form .form-group {
  margin-bottom: 24px;
}

.create-form .form-group:last-of-type {
  margin-bottom: 0;
}

.create-form .form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-error {
  font-size: 12px;
  color: #EF4444;
  margin-top: 6px;
  display: none;
}

.form-error.show {
  display: block;
}

/* 密码输入框容器 */
.password-wrap {
  position: relative;
}

.password-wrap .form-input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font);
  padding: 8px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.password-toggle:active {
  color: var(--text);
}

/* 生成按钮 */
.create-btn-wrap {
  margin-top: 24px;
}

/* ===== 成功弹窗 ===== */
.dialog-success {
  text-align: center;
}

.dialog-success .dialog-title {
  color: #16A34A;
  font-size: 18px;
  margin-bottom: 20px;
}

.dialog-info {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  text-align: left;
}

.dialog-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.dialog-info-row + .dialog-info-row {
  border-top: 1px solid var(--border);
}

.dialog-info-label {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 12px;
}

.dialog-info-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.dialog-tip {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: left;
}

.btn-copy {
  margin-bottom: 0;
}

/* ===== 离开确认弹窗 ===== */
.dialog-confirm-text {
  font-size: 15px;
  color: var(--text);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}
.placeholder {
  text-align: center;
  padding: 80px 20px;
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.placeholder-text {
  font-size: 15px;
  color: var(--text-muted);
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.78);
  color: #FFFFFF;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
}

.toast.show {
  opacity: 1;
}

/* ===== 意见箱页面（满屏布局） ===== */
.box-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.box-page .btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.box-page .btn-action {
  flex: 1;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.box-page .btn-action:active {
  background: var(--bg);
}

.box-page .btn-action.primary {
  background: var(--brand);
  color: var(--brand-text);
  border-color: var(--brand);
}

.box-page .btn-action.primary:active {
  opacity: 0.85;
}

.box-page .btn-action.unlocked {
  color: #16A34A;
  border-color: #16A34A;
  background: #F0FDF4;
}

/* 提交者信息行 */
.box-submitter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.box-submitter .name-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.box-submitter .name-input:focus {
  border-color: var(--brand);
}

.box-submitter .name-input::placeholder {
  color: var(--text-muted);
}

.box-submitter .name-input:disabled {
  opacity: 0.5;
}

/* 匿名选择 */
.anon-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
}

.anon-option {
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--font);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.anon-option + .anon-option {
  border-left: 1px solid var(--border);
}

.anon-option.active {
  background: var(--brand);
  color: var(--brand-text);
}

/* 意见标题 */
.box-title {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}

.box-title:focus {
  border-color: var(--brand);
}

.box-title:read-only {
  color: var(--text-muted);
  background: #F5F5F7;
}

/* 意见内容区（内部滚动） */
.box-content-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  min-height: 0;
}

.box-content {
  flex: 1;
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  resize: none;
  line-height: 1.6;
  transition: border-color var(--transition);
}

.box-content:focus {
  border-color: var(--brand);
}

.box-content::placeholder {
  color: var(--text-muted);
}

/* 提交按钮 */
.box-submit {
  flex-shrink: 0;
}

/* ===== 查阅意见页面 ===== */

/* 图表区 */
.chart-section {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.chart-section .chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-section .chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.chart-section .chart-month {
  font-size: 13px;
  color: var(--text-muted);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 140px;
  padding: 0 4px;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 56px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-fill {
  width: 100%;
  max-width: 36px;
  background: var(--brand);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-bar-fill.zero {
  background: #E5E7EB;
}

.chart-bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.chart-bar-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  white-space: nowrap;
}

.chart-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* 注销意见箱 */
.danger-zone {
  margin-bottom: 12px;
}

.btn-danger {
  display: block;
  width: 100%;
  padding: 13px 0;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: #EF4444;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-danger:active {
  background: #FEF2F2;
}

/* 意见列表 */
.opinion-list-section {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.opinion-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.opinion-list-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.opinion-list-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 8px;
  font-weight: 400;
}

.btn-clear-all {
  padding: 6px 14px;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-full);
  background: none;
  color: #EF4444;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-clear-all:active {
  background: #FEF2F2;
}

.opinion-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.opinion-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.opinion-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.opinion-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.opinion-item-time {
  font-size: 12px;
  color: var(--text-muted);
}

.opinion-item-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
  word-break: break-word;
}

.opinion-item-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-delete {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-delete:active {
  background: #FEF2F2;
  color: #EF4444;
  border-color: #FCA5A5;
}

.opinion-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.opinion-loading {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* 意见条目可点击 */
.opinion-item {
  cursor: pointer;
}

.opinion-item:active {
  background: #F9FAFB;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

/* 意见详情弹窗 */
.opinion-detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.opinion-detail-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.opinion-detail-time {
  font-size: 13px;
  color: var(--text-muted);
}

.opinion-detail-content {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
  word-break: break-word;
  white-space: pre-wrap;
}