@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500&family=Noto+Sans+SC:wght@300;400;500&display=swap');

:root {
  --bg:        #faf8f4;
  --surface:   #f3efe8;
  --surface2:  #ece7de;
  --border:    #ddd8ce;
  --border2:   #ccc6ba;
  --text:      #2a2520;
  --muted:     #9a9186;
  --hint:      #bdb5a8;
  --accent:    #7a5c3a;
  --accent-lt: #a07c54;
  --danger:    #9b3a3a;
  --radius:    4px;
  --radius-lg: 8px;
  --sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'Noto Serif SC', 'Georgia', serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── page wrapper ───────────────────────────────────────────────────────────── */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ── nav ────────────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}

.logo {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: .5px;
}

.nav-quote {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  letter-spacing: .4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.nav-links {
  display: flex;
  gap: 28px;
}

.nav-links a {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .3px;
  transition: color .2s;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

/* ── quote page ─────────────────────────────────────────────────────────────── */
.quote-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 68vh;
  text-align: center;
  gap: 20px;
}

.quote-mark {
  font-family: var(--serif);
  font-size: 80px;
  line-height: .6;
  color: var(--border2);
  user-select: none;
  margin-bottom: -8px;
}

.quote-text {
  font-family: var(--serif);
  font-size: clamp(20px, 3.2vw, 32px);
  font-weight: 300;
  color: var(--text);
  max-width: 640px;
  line-height: 1.85;
  letter-spacing: .8px;
}

.quote-divider {
  width: 32px;
  height: 1px;
  background: var(--border2);
}

.quote-author {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1.5px;
  font-weight: 300;
}

.quote-empty {
  font-size: 15px;
  color: var(--muted);
}

/* ── login ──────────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65vh;
}

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 40px 0;
}

.login-box h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 32px;
  color: var(--text);
  letter-spacing: .3px;
}

.login-box .error {
  border-left: 2px solid var(--danger);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 20px;
  background: rgba(155,58,58,.06);
}

/* ── form ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 400;
}

input[type=text],
input[type=password],
textarea,
select {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 0;
  outline: none;
  border-radius: 0;
  transition: border-color .2s;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-bottom-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 88px;
  padding: 8px 0;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%239a9186' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 20px;
}

/* ── buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 20px;
  font-size: 12px;
  font-family: var(--sans);
  letter-spacing: .8px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-transform: uppercase;
  transition: all .2s;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #faf8f4;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-lt); border-color: var(--accent-lt); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border2); background: var(--surface); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(155,58,58,.3);
}
.btn-danger:hover { background: rgba(155,58,58,.06); }

.btn-sm { padding: 5px 14px; font-size: 11px; }

.calc-panel {
  position: fixed;
  bottom: 56px;
  left: 20px;
  width: 300px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(42,37,32,.12);
  padding: 18px 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.calc-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}
.calc-mnemonic {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-word;
}
.calc-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border2);
  padding: 4px 0;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.calc-input:focus { border-bottom-color: var(--accent); }
.calc-output-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.calc-output {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
}
.calc-copy {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 1px;
  line-height: 1;
}
.calc-copy:hover { color: var(--accent); }

.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }

.confirm-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(42,37,32,.12);
  padding: 24px 28px;
  text-align: center;
}
.confirm-msg {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 18px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.inline-input, .inline-select {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 4px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.inline-input:focus, .inline-select:focus {
  outline: none;
}
.inline-select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* ── page title ─────────────────────────────────────────────────────────────── */
.page-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .4px;
  color: var(--text);
  margin-bottom: 32px;
}

/* ── search bar ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 24px;
  margin-bottom: 36px;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.search-bar .form-group {
  margin-bottom: 0;
  flex: 1;
}

/* ── table ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .3px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface); }

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

/* ── owner tag ──────────────────────────────────────────────────────────────── */
.owner-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: .3px;
}

/* ── password cell ──────────────────────────────────────────────────────────── */
.pw-cell { display: flex; align-items: center; gap: 8px; }

