:root{
  --bg: #2b2b2b;
  --header: #000000;
  --dropdown: #000000;
  --text: #ffffff;
  --muted: #d0d0d0;
  --border: #1f1f1f;
  --panel: #1c1c1c;
  --good: #2bad68;
  --bad: #a0655d;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

header{
  background: var(--header);
  color: var(--text);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
}

.brand{ font-weight: 700; letter-spacing: 0.2px; }

.actions{ display: flex; align-items: center; gap: 10px; }

.menu-btn{
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
}

.menu-btn:focus{ outline: 2px solid #444; outline-offset: 2px; }

.bars{ width: 22px; height: 14px; display: grid; gap: 4px; }
.bars span{ display: block; height: 2px; background: var(--text); width: 100%; }

.account-dot{
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  background: var(--bad);
  border: 1px solid #2a2a2a;
}
.account-dot.logged-in{ background: var(--good); }

.dropdown{
  position: absolute;
  top: 56px;
  right: 0;
  width: 100%;
  background: var(--dropdown);
  display: none;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  z-index: 10;
}

.dropdown.open{ display: block; }

.dropdown a{
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 4px;
  text-align: right;
}

.dropdown a:hover{ color: var(--text); }

main{ padding: 32px 20px; }

h1, h2{ margin: 0 0 12px; }

.muted{ color: var(--muted); }

.panel{
  width: min(1100px, 100%);
  margin: 0 auto;
  min-width: 0;
}

.card{
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  min-width: 0;
}

.row{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form{ display: grid; gap: 12px; }

label{ font-size: 14px; color: var(--muted); }

input, select, textarea{
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  background: #141414;
  color: var(--text);
}

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

.field-inline > *{
  min-width: 0;
}

.field-prefix{
  padding: 12px 10px;
  border: 1px solid var(--border);
  background: #141414;
  color: var(--muted);
  white-space: nowrap;
}

.field-input{
  flex: 1 1 auto;
  min-width: 0;
}

.toggle-btn{
  white-space: nowrap;
  padding: 12px 10px;
}

button, .btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid #3a3a3a;
  background: #1a1a1a;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

button:disabled{ opacity: 0.5; cursor: not-allowed; }

.notice{ border: 1px solid #2f5c46; background: #15241c; padding: 10px 12px; }
.error{ border: 1px solid #5c2f2f; background: #241515; padding: 10px 12px; }

.criteria{ margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.criteria li{ margin: 4px 0; }
.criteria .ok{ color: var(--good); }
.criteria .bad{ color: var(--bad); }

.inline-status{ font-size: 13px; margin-top: 6px; }
.inline-status.ok{ color: var(--good); }
.inline-status.bad{ color: var(--bad); }
.tx-type{ font-weight: 600; text-transform: lowercase; }
.tx-incoming{ color: var(--good); }
.tx-outgoing{ color: var(--bad); }
.tx-internal{ color: #a6a6a6; }
.tx-party{
  white-space: nowrap;
}
.wallet-status-active{
  color: var(--good);
  font-weight: 600;
}
.wallet-status-frozen{
  color: #9fb9d6;
  font-weight: 600;
}

.table-wrap{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table{ width: 100%; border-collapse: collapse; }
.table th, .table td{ text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }

.uid-text{
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  word-break: normal;
  overflow-wrap: normal;
}

/* Keep iOS/auto-detected numeric links from turning blue */
a[x-apple-data-detectors],
a[href^="x-apple-data-detectors:"],
a[href^="tel:"],
a[href^="sms:"],
a[href^="mailto:"]{
  color: inherit !important;
  text-decoration: inherit !important;
  font: inherit !important;
}

.wiki-shell{
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
}

.wiki-side{
  border: 1px solid var(--border);
  background: #1a1a1a;
  padding: 14px;
  align-self: start;
}

.wiki-side h2,
.wiki-side h3{
  margin: 0 0 10px;
  font-size: 17px;
}

.wiki-side code{
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  margin-top: 4px;
}

.wiki-main{
  min-width: 0;
}

.wiki-article{
  border: 1px solid var(--border);
  background: #181818;
  padding: 18px;
}

.wiki-article h1{
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 600;
  font-size: 32px;
}

.wiki-article h2,
.wiki-article h3,
.wiki-article h4{
  margin: 22px 0 10px;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 600;
}

.wiki-article p{
  margin: 0 0 12px;
  line-height: 1.6;
}

.wiki-data-table{
  min-width: 520px;
}

.wiki-data-table th,
.wiki-data-table td{
  white-space: nowrap;
}

.wiki-code-block{
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border);
  background: #0f0f0f;
  overflow-x: auto;
}

.wiki-code-block code{
  display: block;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: #d7d7d7;
  font-size: 13px;
}

.wiki-link{
  color: #90b8ff;
  text-decoration: none;
}

.wiki-link:hover{
  color: #b1cdff;
  text-decoration: underline;
}

.wiki-search{
  display: flex;
  gap: 8px;
}

.wiki-search input{
  flex: 1 1 auto;
}

.wiki-toc{
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.wiki-toc li{
  margin: 6px 0;
}

.wiki-toc li.depth-2{
  margin-left: 12px;
}

.wiki-toc li.depth-3{
  margin-left: 24px;
}

.wiki-hr{
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.wiki-image-embed{
  border: 1px solid var(--border);
  background: #141414;
  margin: 14px 0;
  overflow: hidden;
  width: 100%;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

.wiki-image-header{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.wiki-image-title{
  display: inline-block;
  font-weight: 600;
}

.wiki-image-embed{
  margin-left: 0;
  margin-right: 0;
}

.wiki-image-body{
  background: #0f0f0f;
}

.wiki-image-frame{
  width: 100%;
  min-height: 240px;
  height: 360px;
  max-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}

.wiki-image-frame img{
  width: auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.wiki-image-embed figcaption{
  padding: 10px 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.wiki-editor-layout{
  max-width: 1080px;
}

.wiki-side-rail{
  position: fixed;
  right: 12px;
  top: 130px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.wiki-rail-btn{
  width: 88px;
}

.wiki-overlay-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 60;
}

.wiki-drawer{
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: #121212;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 180ms ease-out;
  z-index: 70;
  display: grid;
  grid-template-rows: auto 1fr;
}

.wiki-drawer.open{
  transform: translateX(0);
}

.wiki-drawer-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.wiki-drawer-head h2{
  margin: 0;
}

.wiki-drawer-close{
  padding: 8px 12px;
}

.wiki-drawer-body{
  padding: 12px;
  overflow-y: auto;
}

.wiki-asset-list{
  display: grid;
  gap: 8px;
}

.wiki-asset-row{
  border: 1px solid var(--border);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.wiki-asset-meta{
  min-width: 0;
}

.wiki-asset-meta > div:first-child{
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wiki-asset-actions{
  display: flex;
  gap: 8px;
}

.wiki-mini-btn{
  padding: 8px 12px;
}

@media (max-width: 700px){
  header{ padding: 0 10px; }
  .brand{
    max-width: calc(100% - 96px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  main{ padding: 20px 12px; }
  .row{ grid-template-columns: 1fr; }
  .table{ min-width: 620px; }
  .dropdown{ padding: 10px 12px; }
  .wiki-shell{ grid-template-columns: 1fr; }
  .wiki-side{ order: 2; }
  .wiki-main{ order: 1; }
  .wiki-side-rail{
    right: 10px;
    top: 96px;
  }
  .wiki-rail-btn{
    width: 88px;
  }
  .wiki-image-frame{
    min-height: 180px;
    height: 260px;
    max-height: 260px;
  }
}

@media (max-width: 420px){
  button, .btn{ padding: 10px 12px; }
  .table{ min-width: 560px; }
}
