:root{
  --bg:#0b0f12; --card:#0f1518; --muted:#9aa4a6; --accent:#6ee7b7; --panel:#0c1113; --text:#e6f1ef;
}
*{box-sizing:border-box}
body{margin:0;font-family:Inter,system-ui,Segoe UI,Roboto,Helvetica,Arial,'Apple Color Emoji','Segoe UI Emoji';background:linear-gradient(180deg,#071011 0%, #071620 100%);color:var(--text);min-height:97.9vh}
.app{display:grid;grid-template-columns:420px 1fr;grid-template-rows:auto 1fr;grid-template-areas:"header header" "left right";gap:20px;max-width:1200px;margin:20px auto;padding:20px;width:calc(100% - 40px)}
.pane{min-width:0}
.pane h2{margin-top:0;margin-bottom:12px}
.left{grid-area:left}
.right{grid-area:right}
.card{background:var(--card);padding:14px;border-radius:8px;margin-bottom:16px;box-shadow:0 4px 20px rgba(2,6,8,0.6)}
.app-header{grid-area:header;align-self:start}
.app-header h1{font-size:28px;margin:0;padding-bottom:8px;text-align:center}
.dropzone{
    border:2px dashed rgba(255,255,255,.08);
    border-radius:6px;
    padding:20px;
    text-align:center;
    color:var(--muted);
    cursor: pointer;

    transition:
        border-color .18s ease,
        background-color .18s ease,
        transform .18s ease,
        box-shadow .18s ease;
}

.dropzone.hover{
    border-color:var(--accent);
    background:rgba(110,229,255,.06);
    box-shadow:0 0 0 3px rgba(110,229,255,.12);
    transform:scale(1.01);
}
.meta{margin-top:8px;color:var(--muted);font-size:13px}
.row{display:flex;align-items:center;gap:8px;margin-top:8px}
.row.small{font-size:13px}
input[type=text],input[type=number],select{background:transparent;border:1px solid rgba(255,255,255,0.06);padding:6px;border-radius:6px;color:var(--text)}
label{font-size:14px}
.book-wrap{position:relative;margin-top:12px}
.book-canvas{display:flex;justify-content:center}
.blit{position:relative;overflow:hidden;display:block}
#bookCanvas{position:absolute;left:0;top:0;display:block}
.book-text{position:absolute;white-space:pre-wrap;font-family: 'Minecraftia', monospace, ui-monospace;line-height:1.1;font-size:8px;color:#0b1311;background:transparent;padding:0;margin:0;overflow:hidden}
.book-text.left{left:36px;top:30px;width:114px;height:128px;padding:0 6px}
.book-text.right{left:162px;top:30px;width:114px;height:128px;padding:0 6px}
.page-labels{display:flex;justify-content:center;gap:220px;margin-top:6px;color:var(--muted);font-size:13px}
.preview-stats{display:flex;gap:18px;margin-top:8px;color:var(--muted)}
.card input, .card select, .card button { font-family: inherit }

/* Themed form controls */
input[type=text], input[type=number], textarea, select {
  background:#0b1314;
  border:1px solid rgba(255,255,255,0.06);
  color:var(--text);
  padding:8px 10px;
  border-radius:8px;
  outline: none;
}
input[type=text]:focus, input[type=number]:focus, textarea:focus, select:focus {
  box-shadow:0 0 0 3px rgba(110,231,183,0.08);
  border-color:rgba(110,231,183,0.25);
}
input[type=checkbox] {
  accent-color: var(--accent);
  width:16px; height:16px;
}
select { appearance:none; -webkit-appearance:none; background-image:linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%); background-position: calc(100% - 14px) calc(1em + 2px), calc(100% - 9px) calc(1em + 2px); background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right:28px }

/* optional Minecraft font if bundled in assets/ */
@font-face{
  font-family: 'Minecraftia';
  src: url('./assets/minecraftia-webfont.woff') format('woff');
  font-display:swap;
}
.preview-controls{display:flex;justify-content:space-between;align-items:center}
.nav{display:flex;gap:8px;align-items:center}
button{background:#0b2320;border:1px solid rgba(255,255,255,0.04);color:var(--text);padding:8px 10px;border-radius:6px}
button:disabled{opacity:.45;cursor:not-allowed;}
#browseBtn{cursor:pointer}
.json-block{background:#081214;border-radius:6px;padding:8px;margin-top:8px;max-height:320px;overflow:auto}
.book-wrap{position:relative;margin-top:12px}
.book-canvas{display:flex;justify-content:center}
.blit{position:relative;overflow:hidden;display:block}
.book-text{position:absolute;white-space:pre-wrap;font-family: 'Minecraftia', monospace, ui-monospace;line-height:1.1;font-size:8px;color:#0b1311;background:transparent;padding:0;margin:0}
.book-text.left{left:36px;top:30px;width:114px;height:128px;padding:0 6px}
.book-text.right{left:162px;top:30px;width:114px;height:128px;padding:0 6px}
.page-labels{display:flex;justify-content:center;gap:220px;margin-top:6px;color:var(--muted);font-size:13px}
.preview-stats{display:flex;gap:18px;margin-top:8px;color:var(--muted)}

@media(max-width:900px){
  .app{grid-template-columns:1fr;grid-template-rows:auto auto auto;grid-template-areas:"header" "left" "right";padding:12px}
  .page-labels{gap:60px}
  .preview-stats{flex-direction:column}
  .book-wrap{height:300px}
  .book-text{font-size:11px}
}

.editor-modal{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.6);
    backdrop-filter:blur(3px);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:9999;
}

.editor-modal[hidden]{
    display:none;
}

.editor-window{
    width:min(1000px,95vw);
    height:min(800px,92vh);
    background:var(--card);
    border-radius:10px;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    box-shadow:0 15px 60px rgba(0,0,0,.6);
}

.editor-add-popup{
    position:absolute;
    inset:0;
    display:flex;
    align-items:flex-start;
    justify-content:center;
    padding:20px;
    background:rgba(0,0,0,.45);
    z-index:5;
}

.editor-add-popup[hidden]{
    display:none;
}

.editor-add-card{
    width:min(520px,100%);
    background:#0f1518;
    border:1px solid rgba(255,255,255,.08);
    border-radius:10px;
    box-shadow:0 10px 40px rgba(0,0,0,.45);
    padding:16px;
    display:flex;
    flex-direction:column;
    gap:12px;
}

.editor-add-title{
    font-size:15px;
    font-weight:700;
}

.editor-add-row,
.editor-add-actions{
    display:flex;
    gap:10px;
}

.editor-add-field{
    display:flex;
    flex-direction:column;
    gap:6px;
}

.editor-add-label{
    color:var(--muted);
    font-size:13px;
}

.editor-add-row label{
    display:flex;
    flex-direction:column;
    gap:6px;
    width:100%;
    color:var(--muted);
    font-size:13px;
}

.editor-add-row input,
.editor-add-input-wrap input,
#addItemAmount{
    width:100%;
}

.editor-add-input-wrap{
    display:flex;
    align-items:center;
    gap:8px;
    padding:0 10px;
    background:#0b1314;
    border:1px solid rgba(255,255,255,.06);
    border-radius:8px;
}

.editor-add-input-wrap input{
    border:none;
    background:transparent;
    padding:9px 0;
}

.editor-item-icon{
    width:22px;
    height:22px;
    object-fit:contain;
    flex:0 0 auto;
}

.editor-item-icon[hidden]{
    display: none;
}

.editor-add-suggestions{
    position:fixed;
    display:flex;
    flex-direction:column;
    gap:4px;
    padding:4px;
    border:1px solid rgba(255,255,255,.06);
    border-radius:8px;
    background:#0b1214;
    max-height:220px;
    overflow:auto;
    box-shadow:0 12px 40px rgba(0,0,0,.55);
    z-index:10001;
}

.editor-add-suggestions[hidden]{
    display:none;
}

.editor-add-suggestion{
    display:flex;
    align-items:center;
    gap:8px;
    width:100%;
    padding:8px 10px;
    text-align:left;
    border-radius:6px;
    background:transparent;
    border:none;
    color:var(--text);
}

.editor-add-suggestion:hover{
    background:rgba(255,255,255,.05);
}

.editor-add-suggestion .editor-item-icon{
    width:20px;
    height:20px;
}

.editor-add-hint{
    min-height:18px;
    color:var(--muted);
    font-size:12px;
}

.editor-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    padding:18px 20px;
    border-bottom:1px solid rgba(255,255,255,.06);
}

.editor-header h2{
    margin:0;
}

.editor-subtitle{
    margin-top:4px;
    color:var(--muted);
    font-size:13px;
}

.editor-toolbar{
    display:flex;
    gap:10px;
    padding:14px 20px;
    border-bottom:1px solid rgba(255,255,255,.06);
}

.editor-toolbar input{
    flex:1;
}

.editor-list{
    flex:1;
    overflow:auto;
}

.editor-list-header,
.editor-row{
    display:grid;
    grid-template-columns:50px minmax(250px, 420px) 90px;
    gap:20px;
    align-items:center;
    padding:10px 20px;
}

.editor-list-header{
    position:sticky;
    top:0;
    background:#11181c;
    font-size:12px;
    color:var(--muted);
    font-weight:600;
    text-transform:uppercase;
    border-bottom:1px solid rgba(255,255,255,.08);
    justify-items:start;
}

.editor-list-header span:last-child,
.editor-total{
    justify-self:end;
}

.editor-row{
    border-bottom:1px solid rgba(255,255,255,.04);
}

.editor-row:hover{
    background:rgba(255,255,255,.03);
}

.editor-row.added{
    background:rgba(110,231,183,.06);
    grid-template-columns:50px minmax(250px, 420px) 90px 90px 90px;
}

.editor-row.added:hover{
    background:rgba(110,231,183,.1);
}

.editor-item-icon-placeholder{
    display:inline-block;
    width:22px;
    height:22px;
    border-radius:4px;
    border:1px dashed rgba(255,255,255,.25);
    background:rgba(255,255,255,.03);
    flex:0 0 auto;
}

.editor-item-icon-placeholder[hidden]{
    display: none;
}

.editor-edit-btn,
.editor-remove-btn{
    justify-self:end;
    border:1px solid rgba(255,255,255,.12);
    background:#1b2427;
    color:var(--text);
    border-radius:6px;
    padding:6px 10px;
    cursor:pointer;
}

.editor-remove-btn{
    background:#8c1f1f;
}

.editor-remove-btn:hover{
    background:#a72929;
}

.editor-edit-btn:hover{
    background:#253136;
}

.editor-row .ignored{
    color:var(--muted);
    text-decoration-line: line-through;
}

.editor-row .item-inline {
    display:flex;
    align-items:center;
    gap:8px;
}

.editor-total{
    text-align:right;
    font-variant-numeric:tabular-nums;
}

.editor-footer{
    display:flex;
    align-items:center;
    padding:14px 20px;
    border-top:1px solid rgba(255,255,255,.06);
}

.editor-spacer{
    flex:1;
}

.editor-section-title{
    padding:14px 20px;
    font-size:13px;
    color:var(--muted);
    text-transform:uppercase;
    border-top:1px solid rgba(255,255,255,.08);
}