.pw-text {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: .5px;
}

.pw-toggle {
  background: none;
  border: none;
  color: var(--hint);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: var(--radius);
  transition: color .15s;
  font-family: var(--sans);
}
.pw-toggle:hover { color: var(--muted); background: var(--surface2); }

/* ── section & admin ────────────────────────────────────────────────────────── */
.section { margin-bottom: 64px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .3px;
}

/* ── tab bar ────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.tab {
  padding: 10px 0;
  margin-right: 32px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  letter-spacing: .3px;
  transition: color .2s;
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

/* ── add panel ──────────────────────────────────────────────────────────────── */
.add-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 32px;
  display: none;
}

.add-panel.open { display: block; }

.add-panel .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0 32px;
}

.add-panel .form-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
}

/* ── edit page ──────────────────────────────────────────────────────────────── */
.edit-wrap {
  max-width: 540px;
  padding: 0 0 64px;
}

.edit-wrap h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 36px;
  letter-spacing: .3px;
}

.form-actions { display: flex; gap: 12px; margin-top: 32px; }

/* ── table filter row ───────────────────────────────────────────────────────── */
.filter-row input,
.filter-row select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .3px;
  padding: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.filter-row input { cursor: text; text-align: left; }
.filter-row input::placeholder { color: var(--hint); font-size: 13px; }
.filter-row input:focus,
.filter-row select:focus { color: var(--text); }

/* ── custom select ──────────────────────────────────────────────────────────── */
.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
}

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  padding: 0;
  outline: none;
}

.cs-trigger svg { color: var(--hint); flex-shrink: 0; transition: transform .15s; }
.custom-select.open .cs-trigger svg { transform: rotate(180deg); }

.cs-list {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(42,37,32,.09);
  min-width: 110px;
  list-style: none;
  padding: 6px 0;
  z-index: 9999;
  display: none;
}

.cs-list.visible { display: block; }

.cs-item {
  padding: 9px 18px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: background .12s;
  white-space: nowrap;
}

.cs-item:hover { background: var(--surface); }
.cs-item.active { color: var(--accent); }
.cs-item:first-child { color: var(--hint); }

.note-cell { color: var(--muted); font-size: 13px; max-width: 240px; }

#pw-table th:nth-child(2),
#pw-table td:nth-child(2) { width: 100px; }

/* ── empty state ────────────────────────────────────────────────────────────── */
.empty {
  color: var(--hint);
  font-size: 13.5px;
  padding: 32px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ── footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 16px 0 20px;
  z-index: 50;
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 2px;
}

.bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--hint);
  background: none;
  border: none;
  cursor: pointer;
  transition: color .15s, background .15s;
  text-decoration: none !important;
}

.bar-btn:hover {
  color: var(--accent);
  background: var(--surface2);
}

/* ── modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42,37,32,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  z-index: 100;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  width: 300px;
  transform: translateY(8px);
  transition: transform .2s;
}

.modal-overlay.open .modal-box {
  transform: translateY(0);
}

.modal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(250,248,244,.92);
  border-radius: 10px;
  padding: 10px 10px 10px 18px;
}

.modal-input {
  flex: 1;
  background: transparent;
  border: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  padding: 0;
  outline: none;
  letter-spacing: 3px;
  min-width: 0;
  caret-color: var(--accent);
  text-decoration: none;
}

.modal-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent);
  border: none;
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}

.modal-btn:hover { background: var(--accent-lt); }

.modal-shake {
  text-align: center;
  font-size: 12px;
  color: var(--danger);
  min-height: 18px;
  margin-top: 8px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.shake { animation: shake .4s ease; }

/* ── responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page { padding: 0 20px; }
  nav { padding: 20px 0 18px; margin-bottom: 40px; }
  .add-panel .form-row { grid-template-columns: 1fr; }
  .search-bar { flex-direction: column; gap: 0; }
}
