/* biscuit · 背单词（discuit 风格极简版：纯白 / 无圆角 / 无色彩装饰） */
:root {
  --text: #1a1a1a;
  --muted: #9e9e9e;
  --line: #ececec;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #fff;
  color: var(--text);
  overflow: hidden;
}

/* ---------- 第一行：入口按钮 + 输入与搜索 ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.head-row { display: flex; align-items: stretch; }
.glyph-btn {
  width: 52px; height: 52px; flex-shrink: 0;
  border: none; border-radius: 0;
  background: #fff;
  color: var(--glyph, #36ab60);
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
/* 象限角标用 SVG 绘制（Unicode ▛/▟ 在安卓上字体回退不一致会变形） */
.glyph-btn svg { width: 24px; height: 24px; display: block; fill: var(--glyph, #36ab60); }
#search {
  display: block; flex: 1; width: 100%; min-width: 0;
  padding: 15px 16px;
  border: none; border-radius: 0;
  font-size: 17px;
  background: #fff;
  color: var(--text);
  outline: none;
  appearance: none; -webkit-appearance: none;
}
#search::placeholder { color: #c4c4c4; }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* 查词浮层（输入时出现） */
.lookup {
  background: #fff;
  border-bottom: 1px solid var(--line);
  max-height: 60vh; overflow-y: auto;
}
.lookup.hidden { display: none; }
.lookup .item { padding: 12px 16px; cursor: pointer; border-top: 1px solid var(--line); }
.lookup .item:active, .lookup .item:hover { background: #f7f7f7; }
.lookup .w { font-size: 16px; }
.lookup .p { color: var(--muted); font-size: 13px; margin-left: 8px; }
.lookup .t { font-size: 14px; margin-top: 3px; color: #555; }
.lookup .d { font-size: 12px; color: var(--muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 单词列表：一行一个 ---------- */
main { height: 100%; overflow-y: auto; padding-top: calc(env(safe-area-inset-top, 0px) + 54px); }
#list { list-style: none; }
.empty { text-align: center; color: var(--muted); margin-top: 30vh; line-height: 2; font-size: 14px; }
.empty.hidden { display: none; }

.card {
  position: relative;
  border-bottom: 1px solid var(--line);
}
.card.open { z-index: 40; } /* 展开浮层时压住后面的行 */

.row {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px;
  padding: 12px 16px;
  user-select: none;
  touch-action: pan-y;
  transition: background .3s, color .3s, transform .25s, opacity .25s;
}
.card.known .row { opacity: .35; }
.w { font-size: 17px; }
.p { font-size: 13px; color: inherit; opacity: .65; margin-left: 8px; }
.badge { font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* 红标记色块：右缘竖条，宽 = 行高/4，红色深度表示标记层级 */
.redblock {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 13px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 600;
  pointer-events: none;
}

/* 滑动提示 */
.hint {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 17px; opacity: 0; transition: opacity .15s;
  pointer-events: none;
  background: #fff;
}
.hint.left  { left: 16px; }
.hint.right { right: 16px; }
.row.swiping .hint.show { opacity: 1; }

/* 删除动画 */
.card.removing .row { transition: opacity .25s, transform .25s; opacity: 0; transform: translateX(-100%); }

/* ---------- 翻转浮层：覆盖在列表之上的"前一层的图层" ---------- */
/* 不挤压列表：绝对定位锚在当前行顶部，宽度与行相同，向下自然展开 */
.flip-panel {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 45;
  background: var(--panel-bg, #fff);
  border: 1px solid var(--line);
  border-top: none;
}
.flip-panel.hidden { display: none; }

/* 顶部一条 = 原单词行占据的位置，点它翻回 */
.fp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  user-select: none;
}

/* 内容区：完整展示，可选可复制 */
.fp-body {
  padding: 14px 16px 18px;
  user-select: text; -webkit-user-select: text;
  cursor: auto;
}
.fp-body .t { font-size: 16px; margin-bottom: 8px; line-height: 1.6; }
.fp-body .d { font-size: 13px; color: #555; white-space: pre-wrap; line-height: 1.7; }
.fp-body .n { font-size: 13px; color: #777; margin-top: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff;
  padding: 8px 18px;
  font-size: 14px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 99;
}
#toast.show { opacity: 1; }

/* ---------- 登录界面：discuit 绿全屏 + 白色图标 + 白色口令条 ---------- */
#token-dialog {
  border: none; border-radius: 0;
  margin: 0;
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  padding: 0;
  background: #36ab60;
  display: flex; align-items: center; justify-content: center;
}
#token-dialog[open] { display: flex; }
#token-dialog::backdrop { background: #36ab60; }
#token-dialog form {
  display: flex; flex-direction: column; align-items: center;
  gap: 56px;
  width: 100%;
}
.login-logo { width: 104px; height: 104px; }

/* 白色输入条：口令 + 右侧箭头（▜ 倾斜 45°） */
.login-row {
  display: flex; align-items: stretch;
  width: min(72vw, 320px);
  background: #fff;
}
.login-row input {
  flex: 1; min-width: 0;
  border: none; border-radius: 0; outline: none;
  background: #fff;
  padding: 14px 16px;
  font-size: 16px;
  color: #1a1a1a;
  letter-spacing: 2px;
}
.login-go {
  width: 52px; flex-shrink: 0;
  border: none; border-radius: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.login-go svg { width: 20px; height: 20px; fill: #36ab60; display: block; }
.login-go:active { background: #f0f0f0; }

/* 出错反馈：不显示文字，输入条红描边 + 抖动 */
#token-dialog.error .login-row { box-shadow: inset 0 0 0 2px #d64541; animation: shake .3s; }
@keyframes shake {
  20% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  80% { transform: translateX(-3px); }
}

/* ---------- 设置界面 ---------- */
#settings {
  position: fixed; inset: 0; z-index: 60;
  background: #fff;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top, 0px);
}
#settings.hidden { display: none; }
.set-head {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
}
.set-title { font-size: 17px; margin-left: 12px; }
.set-body { padding-bottom: 40px; }
.set-group { padding: 18px 16px 6px; border-bottom: 1px solid var(--line); }
.set-group:last-child { border-bottom: none; }
.set-group h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.set-line {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; font-size: 15px;
}
.set-line select, .set-line input[type="text"], .set-line input[type="number"] {
  font-size: 15px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 0;
  background: #fff; color: var(--text);
  max-width: 60%;
}
.set-line input[type="range"] { flex: 1; }
.zone-val { font-size: 13px; color: var(--muted); min-width: 70px; text-align: right; }
.set-line input[type="color"] {
  width: 44px; height: 30px; padding: 0; border: 1px solid var(--line);
  background: #fff; border-radius: 0;
}
.set-note { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.set-btn {
  margin-top: 6px; padding: 9px 20px;
  border: 1px solid var(--text); border-radius: 0;
  background: #fff; color: var(--text);
  font-size: 14px; cursor: pointer;
}
.set-btn:active { background: #f2f2f2; }
.swatches { display: flex; gap: 10px; padding-bottom: 12px; }
.swatch {
  width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 0;
  cursor: pointer; padding: 0;
}
.swatch.transparent { background: #fff; background-image: linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%), linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%); background-size: 10px 10px; background-position: 0 0, 5px 5px; }
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
