:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-hover: #faf8f6;
  --surface-alt: #f0ede8;
  --primary: #7b9ea8;
  --primary-dark: #5f8490;
  --primary-light: #a3c1c9;
  --primary-bg: #eaf2f4;
  --accent: #c4a882;
  --accent-bg: #f5efe8;
  --text: #3d3d3d;
  --text-secondary: #7a7a7a;
  --text-tertiary: #a8a8a8;
  --border: #e8e4df;
  --border-light: #f0ede8;
  --danger: #c4918a;
  --danger-bg: #faf0ee;
  --success: #8ab5a0;
  --success-bg: #eef6f2;
  --shadow-sm: 0 1px 3px rgba(61,61,61,0.04);
  --shadow-md: 0 4px 12px rgba(61,61,61,0.06);
  --shadow-lg: 0 8px 30px rgba(61,61,61,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-jp: 'Noto Sans JP', sans-serif;
  --font-cn: 'Noto Sans SC', 'Noto Sans JP', sans-serif;
  --header-h: 56px;
  --nav-h: 64px;
  --player-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-cn);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 32px 24px;
}

#auth-screen.hidden {
  display: none;
}

.auth-container {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-logo {
  font-size: 56px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.5;
}

#auth-form .form-group {
  margin-bottom: 14px;
  text-align: left;
}

#auth-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

#auth-form .form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-cn);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#auth-form .form-group input:focus {
  border-color: var(--primary);
}

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
}

.auth-error.hidden {
  display: none;
}

.auth-offline-text {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  margin: 8px 0 4px;
}

.btn-block {
  width: 100%;
  margin-bottom: 10px;
}

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-ghost:active {
  background: var(--surface-alt);
}

#auth-logged-in {
  text-align: center;
}

#auth-logged-in.hidden {
  display: none;
}

.auth-user-info {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
}

#main-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

#main-app.hidden {
  display: none;
}

header#header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 10;
}

#page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}

#header-actions {
  display: flex;
  gap: 8px;
}

main#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
}

.page.active {
  display: block;
}

#bottom-nav {
  height: var(--nav-h);
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 10;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  font-family: var(--font-cn);
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}

.nav-btn.active {
  color: var(--primary-dark);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:active {
  background: var(--surface-alt);
}

#btn-sync.syncing svg {
  animation: spin 0.8s linear infinite;
}

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

#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  margin-bottom: 8px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: rgba(34,139,34,0.85);
}

.toast.error {
  background: rgba(200,50,50,0.85);
}

#list-toolbar {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-right {
  display: flex;
  gap: 4px;
}

.toggle-group {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-bg);
}

#filter-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

#filter-panel.hidden {
  display: none;
}

.filter-section {
  margin-bottom: 12px;
}

.filter-section:last-child {
  margin-bottom: 0;
}

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

.filter-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-bg);
}

#word-list {
  padding: 8px 16px;
}

.date-filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.date-filter-btn.has-filter {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-bg);
}

.date-filter-content {
  max-width: 340px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.dfm-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  max-height: 50vh;
}

.dfm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.dfm-item:hover {
  background: var(--bg);
}

.dfm-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.dfm-item span {
  font-size: 14px;
  color: var(--text);
}

.dfm-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.dfm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
}

.dfm-footer .btn {
  padding: 6px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  border: none;
}

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

.dfm-footer .btn-primary {
  background: var(--primary);
  color: #fff;
}

.word-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 0 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.group-title-text {
  flex: 1;
}

.group-count {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 8px;
}

.group-toggle-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.group-toggle-btn:active {
  transform: scale(0.95);
}

.word-group-items.collapsed {
  display: none;
}

.word-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  gap: 12px;
  border: 1px solid var(--border-light);
}

.word-item:active {
  transform: scale(0.98);
}

.word-item:has(.word-item-field-btn:active) {
  transform: none;
}

