:root {
  --bg: #0e0f13;
  --surface: #17181d;
  --surface2: #1f2128;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.16);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(14, 15, 19, 0.9);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 10px;
  display: block;
}
.back-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.title-block h1 { margin: 0; font-size: 18px; font-weight: 700; }
.title-block p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  overflow: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:active { transform: scale(0.97); }

.cat-thumb {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-soft), #14233f);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.word-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}

.card-body { padding: 10px 12px 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== word detail ===== */
.detail { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }

/* 全屏虚化背景：与前景大图同源，模糊铺底营造层次（位于 .detail 内容之下） */
.detail-bg-img {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(28px) brightness(0.42) saturate(1.12);
  transform: scale(1.18);
  z-index: -1;
  pointer-events: none;
}

.detail-stage {
  position: relative;
  flex: 1;
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.detail-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.detail-word {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 18px 18px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}
.detail-hint {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 9px;
  border-radius: 20px;
  pointer-events: none;
}

.detail-actions { display: flex; justify-content: center; margin-top: 16px; }
.upload-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 12px;
  cursor: pointer;
}

.detail-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.nav-btn {
  text-decoration: none;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.app-footer {
  position: relative;
  z-index: 11;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 16px 0 22px;
}

/* ===== crop modal（上传前裁剪）===== */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  padding: 16px;
}
.crop-modal[hidden] { display: none; }
.crop-box {
  width: 100%;
  max-width: 640px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.crop-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.crop-title { font-size: 15px; font-weight: 600; }
.crop-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crop-ratio-fixed {
  display: inline-flex; align-items: center;
  border: 1px solid var(--accent);
  color: var(--accent); background: var(--accent-soft);
  font-size: 13px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px;
}
.crop-tool {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.crop-tool.active { border-color: var(--accent); color: var(--accent); }
.crop-stage {
  background: #000;
  height: 56vh;
  max-height: 540px;
  overflow: hidden;
}
.crop-stage img { display: block; max-width: 100%; }
.crop-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.btn-accent {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
}
