/* ============================================================
   DICTIONARY — FAB anchored to sheet + side panel + word card
   ============================================================ */

/* ---- FAB (squircle "Aa", anchored to right edge of A4 sheet) ---- */
.dict-fab {
  position: fixed;
  bottom: 32px;
  /* Sheet width 794px → half = 397. Plus 24px gap, plus FAB half (30) for visual centering offset.
     50% (= viewport center) - 397 - 24 - 60 (fab width) = 50% - 481.
     Use max() to clamp on narrow screens. */
  right: max(20px, calc(50% - 481px));
  z-index: 49;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, #2c2d31 0%, #1a1b1e 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 6px 18px rgba(60, 64, 67, 0.28),
    0 2px 6px rgba(60, 64, 67, 0.16);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.18s,
              opacity 0.2s;
}
.dict-fab:hover {
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 12px 28px rgba(60, 64, 67, 0.36),
    0 4px 8px rgba(60, 64, 67, 0.20);
}
.dict-fab:active { transform: translateY(-1px); }

.dict-fab-aa {
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
}
.dict-fab-aa .a1 {
  font-size: 26px;
}
.dict-fab-aa .a2 {
  font-size: 18px;
  margin-left: 1px;
  opacity: 0.78;
}

.dict-fab-label {
  position: absolute;
  right: 72px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.dict-fab:hover .dict-fab-label { opacity: 1; }

.dict-open .dict-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

/* ---- Backdrop ---- */
.dict-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.36);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.dict-open .dict-backdrop { opacity: 1; pointer-events: auto; }

/* ---- Panel ---- */
.dict-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: var(--paper);
  box-shadow: -6px 0 28px rgba(60, 64, 67, 0.20);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.dict-open .dict-panel { transform: translateX(0); }

.dict-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--rule);
  min-height: 56px;
  flex-shrink: 0;
}
.dict-head .dict-back {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 6px;
  margin-left: -4px;
}
.dict-head .dict-back:hover { background: #f1f3f4; color: var(--ink); }
.dict-head .dict-back svg { width: 14px; height: 14px; }
.dict-view-detail .dict-head .dict-back { display: inline-flex; }
.dict-view-detail .dict-head .dict-title { display: none; }

.dict-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.dict-close {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}
.dict-close:hover { background: #f1f3f4; color: var(--ink); }

/* ---- Search ---- */
.dict-search-wrap {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.dict-view-detail .dict-search-wrap { display: none; }

.dict-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f3f4;
  border-radius: 12px;
  padding: 11px 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.dict-search:focus-within {
  background: var(--paper);
  border-color: var(--ink-dim);
}
.dict-search svg.dict-icon {
  width: 16px;
  height: 16px;
  color: var(--ink-dim);
  flex-shrink: 0;
}
.dict-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 0;
}
.dict-search input::placeholder { color: var(--ink-dim); }
.dict-clear {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  display: none;
}
.dict-clear.shown { display: block; }
.dict-clear:hover { color: var(--ink); }

/* ---- Body ---- */
.dict-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- States ---- */
.dict-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-soft);
}
.dict-state .dict-state-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }
.dict-state .dict-state-text { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.dict-state .dict-state-hint { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }
.dict-state .dict-progress { width: 200px; height: 3px; background: #f1f3f4; border-radius: 2px; margin-top: 14px; overflow: hidden; }
.dict-state .dict-progress-bar { height: 100%; background: var(--ink-soft); width: 0; transition: width 0.2s; }
.dict-state-error button {
  margin-top: 12px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---- Results list ---- */
.dict-results {
  overflow-y: auto;
  flex: 1;
}
.dict-result {
  display: block;
  padding: 13px 22px;
  border-bottom: 1px solid #f1f3f4;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.dict-result:hover { background: #fafbfc; }
.dict-result-word {
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}
.dict-result-word.exact { color: #1a73e8; }
.dict-result-translations {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.dict-meta {
  padding: 10px 22px;
  font-size: 11px;
  color: var(--ink-dim);
  background: #fafbfc;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

/* ============================================================
   WORD DETAIL — clean flex layout, no tables
   ============================================================ */
.dict-detail {
  flex: 1;
  overflow-y: auto;
  padding: 26px 26px 60px;
}

.dict-detail-head {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 26px;
}
.dict-detail-word {
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.015em;
  margin-bottom: 6px;
  line-height: 1.05;
}
.dict-detail-pos {
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.dict-detail-translations {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
}

/* Section blocks */
.dict-detail-section {
  margin-bottom: 30px;
}
.dict-detail-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--ink);
  letter-spacing: -0.005em;
}
.dict-detail-section-sub {
  font-size: 12px;
  color: var(--ink-dim);
  margin: -2px 0 12px;
  font-style: italic;
}

/* Form rows — flex, two columns */
.dict-form {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 9px 0;
  border-bottom: 1px dashed #e8eaed;
}
.dict-form:last-child { border-bottom: none; }

.dict-form-key {
  flex: 0 0 auto;
  min-width: 0;
}
.dict-form-main {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.3;
}
.dict-form-primary {
  font-weight: 600;
}
.dict-form-secondary {
  color: var(--ink-soft);
  font-weight: 400;
  font-size: 13px;
}
.dict-form-sub {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 3px;
  line-height: 1.3;
  font-style: italic;
}
.dict-form-val {
  flex: 1;
  text-align: right;
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.005em;
  word-break: break-word;
}
.dict-form-val.dash {
  color: var(--ink-dim);
  font-weight: 400;
  font-style: italic;
  font-size: 17px;
}

/* Toggle button */
.dict-toggle-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  margin: 8px 0 22px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dict-toggle-more:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.dict-detail-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  font-size: 13px;
  padding: 60px 20px;
}

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .dict-panel {
    top: auto;
    width: 100%;
    height: 88vh;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .dict-open .dict-panel { transform: translateY(0); }
  .dict-fab {
    right: 18px;
    bottom: 18px;
  }
  .dict-fab-label { display: none; }
  .dict-detail { padding: 20px 18px 50px; }
  .dict-detail-word { font-size: 30px; }
}