.word-item.playing {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.word-item-main {
  flex: 1;
  min-width: 0;
}

.word-item-word {
  font-family: var(--font-jp);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.word-item-kana {
  font-family: var(--font-jp);
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.word-item-kana.hidden,
.word-item-meaning.hidden {
  display: none;
}

.word-blurred {
  filter: blur(8px);
  user-select: none;
  transition: filter 0.2s;
}

.word-item-meaning {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.word-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.word-item-speak {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.word-item-speak:active {
  background: var(--primary-bg);
}

.word-item-field-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-secondary);
  opacity: 0.4;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.word-item-field-btn:hover {
  opacity: 0.7;
}

.word-item-field-btn.active {
  opacity: 0.85;
  color: var(--text);
}

.word-item-word-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.word-item-tags {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.word-item-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  white-space: nowrap;
}

#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

#empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

#empty-state p {
  font-size: 16px;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 13px !important;
  color: var(--text-tertiary) !important;
  margin-top: 4px;
}

.import-container {
  padding: 16px;
}

.import-section {
  margin-bottom: 20px;
}

.import-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.import-tip {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.template-hint {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.template-hint pre {
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  font-family: var(--font-jp);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.import-section label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.import-section input[type="text"],
.import-section textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-cn);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
}

.import-section input[type="text"]:focus,
.import-section textarea:focus {
  border-color: var(--primary);
}

.import-section textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.import-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
}

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

.btn-secondary:active {
  background: var(--surface-alt);
}

.btn-outline {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1.5px solid var(--primary-light);
}

.btn-outline:active {
  background: var(--primary-bg);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:active {
  opacity: 0.9;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

#import-preview {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
}

#import-preview.hidden {
  display: none;
}

#import-preview h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.preview-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.preview-item:last-child {
  border-bottom: none;
}

.preview-word {
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 500;
}

.preview-kana {
  font-family: var(--font-jp);
  font-size: 12px;
  color: var(--text-secondary);
}

.preview-meaning {
  font-size: 12px;
  color: var(--text-secondary);
}

.settings-container {
  padding: 16px;
}

.settings-section {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 12px;
}

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

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

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-cn);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

.form-group .btn + .btn {
  margin-left: 8px;
}

.form-group.hidden {
  display: none;
}

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

.input-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  line-height: 1.4;
}

.status-text {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-left: 8px;
}

.status-text.connected {
  color: var(--success);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
}

.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.radio-label input[type="radio"] {
  accent-color: var(--primary-dark);
}

.radio-label span {
  font-size: 14px;
  color: var(--text);
}

.radio-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  width: 100%;
  padding-left: 22px;
}

.form-group input[type="range"] {
  width: calc(100% - 50px);
  accent-color: var(--primary-dark);
  vertical-align: middle;
}

.range-val {
  font-size: 13px;
  color: var(--primary-dark);
  margin-left: 8px;
  font-weight: 500;
}

.sql-hint {
  background: #2d2a26;
  color: #e8e0d6;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'Courier New', monospace;
}

#player-bar {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  box-shadow: 0 -2px 10px rgba(61,61,61,0.06);
}

#player-bar.hidden {
  display: none;
}

#player-word-list-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  z-index: 25;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  animation: slideUp 0.3s ease;
}

#player-word-list-panel.hidden {
  display: none;
}

.deleted-modal-content {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.deleted-modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.deleted-modal-actions {
  padding: 8px 20px;
  flex-shrink: 0;
}

.deleted-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 16px;
  -webkit-overflow-scrolling: touch;
}

.speed-btns {
  display: flex;
  gap: 8px;
}

.speed-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: all 0.2s;
}

.speed-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.speed-btn:active {
  opacity: 0.7;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(61,61,61,0.3);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
  flex-shrink: 0;
}

.card-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

#card-counter {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: center;
}

.card-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 16px;
}

.card-word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.card-word {
  font-family: var(--font-jp);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.card-eye-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  flex-shrink: 0;
}

.card-eye-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.speak-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.speak-btn:active {
  background: var(--primary);
  color: white;
}

.speak-btn-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.speak-btn-sm:active {
  color: var(--primary-dark);
  background: var(--primary-bg);
}

.card-field {
  margin-bottom: 16px;
}

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

.field-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
}

.field-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.field-toggle:not(.active) {
  color: var(--text-tertiary);
}

.card-field[data-hidden="true"] .field-value {
  filter: blur(6px);
  user-select: none;
  transition: filter 0.3s;
}

