/* ==========================================================================
   違規魔人 Out! (Violator Out!) - Mobile-First Modern Design System
   ========================================================================== */

:root {
  --primary: #DC2626;
  --primary-hover: #B91C1C;
  --primary-light: #FEE2E2;
  --primary-soft: #FEF2F2;

  --accent-blue: #2563EB;
  --accent-green: #16A34A;
  --accent-amber: #D97706;

  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-muted: #F1F5F9;
  --bg-subtle: #E2E8F0;

  --text-main: #0F172A;
  --text-muted: #475569;
  --text-subtle: #94A3B8;
  --text-inverse: #FFFFFF;

  --border-light: #E2E8F0;
  --border-focus: #DC2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-preview: 0 8px 24px -4px rgba(220, 38, 38, 0.15), 0 4px 12px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* 底部固定操作列預留安全距離 (避免最底端表單被遮擋) */
  --bottom-bar-clearance: calc(225px + env(safe-area-inset-bottom, 20px));
}

/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
}

/* 頂部導航列 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-medium);
}

.nav-btn:active {
  transform: scale(0.96);
}

.icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-subtle);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn .icon {
  font-size: 1rem;
  line-height: 1;
}

.icon-btn .btn-label {
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 2px;
}

/* 主容器 (底部預留 safe clearance 防止被固定操作列遮擋) */
.main-container {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 16px var(--bottom-bar-clearance);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 表單容器與卡片間隔 */
#report-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 卡片共用樣式 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}

/* 表單分區標題 */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge-optional {
  font-size: 0.7rem;
  color: var(--text-subtle);
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* 表單元件 */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.label-hint {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--text-muted);
}

.required-star {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  margin-left: 2px;
}

.label-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-with-action .form-label {
  margin-bottom: 0;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.btn-text-link:hover {
  text-decoration: underline;
}

/* 輸入框與選單包裝 */
.select-wrapper, .input-wrapper {
  position: relative;
  width: 100%;
}

.custom-select, .custom-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 0.95rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  color: var(--text-main);
  transition: var(--transition-fast);
  outline: none;
}

.custom-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 40px;
  cursor: pointer;
}

.custom-select:focus, .custom-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.input-wrapper .custom-input {
  padding-right: 44px;
}

.custom-input.uppercase {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.btn-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  background: #CBD5E1;
  color: #FFFFFF;
  border: none;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear:hover {
  background: #94A3B8;
}

/* GPS 定位按鈕 */
.btn-action-gps {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #EFF6FF;
  border: 1.5px solid #BFDBFE;
  color: var(--accent-blue);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-action-gps:hover {
  background: #DBEAFE;
}

.btn-action-gps:active {
  transform: scale(0.95);
}

.gps-icon {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.btn-action-gps.loading {
  opacity: 0.75;
  pointer-events: none;
}

.btn-action-gps.loading .gps-icon {
  animation: spin 1s infinite linear;
}

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



/* 常用地點快捷列 (Requirement 2) */
.favorites-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.fav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fav-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.fav-manage-link {
  background: none;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-blue);
  cursor: pointer;
}

.fav-manage-link:hover {
  text-decoration: underline;
}

.fav-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.fav-chips-scroll::-webkit-scrollbar {
  display: none;
}

.fav-chip {
  flex-shrink: 0;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #92400E;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.fav-chip:hover {
  background: #FEF3C7;
  border-color: #F59E0B;
}

.fav-chip:active {
  transform: scale(0.96);
}

.fav-chip-add {
  flex-shrink: 0;
  background: var(--bg-muted);
  border: 1px dashed #CBD5E1;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.fav-chip-add:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* 分頁式 Segmented Control */
.tab-segmented {
  display: flex;
  background: var(--bg-muted);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Chips 選擇按鈕組 (車種、數量、路霸) */
.chips-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  height: 38px;
  padding: 0 14px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip-btn:hover {
  border-color: #CBD5E1;
  background: var(--bg-muted);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

.chip-btn:active {
  transform: scale(0.96);
}

/* 熱門高頻違規 Grid */
.hot-violations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

@media (min-width: 480px) {
  .hot-violations-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hot-vio-btn {
  height: 44px;
  padding: 0 10px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hot-vio-btn:hover {
  border-color: #F87171;
  background: #FEF2F2;
}

.hot-vio-btn.active {
  background: #FEF2F2;
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--primary);
}

.hot-vio-btn:active {
  transform: scale(0.97);
}

.mt-sm {
  margin-top: 8px;
}

/* 提示折疊方塊 (車牌眉角) */
.hint-callout {
  margin-top: 8px;
  padding: 10px 12px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hint-icon {
  font-size: 1rem;
  line-height: 1.2;
}

.hint-text {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #92400E;
}

/* 照片網址區塊 (Requirement 3) */
.input-with-button {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  height: 48px;
  padding: 0 14px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-muted);
}

.btn-secondary:active {
  transform: scale(0.96);
}

.btn-clear-inline {
  height: 48px;
  width: 48px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  color: #94A3B8;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear-inline:hover {
  color: var(--primary);
  border-color: #F87171;
}

.photo-info-note {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.photo-preview-card {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.photo-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.photo-img-wrapper {
  max-height: 200px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.photo-img-wrapper img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
}



/* 手機底部懸浮操作列 (Pinned Action Bar) */
.bottom-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 12px));
}

.bottom-action-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bottom-info-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bottom-police-badge {
  font-weight: 500;
}

.bottom-police-target {
  font-weight: 700;
  color: var(--primary);
}

.bottom-buttons-grid {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-primary-send {
  flex: 1;
  height: 52px;
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
  transition: var(--transition-fast);
}

.btn-primary-send:hover {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
}

.btn-primary-send:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

.btn-primary-send:disabled {
  background: #E2E8F0;
  color: #94A3B8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-primary-send:disabled:hover {
  background: #E2E8F0;
  box-shadow: none;
}

.btn-primary-send:disabled:active {
  transform: none;
  box-shadow: none;
}

.btn-secondary-copy {
  height: 52px;
  padding: 0 18px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.btn-secondary-copy:hover {
  background: var(--bg-muted);
  border-color: #CBD5E1;
}

.btn-secondary-copy:active {
  transform: scale(0.96);
}

.btn-secondary-copy:disabled {
  background: var(--bg-muted);
  border-color: var(--border-light);
  color: #94A3B8;
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
}

.btn-secondary-copy:disabled:hover {
  background: var(--bg-muted);
  border-color: var(--border-light);
}

.btn-secondary-copy:disabled:active {
  transform: none;
}

/* Modals (彈出視窗) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: #FFFFFF;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .modal-dialog {
    border-radius: var(--radius-xl);
  }
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-muted);
}

/* Modal 內部小元件 */
.sub-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.fav-add-box {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

.form-group-sm {
  margin-bottom: 8px;
}

.custom-input-sm, .custom-select-sm {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 0.88rem;
  border: 1px solid #CBD5E1;
  border-radius: var(--radius-sm);
  background: #FFFFFF;
}

.btn-primary-sm {
  width: 100%;
  height: 40px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary-sm:hover {
  background: var(--primary-hover);
}

.btn-secondary-sm {
  padding: 8px 16px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

.btn-subtle-sm {
  padding: 8px 12px;
  background: none;
  border: 1px dashed #CBD5E1;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-danger-sm {
  padding: 8px 16px;
  background: #FEE2E2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

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

.count-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.fav-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: var(--transition-fast);
}

.fav-item-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-sm);
}

.fav-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.fav-item-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.fav-item-county {
  font-size: 0.72rem;
  background: #EFF6FF;
  color: var(--accent-blue);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.fav-item-addr {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}

.btn-fav-action {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-light);
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn-fav-action:hover {
  background: var(--bg-subtle);
  border-color: var(--border-medium);
}

.btn-fav-action.btn-apply-fav {
  color: var(--primary);
  border-color: #FECACA;
  background: #FEF2F2;
}

.btn-fav-action.btn-apply-fav:hover {
  background: #FEE2E2;
}

.btn-fav-action.btn-delete-fav {
  color: var(--text-muted);
}

.btn-fav-action.btn-delete-fav:hover {
  color: var(--danger);
  border-color: #FECACA;
  background: #FEF2F2;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.btn-icon-sm:hover {
  background: var(--bg-subtle);
}

/* 歷史紀錄卡片 */
.history-intro {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.history-card:hover {
  border-color: #F87171;
  background: #FEF2F2;
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.4;
}

.history-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-light);
}

.btn-history-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-history-action:hover {
  background: #E2E8F0;
  border-color: #CBD5E1;
}

.btn-history-action.btn-apply-history {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: var(--accent-blue);
}

.btn-history-action.btn-apply-history:hover {
  background: #DBEAFE;
}

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-subtle);
  font-size: 0.9rem;
}

/* 說明須知內容 */
.doc-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-block {
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 14px;
}

.info-block h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.info-block p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Toast 通知組件 */
.toast-notification {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  pointer-events: none;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   底部即時簡訊展開抽屜 (Bottom Preview Sheet)
   ========================================================================== */

.bottom-preview-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.bottom-preview-sheet .sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.bottom-preview-sheet .sheet-container {
  position: relative;
  z-index: 1;
  background: #FFFFFF;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom, 16px));
  animation: sheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: #CBD5E1;
  border-radius: var(--radius-full);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.sheet-target-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.sheet-badge {
  background: #FEE2E2;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.sheet-label {
  color: var(--text-muted);
  font-weight: 500;
}

.sheet-police-number {
  font-weight: 800;
  color: var(--primary);
}

.btn-sheet-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-sheet-close:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.sheet-sms-content {
  background: #FFF5F5;
  border: 1px solid #FECACA;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-main);
  font-weight: 500;
  max-height: 220px;
  overflow-y: auto;
  word-break: break-word;
  white-space: pre-wrap;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.sheet-actions {
  display: flex;
  gap: 8px;
}

.btn-sheet-secondary {
  padding: 8px 14px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sheet-secondary:hover {
  background: var(--bg-muted);
}

.btn-sheet-primary {
  padding: 8px 16px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sheet-primary:hover {
  background: var(--primary-hover);
}

.btn-sheet-primary:disabled {
  background: #E2E8F0;
  color: #94A3B8;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-sheet-primary:disabled:hover {
  background: #E2E8F0;
}

/* 底部操作列簡訊預覽 Trigger (支援至少兩行預覽) */
.bottom-preview-trigger {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.bottom-preview-trigger:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  border-left-color: var(--primary-hover);
}

.bottom-preview-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.bottom-preview-label-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.bottom-preview-icon {
  font-size: 0.8rem;
  line-height: 1;
}

.bottom-preview-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--primary);
}

.bottom-preview-arrow {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-blue);
}

.bottom-preview-snippet {
  width: 100%;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-main);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* 桌面與平板排版微調 */
@media (min-width: 680px) {
  .main-container {
    padding: 24px 20px var(--bottom-bar-clearance);
  }
}
