/* LinkDrop — shared styles for admin + view pages */

:root {
  --paper: #f5f1e8;
  --card: #fffdf8;
  --ink: #23201a;
  --ink-soft: #6e675c;
  --line: #e2dccd;
  --line-strong: #cfc7b2;
  --accent: #1f5c47;
  --accent-ink: #f2efe6;
  --accent-soft: #e3ede7;
  --danger: #a83c2e;
  --danger-soft: #f4e4e0;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Bricolage Grotesque", "Avenir Next", "Helvetica Neue", sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35, 32, 26, 0.06), 0 4px 14px rgba(35, 32, 26, 0.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 400px at 80% -10%, #efe7d4 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) clamp(14px, 4vw, 32px) calc(56px + env(safe-area-inset-bottom));
}

/* ---------- header ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
  margin-bottom: clamp(18px, 3vw, 28px);
}

.brand {
  font-weight: 800;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -0.02em;
  margin: 0;
}

.brand .tick { color: var(--accent); }

.masthead .sub {
  color: var(--ink-soft);
  font-size: 13px;
  font-family: var(--mono);
}

/* ---------- cards & sections ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 24px);
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card .hint {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.hint code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--accent);
  overflow-wrap: anywhere;
}

/* ---------- forms ---------- */

label.field {
  display: block;
  margin-bottom: 12px;
}

label.field span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  font-family: var(--mono);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 92, 71, 0.15);
}

textarea { resize: vertical; min-height: 110px; }

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

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

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.06s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px) scale(0.99); }

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

.btn-primary:hover { box-shadow: 0 3px 10px rgba(31, 92, 71, 0.3); }

.btn-ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
}

.btn-danger {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-copy {
  min-height: 40px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: #fff;
  white-space: nowrap;
}

.btn-copy.copied {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn[disabled] { opacity: 0.5; cursor: default; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- record cards ---------- */

.record {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line-strong);
  margin-bottom: 10px;
}

.record-link {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.record-link:hover { text-decoration: underline; }

.record-head .actions { display: flex; gap: 8px; }

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.field-row + .field-row { border-top: 1px solid var(--line); }

.field-label {
  flex: 0 0 58px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

.field-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 14px;
  overflow-wrap: anywhere;
  min-width: 0;
}

.field-value.empty { color: var(--line-strong); }

/* editable record fields */
input.field-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 14px;
}

textarea.note-input {
  min-height: 84px;
  font-size: 14px;
}

.btn-save {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 560px) {
  .field-row { flex-wrap: wrap; }
  .field-row .field-label { flex: 1; }
  .field-row input.field-input { order: 3; flex-basis: 100%; }
}

/* access PIN list */
.pin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}

.pin-row + .pin-row { border-top: 1px solid var(--line); }

.pin-row .pin-label {
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.pin-row .pin-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.note-block {
  margin-top: 12px;
}

.note-block .note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.note-text {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #faf7ee;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 72px;
}

/* ---------- states ---------- */

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 16px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
}

.error-msg {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin: 10px 0 0;
}

.skeleton {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #ece6d8 40%, #f5f0e4 50%, #ece6d8 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  margin-bottom: 14px;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: calc(100vw - 32px);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }
