@font-face { font-family: "Minecraft"; src: url("fonts/Minecraft.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "MinecraftBold"; src: url("fonts/Minecraft-Bold.otf") format("opentype"); font-display: swap; }
/* Minecraft.otf has no ğ ı İ ş; Monocraft (same pixel style) fills only those code points. */
@font-face { font-family: "MinecraftTR"; src: url("fonts/Monocraft.ttf") format("truetype"); font-display: swap; unicode-range: U+011E-011F, U+0130-0131, U+015E-015F; }
@font-face { font-family: "MinecraftTRBold"; src: url("fonts/Monocraft-Bold.ttf") format("truetype"); font-display: swap; unicode-range: U+011E-011F, U+0130-0131, U+015E-015F; }

:root {
  --bg: #0d0e12;
  --panel: #15171d;
  --panel-2: #1b1e26;
  --panel-3: #232733;
  --border: #272b36;
  --text: #e9eaef;
  --muted: #8a8fa0;
  --accent: #e8735c;
  --accent-2: #3fb8a6;
  --accent-ink: #160a07;
  --warn: #f2b44c;
  --danger: #ff6b6b;
  --info: #6ea8ff;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.25);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f8; --panel: #ffffff; --panel-2: #f3f4f7; --panel-3: #e9ebf0; --border: #e1e4ea;
  --text: #15171c; --muted: #5e6475; --accent: #d75a42; --accent-2: #1f9483; --accent-ink: #fff;
  --warn: #b7791f; --danger: #d64545; --info: #2f6fd6;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f8; --panel: #ffffff; --panel-2: #f3f4f7; --panel-3: #e9ebf0; --border: #e1e4ea;
    --text: #15171c; --muted: #5e6475; --accent: #d75a42; --accent-2: #1f9483; --accent-ink: #fff;
    --warn: #b7791f; --danger: #d64545; --info: #2f6fd6;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
code, .code, textarea, input { font-variant-ligatures: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 22px; height: 22px; fill: var(--accent); }
.brand-name {
  font-weight: 700; font-size: 18px; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { color: var(--muted); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border); cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; }
.btn-icon { width: 36px; padding: 0; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn-danger { color: var(--danger); }
select.btn { padding-right: 8px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12px; }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.seg-sm button { padding: 3px 8px; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px;
  max-width: 1440px; margin: 0 auto; padding: 20px 24px 40px;
}
.editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.preview { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; min-width: 0; scrollbar-width: thin; }
.preview > * { flex: none; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .preview { position: static; max-height: none; overflow: visible; order: -1; }
  .topbar { padding: 10px 16px; }
}

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head.pad { padding: 14px 18px 0; }
.card h2 { font-size: 15px; margin: 0; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 8px; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.toolbar-hint { margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field > span small { font-weight: 400; }
input:not([type=color]):not([type=checkbox]), select:not(.btn), textarea {
  width: 100%; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.6; }
.fmt-field { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
input.invalid { border-color: var(--danger); }
input[type=color] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type=color]:disabled { opacity: .35; cursor: not-allowed; }
.mini-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.mini-check input { accent-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

.material-input { display: flex; align-items: center; gap: 10px; }
.material-input .mc-item { width: 36px; height: 36px; flex: none; padding: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.mc-item { image-rendering: pixelated; }
.mc-item.missing { background: conic-gradient(#f800f8 25%, #000 0 50%, #f800f8 0 75%, #000 0) 0 0 / 50% 50% !important; }

.quick-materials { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-materials button {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; transition: border-color .15s, transform .1s;
}
.quick-materials button:hover { transform: translateY(-1px); border-color: var(--muted); }
.quick-materials button.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.quick-materials img { width: 28px; height: 28px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.swatches { display: grid; grid-template-columns: repeat(8, 20px); gap: 4px; }
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.35); cursor: pointer; padding: 0; transition: transform .1s; }
.swatch:hover { transform: scale(1.15); }
.tool-group { display: flex; align-items: center; gap: 4px; padding-left: 8px; border-left: 1px solid var(--border); }
.tool { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 13px; }
.tool:hover { background: var(--panel-3); }
.grad-preview { width: 44px; height: 10px; border-radius: 99px; }
@media (max-width: 560px) { .tool-group { border-left: 0; padding-left: 0; } }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); font-size: 13px; }
.notice[hidden] { display: none; }

/* ---------- lists (effects / abilities) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.list:empty::after { content: attr(data-empty); display: block; padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; font-size: 13px; }
.item-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); overflow: hidden; }
.item-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; user-select: none; }
.item-head .badge { font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); white-space: nowrap; }
.item-head .badge.fx { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.item-head .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.item-head .title .mc-line { font-size: 13px; }
.item-head .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item-head .chev { color: var(--muted); transition: transform .15s; }
.item-card.open .chev { transform: rotate(90deg); }
.item-body { display: none; padding: 4px 12px 12px; border-top: 1px solid var(--border); }
.item-card.open .item-body { display: block; padding-top: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.del:hover { color: var(--danger); }
.type-desc { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.new-tag { font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 5px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.name-preview { min-height: 28px; padding: 4px 8px; margin: -4px 0 14px; background: #100010; border-radius: 6px; }

.subsection { margin-top: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.subsection h3 { font-size: 12.5px; margin: 0 0 10px; color: var(--muted); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ring-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ring { width: 46px; height: 46px; border-radius: 50%; flex: none; -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.chip .icon-btn { width: 20px; height: 20px; font-size: 12px; }

/* ---------- preview screen ---------- */
.screen {
  position: relative; margin-top: 14px; padding: 22px 18px;
  min-height: 360px; overflow: hidden;
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(232,115,92,.18), transparent 60%),
    radial-gradient(100% 70% at 100% 100%, rgba(63,184,166,.18), transparent 60%),
    linear-gradient(180deg, #1a1d2b 0%, #12131a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .08;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 32px 32px;
}
.screen > * { position: relative; }

.mc-line, .mc-tooltip { font-family: "Minecraft", "MinecraftTR", monospace; font-size: 16px; line-height: 20px; white-space: pre; letter-spacing: 0; }
.mc-line span { text-shadow: 2px 2px 0 var(--shadow); }
.mc-line .mc-b { font-family: "MinecraftBold", "MinecraftTRBold", "Minecraft", monospace; }
.mc-line .mc-i { font-style: italic; }
.mc-line:empty::after { content: "\200b"; }

.tooltip-wrap { transform-origin: top left; }
.mc-tooltip {
  position: relative; display: inline-block; padding: 8px 10px 6px;
  background: rgba(16, 0, 16, .94);
  clip-path: polygon(2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px), 0 2px, 2px 2px);
}
.mc-tooltip::before {
  content: ""; position: absolute; inset: 2px; pointer-events: none;
  border: 2px solid transparent;
  border-image: linear-gradient(rgba(80, 0, 255, .55), rgba(40, 0, 127, .55)) 1;
}
.mc-title { margin-bottom: 4px; }

/* inventory view */
.inv-scene { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; justify-content: center; }
.inv-panel {
  padding: 8px; background: #c6c6c6; border-radius: 4px;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #555, 0 0 0 2px #000;
}
.inv-grid { display: grid; grid-template-columns: repeat(9, 36px); gap: 0; }
.inv-grid + .inv-grid { margin-top: 8px; }
.slot { width: 36px; height: 36px; background: #8b8b8b; box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #fff; display: grid; place-items: center; position: relative; }
.slot img { width: 32px; height: 32px; }
.slot.hover { background: #c5c5c5; }
@media (max-width: 520px) { .inv-grid { grid-template-columns: repeat(9, 28px); } .slot { width: 28px; height: 28px; } .slot img { width: 24px; height: 24px; } }

/* hotbar view */
.screen.hotbar-view { justify-content: flex-end; min-height: 260px; padding-bottom: 14px; }
.hud { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.held-name { text-align: center; min-height: 20px; }
.hotbar { display: flex; padding: 2px; background: rgba(0,0,0,.55); box-shadow: 0 0 0 2px #1d1d1d, inset 0 0 0 2px #5a5a5a; }
.hb-slot { width: 40px; height: 40px; display: grid; place-items: center; position: relative; box-shadow: inset 0 0 0 2px rgba(120,120,120,.55); }
.hb-slot img { width: 32px; height: 32px; }
.hb-slot.sel::after { content: ""; position: absolute; inset: -4px; border: 4px solid #fff; box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000; pointer-events: none; }
@media (max-width: 520px) { .hb-slot { width: 30px; height: 30px; } .hb-slot img { width: 24px; height: 24px; } }

/* ---------- yaml ---------- */
.code {
  margin: 0; padding: 14px 16px; border-radius: 10px; background: #0b0c10; color: #d7dae3;
  border: 1px solid var(--border);
  font: 12.5px/1.65 "JetBrains Mono", ui-monospace, monospace; white-space: pre; overflow: auto; max-height: 460px; tab-size: 2;
}
.code .k { color: #7cc6ff; }
.code .s { color: #b5e08a; }
.code .n { color: #f6b26b; }
.code .c { color: #6c7385; font-style: italic; }
.code .d { color: #8a8fa0; }

.warnings { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { display: flex; gap: 8px; font-size: 13px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); }
.warnings li::before { font-weight: 800; flex: none; width: 12px; text-align: center; }
.warnings li.err { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.warnings li.err::before { content: "✕"; color: var(--danger); }
.warnings li.warn::before { content: "!"; color: var(--warn); }
.warnings li.info::before { content: "i"; color: var(--info); }
.warnings li.ok { border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.warnings li.ok::before { content: "✓"; color: var(--accent-2); }

/* ---------- misc ---------- */
.footer { display: flex; justify-content: center; gap: 14px; padding: 8px 16px 28px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; text-align: center; }
.footer a { color: var(--muted); }

.dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.dialog::backdrop { background: rgba(5,6,10,.6); backdrop-filter: blur(3px); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body h2 { margin: 0; font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.error { color: var(--danger); margin: 0; font-size: 13px; }
.error[hidden] { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px;
  transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
