/* ============================================================
   passvault · 黄铜金库
   ============================================================ */

:root {
  --ink:      #09090B;
  --ink-soft: #0E0F12;
  --panel:    #13151A;
  --panel-hi: #191C22;
  --panel-lo: #0B0C0F;

  --line:     rgba(201, 169, 97, 0.18);
  --line-2:   rgba(255, 255, 255, 0.065);
  --line-3:   rgba(255, 255, 255, 0.03);

  --brass:    #C9A961;
  --brass-hi: #EFD79A;
  --brass-lo: #8A7440;

  --mint:     #6FCF97;
  --danger:   #E25850;
  --warn:     #E0A33C;

  --fg:       #EDE8DC;
  --fg-dim:   #8C8A83;
  --fg-mute:  #5C5B56;

  --serif: Georgia, 'Songti SC', 'STSong', 'Noto Serif CJK SC', 'Source Han Serif SC', serif;
  --sans:  'Segoe UI Variable Text', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --mono:  'Cascadia Mono', ui-monospace, 'SF Mono', Consolas, 'Courier New', monospace;

  --r: 3px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* 纸纹颗粒 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 顶部黄铜光晕 */
body::after {
  content: '';
  position: fixed;
  top: -30vh;
  left: 50%;
  width: 120vw;
  height: 70vh;
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(201, 169, 97, 0.07), transparent 62%);
  z-index: 0;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

::selection { background: rgba(201, 169, 97, 0.3); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: rgba(201,169,97,0.25) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(201,169,97,0.22); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(201,169,97,0.4); }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   锁屏
   ============================================================ */

#lockView {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock-inner {
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: rise .9s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* 表盘 */
.dial {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 0 auto 34px;
}

.dial svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dial .ring-outer {
  transition: transform 1.1s var(--ease);
  transform-origin: 84px 84px;
}

.dial .ring-inner {
  transition: transform 1.4s var(--ease);
  transform-origin: 84px 84px;
}

.dial.is-spin .ring-outer { transform: rotate(216deg); }
.dial.is-spin .ring-inner { transform: rotate(-144deg); }

.dial .tick      { stroke: rgba(201,169,97,0.34); stroke-width: 1; }
.dial .tick-major{ stroke: var(--brass); stroke-width: 1.6; }
.dial .hub       { fill: none; stroke: rgba(201,169,97,0.28); stroke-width: 1; }

.dial .keyhole {
  fill: none;
  stroke: var(--brass);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dial::after {
  content: '';
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,169,97,0.13), transparent 58%);
  pointer-events: none;
}

.wordmark {
  font-family: var(--serif);
  font-size: 33px;
  font-weight: 400;
  letter-spacing: 0.09em;
  margin: 0 0 8px;
  color: var(--fg);
}

.wordmark em {
  font-style: normal;
  color: var(--brass);
}

.tagline {
  margin: 0 0 30px;
  font-size: 11.5px;
  letter-spacing: 0.22em;
  color: var(--fg-mute);
  text-transform: uppercase;
}

/* 输入组 */
.field {
  position: relative;
  margin-bottom: 12px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--fg-mute);
  margin-bottom: 7px;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--panel-lo);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 11px 13px;
  color: var(--fg);
  transition: border-color .18s, background .18s;
}

.field input[type='password'],
.field input.mono {
  font-family: var(--mono);
  letter-spacing: 0.14em;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(201,169,97,0.55);
  background: #000;
}

.field input::placeholder { color: var(--fg-mute); letter-spacing: 0.04em; }

.field textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  min-height: 84px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: transparent;
  color: var(--fg);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
  white-space: nowrap;
}

.btn:hover { background: rgba(201,169,97,0.08); border-color: rgba(201,169,97,0.45); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%;
  background: var(--brass);
  border-color: var(--brass);
  color: #14120A;
  font-weight: 600;
  letter-spacing: 0.16em;
  padding: 12px 18px;
}

.btn-primary:hover { background: var(--brass-hi); border-color: var(--brass-hi); }

.btn-ghost {
  border-color: transparent;
  color: var(--fg-dim);
  padding: 7px 11px;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.btn-ghost:hover { color: var(--brass); background: rgba(201,169,97,0.07); }

.btn-danger { color: var(--danger); border-color: rgba(226,88,80,0.35); }
.btn-danger:hover { background: rgba(226,88,80,0.1); border-color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 11.5px; }

.hint {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 0.03em;
}

.hint.err { color: var(--danger); }
.hint.ok  { color: var(--mint); }

.lock-foot {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line-3);
  font-size: 11px;
  color: var(--fg-mute);
  line-height: 1.85;
}

.lock-foot b { color: var(--fg-dim); font-weight: 500; }

/* ============================================================
   主界面
   ============================================================ */

#vaultView {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: fadeIn .45s var(--ease) both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  height: 58px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(25,28,34,0.75), rgba(9,9,11,0.4));
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.brand .mark {
  width: 9px;
  height: 9px;
  background: var(--brass);
  border-radius: 1px;
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(201,169,97,0.65);
}

.rev {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border: 1px solid var(--line-3);
  border-radius: 2px;
}

.search-wrap {
  flex: 1 1 auto;
  max-width: 460px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  background: var(--panel-lo);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 8px 12px 8px 32px;
  color: var(--fg);
  font-size: 13px;
}

