/* ==========================================================================
   Apple-Inspired Liquid Glass Design System (Compact Single-Screen Version)
   单行极简控制栏 + 防遮挡无滚动输入空间 + 独立底置规则提示岛
   ========================================================================== */

:root {
  /* Apple 系统主色 */
  --apple-bg: #f5f6fa;
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-glow: rgba(0, 113, 227, 0.16);
  --apple-green: #34c759;
  --apple-green-bg: rgba(52, 199, 89, 0.12);
  --apple-orange: #ff9500;
  --apple-orange-bg: rgba(255, 149, 0, 0.12);

  /* 文字颜色 */
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-placeholder: #a1a1a6;

  /* 毛玻璃质感 */
  --glass-surface: rgba(255, 255, 255, 0.76);
  --glass-dock: rgba(255, 255, 255, 0.86);
  --glass-border: rgba(255, 255, 255, 0.88);
  --glass-border-subtle: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
  --glass-shadow-dock: 0 8px 24px -6px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);

  /* 圆角 */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* 字体族 */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", sans-serif;
  --font-mono: "SF Mono", Monaco, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 核心布局：锁定视口高度 100vh，杜绝全局滚动 */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--apple-bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* 浅色环境光晕背景 */
.glass-ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
}

.glow-1 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(190, 225, 255, 0.75) 0%, rgba(225, 240, 255, 0) 70%);
  top: -80px;
  left: 15%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(235, 220, 255, 0.7) 0%, rgba(245, 235, 255, 0) 70%);
  top: 20%;
  right: -60px;
}

.glow-3 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(210, 250, 235, 0.65) 0%, rgba(230, 255, 245, 0) 70%);
  bottom: 0%;
  left: 25%;
}

/* ==========================================================================
   一、极致收窄的单行顶部控制栏 (Single-Row Navbar)
   ========================================================================== */

.glass-navbar {
  flex-shrink: 0;
  width: 100%;
  height: 42px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--glass-border-subtle);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  z-index: 100;
}

.nav-content {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

/* 品牌微标 */
.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.jp-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, #0071e3 0%, #47a0ff 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  white-space: nowrap;
}

/* 单行功能集群 */
.control-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.control-cluster::-webkit-scrollbar {
  display: none;
}

/* 并列的双功能控制开关 */
.toggle-group {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  padding: 2px;
  border-radius: var(--radius-full);
  gap: 2px;
  flex-shrink: 0;
}

.glass-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.glass-toggle-btn .toggle-icon {
  width: 13px;
  height: 13px;
}

.glass-toggle-btn.active {
  background: #ffffff;
  color: var(--apple-blue);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.glass-toggle-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* 分段选择器 (Segmented Controls) */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  padding: 2px;
  border-radius: var(--radius-full);
  gap: 1px;
  flex-shrink: 0;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.seg-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* 内嵌指定形态下拉框 */
.targeted-inline {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.targeted-inline.hidden {
  display: none;
}

.glass-inline-select {
  appearance: none;
  background: #ffffff;
  border: 1px solid rgba(0, 113, 227, 0.25);
  color: var(--apple-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 22px 3px 10px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%230071e3'%3e%3cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
}

/* 右侧控制项 */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  background: rgba(0, 0, 0, 0.03);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-num {
  font-weight: 700;
  color: var(--apple-blue);
  font-size: 13px;
}

.glass-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--apple-blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.glass-pill-btn:hover {
  background: var(--apple-blue-hover);
}

.key-hint {
  font-size: 9px;
  background: rgba(255, 255, 255, 0.25);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
}

/* ==========================================================================
   二、中间主舞台 (App Main Stage) - 高度自适应，不发生滚动
   ========================================================================== */

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 6px 20px 4px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.glass-card {
  background: var(--glass-surface);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 10px 22px 8px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}

/* 词卡微型头部 */
.word-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.word-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-tag {
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

.pos-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--apple-blue-glow);
  color: var(--apple-blue);
  padding: 2px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(0, 113, 227, 0.18);
}

.pos-badge.hidden {
  display: none;
}

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

.icon-nav-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--glass-border-subtle);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.icon-nav-btn:hover {
  background: #ffffff;
  color: var(--text-primary);
  transform: scale(1.06);
}

/* 单词展示区 (横向紧凑设计) */
.word-hero {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  padding: 0 0 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 4px;
  min-height: 38px;
}

.hero-kanji {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  line-height: 1.1;
  min-height: 36px;
}

.hero-kanji ruby {
  ruby-align: center;
  ruby-position: over;
}

.hero-kanji rt {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
  padding-bottom: 1px;
  user-select: none;
}

.hero-kanji rt.ruby-placeholder {
  visibility: hidden;
  user-select: none;
  pointer-events: none;
}

.hero-meaning-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-meaning {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.romaji-hint {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.03);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

/* ==========================================================================
   三、打字输入工作区 (Typing Workspace) - 紧凑横排网格（固定每行 3 个选项）
   ========================================================================== */

.typing-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
}

.forms-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 4px 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.forms-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.05);
}

.forms-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px 10px;
  margin-bottom: 3px;
}

/* 某一行只有单个形态卡片时，水平居中置中显示 */
.form-input-card.single-in-row {
  grid-column: 2;
  justify-self: stretch;
  width: 100%;
  max-width: none;
}

/* 舒适精致输入卡片（~1.25x 优化） */
.form-input-card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  gap: 8px;
  min-height: 38px;
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.form-input-card:focus-within {
  background: #ffffff;
  border-color: var(--apple-blue);
  box-shadow: 0 3px 14px var(--apple-blue-glow);
  transform: translateY(-1px);
}

