/* 主题与基础样式 */
:root {
  --paper: #f8f9f6;
  --ink: #233c34;
  --muted: #77817a;
  --green: #176452;
  --line: #e1e7df;
  --wash: #eff4ed;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    'PingFang SC',
    'Microsoft YaHei',
    sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #70b6a0;
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
[hidden] {
  display: none !important;
}

/* 页头与布局 */
.header {
  max-width: 1240px;
  margin: auto;
  padding: 29px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 24px;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.7px;
}
.brand-mark {
  background: var(--green);
  color: white;
  border-radius: 9px;
  width: 35px;
  height: 37px;
  display: grid;
  place-content: center;
  font-family: Georgia, serif;
  position: relative;
  font-size: 28px;
}
.brand-mark span {
  position: absolute;
  font-size: 13px;
  right: 3px;
  top: 2px;
}
.brand-caption {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 2px;
  margin-left: 8px;
  color: var(--muted);
  border-left: 1px solid #d8dfd5;
  padding-left: 17px;
}
.layout {
  max-width: 1240px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 64px;
  margin: auto;
  padding: 24px 48px 80px;
  min-height: calc(100vh - 172px);
}
.intro {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 32px;
}

/* 搜索与联想 */
#search-form {
  position: relative;
  z-index: 3;
}
.search-wrap {
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid #cbd6ca;
  border-radius: 10px;
  padding: 7px;
  box-shadow: 0 6px 22px #263c3110;
  transition: box-shadow 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px #17645212;
}
.search-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  height: 40px;
  color: #5c786a;
}
input {
  min-width: 0;
  flex: 1;
  width: 100%;
  font-size: 17px;
  border: 0;
  outline: 0;
  padding: 10px 3px;
  color: var(--ink);
  background: transparent;
}
input::placeholder {
  font-size: 14px;
  color: #9ba59c;
}
.search-button {
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  white-space: nowrap;
  padding: 13px 20px;
  font-size: 14px;
}
.search-button:hover {
  background: #0e5343;
}
.search-button span {
  padding-left: 15px;
}
.search-tip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 14px 1px 30px;
  font-size: 11px;
  color: var(--muted);
}
.search-tip button {
  font-size: 11px;
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0 0 0 10px;
  color: #69816d;
}
.keyboard-tip {
  font-size: 10px;
  white-space: nowrap;
}
#suggestions {
  position: absolute;
  margin: 7px 0 0;
  padding: 6px;
  left: 0;
  right: 0;
  max-height: 340px;
  overflow: auto;
  list-style: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 16px 28px #233c3418;
}
#suggestions li {
  padding: 10px 13px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
#suggestions li::after {
  content: '↵';
  color: #a5b3a8;
}
#suggestions li:hover,
#suggestions li[aria-selected='true'] {
  background: var(--wash);
  color: var(--green);
}

/* 提示与空状态 */
.notice {
  margin: 0 0 15px;
  font-size: 13px;
  line-height: 1.7;
  background: var(--wash);
  padding: 11px 15px;
  border-radius: 7px;
  color: #4c7461;
}
.notice.error {
  background: #faf0e9;
  color: #9a5037;
}
.empty-state {
  border: 1px dashed #d7e0d3;
  display: flex;
  align-items: center;
  gap: 22px;
  border-radius: 10px;
  padding: 40px 27px;
  color: #81917f;
}
.empty-icon {
  font-family: Georgia, serif;
  font-size: 42px;
  color: #9ead99;
}
.empty-state h2 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 500;
}
.empty-state p {
  font-size: 12px;
  margin: 0;
  line-height: 1.8;
}

/* 词条释义 */
.entry {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0 0 18px;
  overflow: hidden;
}
.entry-head {
  padding: 27px 28px 22px;
  border-bottom: 1px solid var(--line);
}
.entry-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 37px;
  line-height: 1.2;
  margin: 0 0 9px;
  overflow-wrap: anywhere;
  font-weight: 500;
}
.phonetic {
  color: #819181;
  font-size: 14px;
}
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 15px;
}
.badge {
  font-size: 10px;
  font-weight: 500;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--wash);
  color: #53775d;
}
.badge.star {
  background: #f8f3df;
  color: #96752e;
}
.entry-body {
  padding: 24px 28px;
}
.section-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #8c9b8a;
  font-weight: 600;
  margin: 0 0 11px;
}
.meaning {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.english {
  margin-top: 24px;
}
.english .meaning {
  font-family: Georgia, 'Times New Roman', serif;
  color: #586b5c;
  font-size: 16px;
  line-height: 1.8;
}
.forms {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 21px;
}
.form-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.form-item {
  font-size: 12px;
  background: var(--paper);
  border-radius: 5px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.form-item span {
  color: #8d998b;
  font-size: 10px;
}
.word-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--green);
  border-bottom: 1px solid #b4ccbd;
}
.frequency {
  font-size: 10px;
  color: #8e9a8a;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 23px;
}

/* 最近查词 */
.sidebar {
  padding-top: 16px;
}
.side-section {
  margin-bottom: 40px;
}
.side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 19px;
}
.side-heading h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 0;
}
.side-heading button {
  border: 0;
  background: none;
  color: #9aa696;
  font-size: 10px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-family: Georgia, serif;
  font-size: 16px;
  overflow-wrap: anywhere;
  gap: 8px;
}
.history-item::after {
  content: '↗';
  font-family: system-ui;
  color: #9daf9b;
  font-size: 12px;
}
.history-item:hover {
  color: var(--green);
}
.history-empty {
  font-size: 12px;
  color: #9da797;
  line-height: 1.8;
}

/* 页脚与辅助样式 */
footer {
  max-width: 1144px;
  margin: auto;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #99a591;
}
footer span:first-child {
  font-size: 12px;
  font-weight: 650;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.loading {
  padding: 35px 0;
  color: var(--muted);
  font-size: 14px;
}
.retry {
  padding: 9px 17px;
  border: 1px solid #b8cdbd;
  background: white;
  border-radius: 5px;
  margin-top: 14px;
  color: var(--green);
}

/* 响应式布局 */
@media (max-width: 900px) {
  .layout {
    gap: 30px;
    padding-left: 25px;
    padding-right: 25px;
    grid-template-columns: minmax(0, 1fr) 210px;
  }
  .header {
    padding-left: 25px;
    padding-right: 25px;
  }
  .keyboard-tip {
    display: none;
  }
  footer {
    margin: 0 25px;
  }
}
@media (max-width: 680px) {
  .header {
    padding: 20px;
  }
  .brand-caption {
    display: none;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 28px;
    padding: 20px 20px 45px;
  }
  .intro {
    font-size: 12px;
    margin-bottom: 26px;
  }
  .search-button {
    padding: 12px 14px;
  }
  .search-button span {
    padding-left: 7px;
  }
  .search-tip {
    margin-bottom: 24px;
  }
  .entry-head {
    padding: 22px;
  }
  .entry-body {
    padding: 22px;
  }
  .entry-title {
    font-size: 33px;
  }
  .meaning {
    font-size: 15px;
  }
  .sidebar {
    padding-top: 0;
  }
  .side-section {
    margin-bottom: 0;
  }
  .empty-state {
    padding: 30px 20px;
    gap: 15px;
  }
  .empty-icon {
    font-size: 35px;
  }
  .empty-state p {
    font-size: 11px;
  }
  footer {
    margin: 0 20px;
    font-size: 9px;
  }
  .search-icon {
    flex-basis: 32px;
  }
}
