:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #191c1f;
  --muted: #647071;
  --panel: #fffdfa;
  --line: #d7d1c8;
  --accent: #176b73;
  --accent-ink: #ffffff;
  --warm: #a94f2b;
  --danger: #b82f36;
  --shadow: 0 18px 48px rgba(31, 42, 43, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 107, 115, 0.12), transparent 42%),
    linear-gradient(225deg, rgba(169, 79, 43, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:hover {
  border-color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.danger {
  border-color: rgba(184, 47, 54, 0.35);
  color: var(--danger);
}

button.ghost {
  background: transparent;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 115, 0.14);
}

.master-password-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.master-password-line button {
  width: 42px;
  padding: 0;
}

.masked-text {
  ime-mode: active;
  -webkit-text-security: disc;
}

.masked-text.revealed {
  -webkit-text-security: none;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 24px;
  align-content: center;
  padding: 28px;
}

.brand-block {
  width: min(520px, 100%);
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 28px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

.brand-block h1,
.topbar h1 {
  font-size: 34px;
  line-height: 1.1;
}

.title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.offline-badge {
  display: none;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(23, 107, 115, 0.35);
  border-radius: 8px;
  background: rgba(23, 107, 115, 0.1);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

body.offline-app .offline-badge {
  display: inline-flex;
}

.brand-block p,
.topbar p,
.message,
.file-name {
  color: var(--muted);
}

.unlock-panel {
  width: min(520px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 14px;
  color: #394142;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.file-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

#vault-file {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.download-row {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.message {
  min-height: 24px;
  margin-top: 14px;
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(25, 28, 31, 0.46);
}

.modal {
  width: min(440px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 22px;
}

.modal > p {
  margin-top: 8px;
  color: var(--muted);
}

.modal .field {
  margin-top: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.modal-actions button {
  min-width: 92px;
  padding: 0 14px;
}

.vault-screen {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.92);
  backdrop-filter: blur(10px);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar button,
.search-box button,
.password-line button {
  width: 42px;
  padding: 0;
}

.toolbar-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.toolbar-link:hover {
  border-color: var(--accent);
}

body.offline-app .offline-download,
body.offline-app .download-row {
  display: none;
}

.security-note {
  min-height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 14px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.35;
}

.workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 330px) 1fr;
}

.list-pane {
  min-height: 0;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.72);
}

.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.entry-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  overflow: auto;
  max-height: calc(100vh - 154px);
}

.entry-card {
  width: 100%;
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 10px 12px;
  text-align: left;
  background: #ffffff;
}

.entry-card.active {
  border-color: var(--accent);
  background: rgba(23, 107, 115, 0.08);
}

.entry-card strong {
  overflow-wrap: anywhere;
}

.entry-card span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty-list {
  padding: 24px 8px;
  color: var(--muted);
  text-align: center;
}

.detail-pane {
  min-width: 0;
  overflow: auto;
  padding: 24px;
}

#entry-form,
.generator {
  max-width: 920px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.generator {
  margin-top: 16px;
}

.form-head,
.generator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-head h2,
.generator-head h2 {
  font-size: 22px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.password-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.form-actions button,
.generator-head button {
  min-width: 108px;
  padding: 0 16px;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(4, auto);
  align-items: end;
  gap: 12px;
}

input[type="range"] {
  padding: 0;
}

.check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  white-space: nowrap;
}

.check input {
  width: 16px;
  height: 16px;
}

@media (max-width: 820px) {
  .workbench {
    grid-template-columns: 1fr;
  }

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

  .entry-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 1fr);
    max-height: none;
    overflow-x: auto;
  }

  .grid,
  .action-row,
  .generator-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .lock-screen,
  .detail-pane {
    padding: 16px;
  }

  .brand-block h1,
  .topbar h1 {
    font-size: 28px;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
  }

  .file-row {
    grid-template-columns: 1fr;
  }
}
