* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: #f8f8f8;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 80px;
  z-index: 100;
  -webkit-app-region: drag;
}

#search-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  -webkit-app-region: no-drag;
}

#search-input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s;
}

#search-input:focus {
  border-color: #0088DD;
  box-shadow: 0 0 0 2px rgba(0, 136, 221, 0.15);
}

#suggestions {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}

#suggestions.hidden {
  display: none;
}

#suggestions .suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}

#suggestions .suggestion-item:last-child {
  border-bottom: none;
}

#suggestions .suggestion-item:hover,
#suggestions .suggestion-item.active {
  background: #e8f4fd;
}

#content {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 16px 20px 40px;
  -webkit-overflow-scrolling: touch;
}

#welcome {
  text-align: center;
  color: #999;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#welcome h1 {
  font-size: 28px;
  font-weight: 300;
  color: #0088DD;
  margin-bottom: 8px;
}

#welcome p {
  font-size: 15px;
}

#definition {
  max-width: 800px;
  margin: 0 auto;
}

/* Override dictionary body styles to not interfere with app layout */
#definition .word_entry {
  margin-top: 0;
  background-image: none;
  padding-right: 0;
}

/* ── Word entry header: 2-row grid layout ─────────────── */
#definition .word_entry {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 2px;
  align-items: baseline;
}

/* Row 1 left: word */
#definition .word_key {
  grid-row: 1;
  grid-column: 1;
  font-size: 1.6em;
}

/* Row 1 right: frequency */
#definition .word-frequency-img {
  grid-row: 1;
  grid-column: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: none;
  line-height: 1;
}

#definition .word-frequency-img::before {
  content: '常用度';
  font-family: "PingFang SC", -apple-system, sans-serif;
  font-size: 11px;
  color: #999;
  margin-right: 4px;
}

#definition .word-frequency-img .level {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
  margin: 0;
}

#definition .word-frequency-img .level.roundRed {
  background: #0088DD;
}

#definition .word-frequency-img .level::before,
#definition .word-frequency-img .level.roundRed::before {
  content: none;
}

/* Row 2 left: pronunciation */
#definition .word_entry > .pron {
  grid-row: 2;
  grid-column: 1;
  padding-left: 0;
  font-size: 0.95em;
}

#definition .word_entry > .pron > a {
  margin-right: 10px;
}

#definition .word_entry > .pron::after {
  content: none;
}

#definition .word_entry > .pron .pron::before {
  content: '/';
}

#definition .word_entry > .pron .pron::after {
  content: '/ ';
}

/* Row 2 right: inflected forms */
#definition .form_inflected {
  grid-row: 2;
  grid-column: 2;
  justify-self: end;
  margin: 0;
}

/* ── Definition styling ────────────────────────────────── */
/* English definition text: blue */
#definition .collins_en_cn .caption {
  color: #0b3594;
}

/* Queried word: inherit definition color, bold is enough to distinguish */
#definition .collins_en_cn .caption > b {
  color: inherit;
}

/* Chinese text: black for clear readability */
#definition .chinese-text {
  color: #000;
}

/* Hide duplicate cn_before (same content as cn_after) */
#definition .def_cn.cn_before {
  display: none;
}

#definition .def_cn.cn_after {
  display: inline;
  color: #000;
}

#definition .def_cn.cn_after::before {
  content: '　';
}

/* Examples: light gray */
#definition .example ul {
  color: #999;
  font-style: italic;
}

/* Chinese translation in examples: light gray, matching English */
#definition .example li .chinese-text {
  color: #999;
  font-style: normal;
}

/* Queried word highlight in examples */
#definition .example .text_blue {
  color: #0055a5;
  border-bottom: none;
}

/* ── Cursor: only show pointer on truly clickable areas ── */
/* Reset all inherited pointer cursors from dictionary CSS */
#definition .hide_cn,
#definition .example li {
  cursor: default;
  -webkit-user-select: auto;
  user-select: auto;
}

/* Restore pointer only for actually interactive elements */
#definition a.explain,
#definition .icon-speak-uk,
#definition .icon-speak-us,
#definition .icon-speak-form,
#definition .word-image-small,
#definition .grammarInfo > .caption,
#definition .collins_en_cn.trend > .caption,
#definition .tab_multiwords a,
#definition .word_entry > .pron a {
  cursor: pointer;
}

/* Generic <a> tags without real targets: default cursor */
#definition a[href="#"],
#definition a[href="javascript:void(0)"],
#definition a[href="javascript:;"] {
  cursor: default;
}

/* Pronunciation UK/US labels */
.icon-speak-uk::after {
  content: ' UK';
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.55em;
  font-style: normal;
  color: hsl(0, 100%, 40%);
  vertical-align: middle;
  margin-right: 4px;
}

.icon-speak-us::after {
  content: ' US';
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.55em;
  font-style: normal;
  color: hsl(240, 100%, 30%);
  vertical-align: middle;
  margin-right: 4px;
}

/* Clear button */
#clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  color: #999;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, background 0.15s;
}

#clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

#clear-btn:hover {
  background: #e0e0e0;
  color: #666;
}

#search-input.loading ~ #clear-btn {
  opacity: 0;
  pointer-events: none;
}

/* Loading state */
#search-input.loading {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 50 50'%3E%3Cpath fill='%230088DD' d='M25,5A20,20,0,1,1,5,25' stroke-width='4' stroke='%230088DD' fill='none'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
}
