/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --primary:       #C0392B;
  --primary-dark:  #96281B;
  --gold:          #F39C12;
  --header-bg:     #1A1A2E;
  --bg:            #F4F5F7;
  --card-bg:       #FFFFFF;
  --text-primary:  #1A1A2E;
  --text-secondary:#4A4A6A;
  --text-muted:    #9999AA;
  --border:        #E2E4EA;
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:     0 3px 14px rgba(0,0,0,0.10);
  --radius:        14px;
  --radius-sm:     8px;
  --transition:    0.22s ease;
  --header-height: 62px;
  --nav-height:    64px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
               'Noto Sans JP', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100%;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

svg {
  display: block;
  flex-shrink: 0;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--header-height);
  background: var(--header-bg);
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0 20px;
}

.header-flag {
  font-size: 28px;
  line-height: 1;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.05em;
  margin-top: 1px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-main {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + 8px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--nav-height);
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  transition: color var(--transition);
  min-height: 48px;
  padding: 6px 4px;
}

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

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

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 24px;
  height: 24px;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ============================================================
   CATEGORY TABS
   ============================================================ */
.category-tabs-wrap {
  position: sticky;
  top: var(--header-height);
  z-index: 100;
  background: var(--header-bg);
  padding: 8px 0 10px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.08);
  border: 1.5px solid transparent;
  transition: all var(--transition);
  scroll-snap-align: start;
  min-height: 36px;
}

.category-tab .tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.category-tab.active {
  color: #FFFFFF;
  background: rgba(255,255,255,0.15);
  border-color: currentColor;
}

.category-tab.active .tab-dot {
  opacity: 1;
}

.category-tab:active {
  opacity: 0.7;
}

/* ============================================================
   WORD LIST
   ============================================================ */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px;
}

.list-count {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 14px 0;
  font-weight: 500;
}

/* ============================================================
   WORD CARD
   ============================================================ */
.word-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border-left: 4px solid var(--cat-color, #ccc);
  transition: box-shadow var(--transition);
}

.word-card.expanded {
  box-shadow: var(--shadow-md);
}

.card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 14px 14px;
  cursor: pointer;
  user-select: none;
  min-height: 80px;
}

.card-main:active {
  background: rgba(0,0,0,0.02);
}

.card-left {
  flex: 1;
  min-width: 0;
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, #F6AD55, #ED8936);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-bottom: 5px;
  letter-spacing: 0.04em;
}

.premium-badge svg {
  width: 10px;
  height: 10px;
}

.word-es {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.word-ja {
  font-size: 18px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}

.word-kana {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.card-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   ICON BUTTONS
   ============================================================ */
.speak-btn,
.fav-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition), transform 0.15s;
}

.speak-btn svg,
.fav-btn svg {
  width: 20px;
  height: 20px;
}

.speak-btn:hover,
.speak-btn:active {
  color: var(--cat-color, #3182CE);
  background: rgba(0,0,0,0.05);
}

.speak-btn.speaking {
  color: var(--cat-color, #3182CE);
  animation: speakPulse 0.9s ease-in-out infinite;
}

@keyframes speakPulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%       { transform: scale(1.25); opacity: 0.7; }
}

.fav-btn:hover,
.fav-btn:active {
  background: rgba(0,0,0,0.05);
}

.fav-btn.active {
  color: #E53E3E;
}

.fav-btn.active svg {
  fill: #E53E3E;
}

.fav-btn:active {
  transform: scale(0.88);
}

.chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.chevron svg {
  width: 18px;
  height: 18px;
}

.word-card.expanded .chevron {
  transform: rotate(180deg);
}

/* ============================================================
   EXAMPLE SECTION (ACCORDION)
   ============================================================ */
.example-section {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.28s ease;
  opacity: 0;
}

.example-section.open {
  max-height: 300px;
  opacity: 1;
}

.example-content {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.015);
}

.example-es-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}

.example-es {
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}

.speak-btn-sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-top: -2px;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition), transform 0.15s;
}

.speak-btn-sm svg {
  width: 16px;
  height: 16px;
}

.speak-btn-sm:hover,
.speak-btn-sm:active {
  color: var(--cat-color, #3182CE);
  background: rgba(0,0,0,0.05);
}

.speak-btn-sm.speaking {
  color: var(--cat-color, #3182CE);
  animation: speakPulse 0.9s ease-in-out infinite;
}

.example-ja {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.55;
}

/* ============================================================
   CATEGORY BADGE (search / favorites view)
   ============================================================ */
.category-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
  color: var(--cat-color, #555);
  background: var(--cat-bg, #eee);
  letter-spacing: 0.03em;
}

/* ============================================================
   SEARCH VIEW
   ============================================================ */
.search-header {
  padding: 16px 14px 4px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border: 1.5px solid var(--border);
  border-radius: 28px;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-icon svg {
  width: 20px;
  height: 20px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  padding: 13px 0;
  min-width: 0;
}

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

.search-clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg);
  font-size: 14px;
  flex-shrink: 0;
  transition: background var(--transition);
}

.search-clear:hover {
  background: var(--border);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  padding: 20px 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
  gap: 12px;
}

.empty-icon {
  font-size: 52px;
  line-height: 1;
}

.empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-secondary);
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   PROGRESS BAR (word count per category)
   ============================================================ */
.cat-stats {
  padding: 4px 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-stats-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.cat-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.cat-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--cat-color, #999);
  transition: width 0.4s ease;
}