.search-wrap input:focus {
  outline: none;
  border-color: rgba(201,169,97,0.45);
}

.search-wrap input::placeholder { color: var(--fg-mute); }

.search-wrap .ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-mute);
  pointer-events: none;
  font-size: 13px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.body-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 186px minmax(280px, 360px) 1fr;
  min-height: 0;
}

/* --- 左：分组 --- */
.rail {
  border-right: 1px solid var(--line-2);
  padding: 16px 0 24px;
  overflow-y: auto;
  background: var(--panel-lo);
}

.rail-title {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-mute);
  text-transform: uppercase;
  padding: 0 16px;
  margin-bottom: 10px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 16px;
  text-align: left;
  border-left: 2px solid transparent;
  color: var(--fg-dim);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  transition: color .15s, background .15s, border-color .15s;
}

.rail-item:hover { color: var(--fg); background: rgba(255,255,255,0.025); }

.rail-item.active {
  color: var(--brass);
  border-left-color: var(--brass);
  background: rgba(201,169,97,0.055);
}

.rail-item .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: currentColor;
  opacity: 0.7;
}

.rail-item .n {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-mute);
}

.rail-item.active .n { color: var(--brass-lo); }

.rail-sep {
  height: 1px;
  background: var(--line-3);
  margin: 12px 16px;
}

/* --- 中：条目列表 --- */
.list {
  border-right: 1px solid var(--line-2);
  overflow-y: auto;
  min-height: 0;
}

.list-empty {
  padding: 46px 24px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 12.5px;
  line-height: 2;
}

.list-empty .big {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--fg-dim);
  display: block;
  margin-bottom: 6px;
}

.row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-3);
  border-left: 2px solid transparent;
  transition: background .14s, border-color .14s;
  animation: rowIn .34s var(--ease) both;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: none; }
}

.row:hover { background: rgba(255,255,255,0.028); }

.row.active {
  background: rgba(201,169,97,0.07);
  border-left-color: var(--brass);
}

.row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.row-title {
  font-family: var(--serif);
  font-size: 14.5px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row.active .row-title { color: var(--brass-hi); }

.row-grp {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--fg-mute);
  border: 1px solid var(--line-3);
  border-radius: 2px;
  padding: 1px 5px;
  text-transform: uppercase;
}

.row-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

/* --- 右：详情 --- */
.detail {
  overflow-y: auto;
  padding: 30px 34px 60px;
  min-height: 0;
  background: radial-gradient(120% 70% at 100% 0%, rgba(201,169,97,0.045), transparent 55%);
}

.detail-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--fg-mute);
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-align: center;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.detail-title {
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1.25;
  margin: 0 0 5px;
  word-break: break-word;
}

.detail-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-mute);
  letter-spacing: 0.06em;
}

.detail-tools {
  margin-left: auto;
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-3);
}

.kv-k {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg-mute);
  text-transform: uppercase;
  padding-top: 4px;
}

.kv-v {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.kv-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  word-break: break-all;
  line-height: 1.65;
  flex: 1 1 auto;
  min-width: 0;
}

.kv-val.masked { letter-spacing: 0.28em; color: var(--fg-dim); }

.kv-val.pre {
  white-space: pre-wrap;
  font-size: 12px;
  background: var(--panel-lo);
  border: 1px solid var(--line-3);
  border-radius: var(--r);
  padding: 11px 13px;
  max-height: 340px;
  overflow: auto;
}

.kv-acts { display: flex; gap: 2px; flex: 0 0 auto; }

.icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  color: var(--fg-mute);
  border: 1px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  font-size: 12px;
}

.icon-btn:hover {
  color: var(--brass);
  background: rgba(201,169,97,0.09);
  border-color: var(--line);
}

.kv-link {
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px solid rgba(201,169,97,0.3);
  word-break: break-all;
}

.kv-link:hover { border-bottom-color: var(--brass); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 2px 7px;
}

/* --- Toast --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 14px);
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 18px;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--fg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 10000;
  white-space: nowrap;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(226,88,80,0.5); color: #FFB4AE; }

/* --- 弹窗 --- */
dialog {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  box-shadow: 0 30px 90px rgba(0,0,0,0.85);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(4,4,6,0.72);
  backdrop-filter: blur(3px);
}

.dlg-head {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.07em;
}

.dlg-head .x { margin-left: auto; }

.dlg-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.dlg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-2);
  background: var(--panel-lo);
}

.dlg-foot .spacer { margin-left: auto; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1 1 auto; }

.back-btn { display: none; }

/* 移动端 */
@media (max-width: 880px) {
  .body-grid { grid-template-columns: 1fr; }

  .rail {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line-2);
  }

  .rail-title, .rail-sep { display: none; }

  .rail-item {
    width: auto;
    flex: 0 0 auto;
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 5px 11px;
    border-radius: 2px;
    white-space: nowrap;
  }

  .rail-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--brass);
  }

  .list { border-right: none; }

  .detail {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: var(--ink);
    padding: 20px 18px 80px;
    display: none;
  }

  .detail.show { display: block; }
  .back-btn { display: grid; }

  .topbar { gap: 10px; padding: 0 12px; }
  .brand span.brand-text { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 78px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
