:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #d7dde7;
  --text: #20242d;
  --muted: #667085;
  --accent: #1769e0;
  --accent-soft: #e9f2ff;
  --code-bg: #f0f3f7;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171c;
  --panel: #20242c;
  --border: #3a414d;
  --text: #e8ecf3;
  --muted: #aab3c2;
  --accent: #79aefb;
  --accent-soft: #26364f;
  --code-bg: #11151c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  min-height: 72px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 14px;
}

p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.filters,
.contentHeader,
.dialogActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button,
select,
input {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:not(:disabled).active,
button:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button:disabled {
  cursor: not-allowed;
  color: var(--muted);
}

input,
select {
  padding: 0 10px;
}

.toggle {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
  cursor: pointer;
}

.toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 72px);
}

.sidebar {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

#search {
  width: 100%;
  margin-bottom: 10px;
}

.filters {
  margin-bottom: 10px;
}

.entryList {
  height: calc(100% - 88px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.entry {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  text-align: left;
  background: var(--panel);
  color: var(--text);
}

.entryName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
}

.badge {
  color: var(--muted);
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contentHeader {
  justify-content: space-between;
}

.panes {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 14px;
}

.markdown,
.translationPane {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.markdown {
  padding: 16px 18px;
  line-height: 1.6;
  user-select: text;
}

.markdown h1 {
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 22px;
}

.markdown h1:first-child {
  margin-top: 0;
}

.markdown h2 {
  margin: 18px 0 8px;
  font-size: 18px;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown pre {
  margin: 8px 0;
}

.markdown ul,
.markdown ol {
  padding-left: 24px;
}

.markdown code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.92em;
}

.markdown pre {
  overflow: auto;
  padding: 10px;
  border-radius: 6px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 13px;
}

.markdown pre code {
  padding: 0;
  background: transparent;
}

.translationPane {
  display: flex;
  flex-direction: column;
}

.translationPane h3 {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

textarea {
  flex: 1;
  min-height: 0;
  resize: none;
  border: 0;
  padding: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.settingsForm {
  width: min(520px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
}

.settingsForm label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.settingsForm input {
  width: 100%;
}

.dialogActions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 420px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #20242d;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 920px) {
  .topbar,
  .contentHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout,
  .panes {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .entryList {
    height: 260px;
  }

  .markdown,
  .translationPane {
    min-height: 420px;
  }
}

