:root {
  --bg: #1F2023; --raised: #2A2B2F; --line: #3A3B40; --text: #E8E6E1; --muted: #8E8D89;
  --blue: #4BA3E3; --green: #8FD694; --yellow: #F5C66B; --red: #FF6B6B; --magenta: #D78BE5; --cyan: #5FD3D9;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --paper: #F3EEDF; --ink: #2A2B2F; --ink-soft: #66635C;
  --wood: #6b4a2e; --wood-dark: #3f2a19;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); overflow: hidden; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.drawer {
  height: 100%; display: flex; flex-direction: column; gap: 0;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 2px, transparent 2px 9px, rgba(255,255,255,.03) 9px 10px, transparent 10px 23px),
    linear-gradient(180deg, #7a5435, #5c3f27 60%, #4b331f);
}
.front { display: flex; align-items: center; gap: 12px; padding: 10px 12px 8px; }
.plate {
  flex: 1 1 auto; min-width: 0; display: flex; justify-content: center;
}
.plate-text {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 16px; font-size: 13px; letter-spacing: .06em; color: #2b2115;
  background: #F1E9D2; border: 3px solid #c9a24a; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 0 0 1px #8a6a22, 0 2px 3px rgba(0,0,0,.4);
  background-clip: padding-box;
}
.find input {
  width: 9.5em; background: rgba(31,32,35,.85); border: 1px solid #2b1d11; border-radius: 4px; padding: 5px 8px; font-size: 12.5px; color: var(--text);
}
.find input::placeholder { color: var(--muted); }

.tabs { display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; border-radius: 6px 6px 0 0; padding: 5px 10px 4px; font-size: 11.5px; cursor: pointer;
  background: #d9cfb6; color: #3b3326; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.tab:hover { background: #e6ddc6; }
.tab[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: none; }
.tab .n { color: #7c7466; font-weight: 400; margin-left: 4px; }
.tab.none { opacity: .45; }
.tab:focus-visible { outline-offset: -2px; outline-color: #1d5f99; }

.well {
  flex: 1; min-height: 0; margin: 0 12px; padding: 14px 16px 10px; position: relative;
  background: linear-gradient(180deg, #2a1d12, #3a2818); border-radius: 0 0 4px 4px;
  box-shadow: inset 0 6px 10px rgba(0,0,0,.5);
}
.stack { position: relative; height: 100%; }
.stack::before, .stack::after {
  content: ""; position: absolute; left: 10px; right: 10px; height: 100%; background: #e2dac6; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.stack::before { top: -8px; left: 18px; right: 18px; background: #cfc6b0; }
.stack::after { top: -4px; left: 13px; right: 13px; }
.card {
  position: absolute; inset: 0; z-index: 1; background-color: var(--paper); color: var(--ink); border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,.45);
  padding: 14px 18px 30px; display: flex; flex-direction: column; overflow: hidden;
}
.card::before { /* the rod hole */
  content: ""; position: absolute; bottom: 9px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: #3a2818; box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
}
.card.flip-next { animation: flipN .22s ease-out; }
.card.flip-prev { animation: flipP .22s ease-out; }
@keyframes flipN { from { transform: translateY(10px) rotate(.6deg); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes flipP { from { transform: translateY(-10px) rotate(-.6deg); opacity: .4; } to { transform: none; opacity: 1; } }

.head { display: flex; align-items: flex-start; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(210,90,90,.55); }
.nsid { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; overflow-wrap: break-word; margin: 0; font-weight: 400; }
.nsid .pre { color: var(--ink-soft); }
.nsid .leaf { font-weight: 700; }
.stamp {
  flex: none; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border: 1.5px solid currentColor; border-radius: 3px;
  transform: rotate(3deg); margin-top: 1px; font-weight: 700; background: rgba(255,255,255,.35);
}
.t-record { color: #2f7d3a; } .t-query { color: #1f68a8; } .t-procedure { color: #9a3fae; }
.t-object { color: #1f8288; } .t-permission-set { color: #9a6a10; } .t-space { color: #b3412f; } .t-defs, .t-other { color: #66635C; }

.body {
  flex: 1; min-height: 0; overflow-y: auto; margin-top: 8px; padding-right: 4px; scrollbar-width: thin;
  background-image: repeating-linear-gradient(transparent 0 21px, rgba(75,140,200,.24) 21px 22px);
  background-attachment: local;
}
.body:focus-visible { outline-color: #1d5f99; outline-offset: 0; }
.desc { margin: 0; font-family: var(--sans); font-size: 13.5px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.desc.none { color: var(--ink-soft); font-style: italic; }
.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 12px; font-size: 12px; line-height: 22px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts code { font-family: var(--mono); color: #1d4f78; }

.controls { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 10px; flex: none; }
.controls button {
  background: #2a1d12; color: #efe4cc; border: 1px solid #1a110a; border-radius: 4px; padding: 4px 12px; font-size: 12px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.controls button:hover:not(:disabled) { background: #3a2818; }
.controls button:disabled { opacity: .4; cursor: default; }
.pos { font-size: 12px; color: #f0e6cf; text-shadow: 0 1px 1px rgba(0,0,0,.5); text-align: center; }

@media (max-width: 420px) {
  .front { gap: 8px; }
  .find input { width: 7em; }
  .plate-text { padding: 4px 10px; font-size: 12px; }
  .card { padding: 12px 13px 28px; }
  .nsid { font-size: 13.5px; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { line-height: 22px; }
  .facts dd { margin-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { .card.flip-next, .card.flip-prev { animation: none; } }