.field-value {
  font-family: var(--font-jp);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  min-height: 24px;
}

#card-meaning,
#card-example-cn {
  font-family: var(--font-cn);
}

.card-tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 28px;
}

.card-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.card-tag-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  white-space: nowrap;
}

.card-tag-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.card-tag-edit-btn:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.card-tag-edit-content {
  padding: 20px;
  max-width: 400px;
}

.card-tag-edit-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-tag-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-tag-section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.ctm-current-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ctm-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--accent);
}

.ctm-tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}

.ctm-tag-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.ctm-add-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctm-add-tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}

.ctm-add-tag-item:hover {
  background: var(--primary-bg);
}

.ctm-no-tags {
  font-size: 12px;
  color: var(--text-tertiary);
}

.ctm-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.dfm-item-special {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
  margin-bottom: 6px;
}

.card-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 12px;
}

.icon-btn.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

#header-dropdown {
  position: absolute;
  top: var(--header-h);
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 180px;
  overflow: hidden;
}

#header-dropdown.hidden {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.dropdown-item:active {
  background: var(--surface-alt);
}

.dropdown-item + .dropdown-item {
  border-top: 1px solid var(--border-light);
}

#batch-bar {
  padding: 10px 16px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#batch-bar.hidden {
  display: none;
}

.batch-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 500;
}

.batch-actions {
  display: flex;
  gap: 6px;
}

.batch-checkbox-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.batch-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-dark);
  cursor: pointer;
}

.word-item.selected {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.deleted-item {
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.deleted-item-main {
  margin-bottom: 10px;
}

.deleted-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

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

#import-tags-area {
  margin-bottom: 4px;
}

#import-tag-list {
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.import-tag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.import-tag-name {
  font-size: 13px;
  color: var(--text);
}

.import-tag-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
  opacity: 0.5;
}

.import-tag-delete:hover {
  color: var(--danger);
  opacity: 1;
}

.import-tag-delete:active {
  background: var(--danger-bg);
}

.import-tag-empty {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 8px 0;
}

.import-tag-select {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.import-tag-select label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-item-main {
  flex: 1;
  min-width: 0;
}

.preview-item-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.preview-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  white-space: nowrap;
}

.tag-add-row {
  display: flex;
  gap: 8px;
}

.tag-add-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-cn);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.tag-add-row input:focus {
  border-color: var(--primary);
}

.tag-modal-content {
  padding: 20px;
  max-width: 400px;
}

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

.tag-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.tag-modal-body {
  max-height: 300px;
  overflow-y: auto;
}

.tag-select-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tag-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.tag-select-item:hover {
  background: var(--primary-bg);
}

.tag-select-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.tag-select-item span {
  font-size: 14px;
  color: var(--text);
}

.tag-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

#card-player-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
}

.card-player-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cp-btn:active {
  background: var(--surface-alt);
}

.cp-btn-main {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
}

.cp-btn-main:active {
  background: var(--primary-dark);
}

.cp-btn-main.playing {
  background: var(--accent);
}

.cp-btn-opt {
  width: 32px;
  height: 32px;
  color: var(--text-tertiary);
}

.cp-btn-opt.active {
  color: var(--primary-dark);
  background: var(--primary-bg);
}

.cp-btn-opt.loop-one {
  color: var(--accent);
  background: var(--accent-bg);
}

.cp-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.cp-select {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-cn);
  color: var(--text-secondary);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.cp-select-sm {
  padding: 4px 4px;
  font-size: 11px;
}

#card-word-list-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  z-index: 15;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  animation: slideUp 0.3s ease;
}

#card-word-list-panel.hidden {
  display: none;
}

.cwl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.cwl-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 16px;
}

.cwl-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  gap: 10px;
}

.cwl-item:active {
  background: var(--surface-alt);
}

.cwl-item.active {
  background: var(--primary-bg);
}

.cwl-item-index {
  font-size: 12px;
  color: var(--text-tertiary);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.cwl-item-word {
  font-family: var(--font-jp);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cwl-item-kana {
  font-family: var(--font-jp);
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.card-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }

  .modal-content {
    border-radius: var(--radius-xl);
    margin-bottom: 20px;
    max-height: 85vh;
  }
}