.form-input-card.correct {
  background: var(--apple-green-bg);
  border-color: rgba(52, 199, 89, 0.45);
}

.form-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 86px;
}

.typing-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-family);
  outline: none;
  min-width: 0;
  height: 26px;
  line-height: 26px;
  padding: 0;
  letter-spacing: 0.2px;
}

.typing-input::placeholder {
  color: var(--text-placeholder);
  font-size: 12px;
  font-weight: 400;
}

.form-input-card.correct .typing-input {
  color: #1a7d36;
}

.form-status-indicator {
  width: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-placeholder);
  flex-shrink: 0;
}

.form-input-card.correct .form-status-indicator {
  color: var(--apple-green);
  font-weight: 700;
}

/* 单项突击模式卡片 (Single Challenge - Larger & Comfortable) */
.single-challenge-card {
  text-align: center;
  padding: 16px 0 10px;
  max-width: 520px;
  margin: 0 auto;
}

.challenge-prompt {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.challenge-target-badge {
  display: inline-block;
  font-size: 20px;
  font-weight: 700;
  color: var(--apple-blue);
  background: var(--apple-blue-glow);
  padding: 6px 20px;
  border-radius: var(--radius-full);
  margin-bottom: 18px;
}

.single-input-wrapper {
  margin-bottom: 12px;
}

.single-large-input {
  width: 100%;
  padding: 14px 22px;
  min-height: 58px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  background: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-lg);
  outline: none;
  letter-spacing: 0.5px;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.single-large-input:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 8px 26px var(--apple-blue-glow);
  transform: scale(1.01);
}

.single-large-input.correct {
  border-color: var(--apple-green);
  background: var(--apple-green-bg);
  color: #1a7d36;
}

.single-feedback {
  font-size: 13px;
  font-weight: 600;
  min-height: 18px;
}

.single-feedback.correct {
  color: var(--apple-green);
}

.single-feedback.error {
  color: #ff3b30;
}

/* 底部极简键盘提示条 */
.input-guide-footer {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
}

.guide-tag {
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  margin-right: 4px;
  color: var(--text-secondary);
}

.guide-shortcuts kbd {
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* ==========================================================================
   四、屏幕底部规则提示岛 (Docked Hint Island) - 独立底置，绝不遮挡上方
   ========================================================================== */

.glass-hint-dock {
  flex-shrink: 0;
  margin: 0 auto 8px;
  width: min(1180px, calc(100vw - 32px));
  background: var(--glass-dock);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow-dock);
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.glass-hint-dock.dock-hidden {
  display: none !important;
}

/* 临时唤起状态 (当平时未常开，用户输入错误或回车空白时临时展开) */
.glass-hint-dock.dock-temporary-peek {
  display: block !important;
  animation: peekPulse 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 16px 40px rgba(255, 149, 0, 0.2), 0 0 0 2px rgba(255, 149, 0, 0.45);
  border-color: rgba(255, 149, 0, 0.45);
}

@keyframes peekPulse {
  0% { transform: translateY(16px); opacity: 0; }
  60% { transform: translateY(-2px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

/* 输入框错误动画 */
.form-input-card.error,
.single-large-input.error {
  animation: shake 0.4s ease;
  border-color: #ff3b30 !important;
  background: rgba(255, 59, 48, 0.08) !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* 可点击顶栏 */
.dock-header {
  padding: 5px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.15s ease;
}

.dock-header:hover {
  background: rgba(255, 255, 255, 0.85);
}

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

.dock-icon {
  font-size: 14px;
}

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

.dock-target-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--apple-blue);
  background: var(--apple-blue-glow);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

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

.dock-collapse-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

.dock-toggle-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.dock-toggle-indicator svg {
  width: 10px;
  height: 10px;
}

/* 折叠状态 */
.glass-hint-dock.dock-collapsed .dock-header {
  border-bottom: none;
}

.glass-hint-dock.dock-collapsed .dock-toggle-indicator {
  transform: rotate(180deg);
}

.glass-hint-dock.dock-collapsed .dock-body {
  display: none;
}

/* 紧凑提示主体 */
.dock-body {
  padding: 6px 16px 7px;
}

.hint-grid {
  display: grid;
  grid-template-columns: 190px 1fr 1.35fr;
  gap: 10px;
  align-items: start;
}

.hint-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.block-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--apple-blue);
  background: var(--apple-blue-glow);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}

.block-rule-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.formula-display {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.03);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(0, 0, 0, 0.04);
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.tip-content {
  font-size: 11px;
  font-weight: 500;
  color: #924b00;
  background: var(--apple-orange-bg);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255, 149, 0, 0.18);
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

/* ==========================================================================
   响应式调整
   ========================================================================== */

@media (max-width: 860px) {
  .forms-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-input-card.single-in-row {
    grid-column: 1 / -1;
    justify-self: center;
    width: 60%;
  }
  .hint-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 540px) {
  .forms-grid {
    grid-template-columns: 1fr;
  }
  .form-input-card.single-in-row {
    grid-column: 1;
    width: 100%;
  }
}

@media (max-height: 680px) {
  .word-hero {
    min-height: 32px;
    padding: 0 0 2px;
    margin-bottom: 2px;
  }
  .hero-kanji {
    font-size: 24px;
    min-height: 30px;
  }
  .form-input-card {
    min-height: 32px;
    padding: 2px 8px;
  }
  .typing-input {
    font-size: 14px;
    height: 24px;
    line-height: 24px;
  }
  .forms-grid {
    gap: 3px 6px;
    margin-bottom: 1px;
  }
  .forms-section-title {
    margin: 2px 0 1px;
  }
  .glass-card {
    padding: 6px 16px 4px;
  }
  .dock-body {
    padding: 4px 12px 5px;
  }
}
