:root {
  --paper: #F3F0E8; --card: #FBFAF6; --ink: #1B1A17; --muted: #5A564D; --soft: #3B3830; --rule: #CFC8B6;
  --blue: #1F4FB8; --phone: #D2BF8E; --tablet: #E2D6B6; --monitor: #EDE6D3; --bg: #D9D3C3;
  --serif: Newsreader, Georgia, serif; --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
a { color: var(--blue); }
#viewport { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#viewport.panning { cursor: grabbing; }
#viewport.drawing { cursor: crosshair; }
#world { position: absolute; left: 0; top: 0; width: 3840px; height: 2160px; transform-origin: 0 0; background: var(--card); box-shadow: 0 0 0 3px var(--ink); }
.zone { position: absolute; pointer-events: none; transition: filter .3s, opacity .3s; }
.zone.monitor { background: var(--monitor); outline: 2px dashed #8C8576; }
.zone.tablet { background: var(--tablet); outline: 2px dashed #7A7262; }
.zone.phone { background: var(--phone); outline: 2px dashed #5F584A; }
.zlabel { position: absolute; font-size: 20px; font-weight: 600; color: var(--muted); pointer-events: none; white-space: nowrap; }

.ad { position: absolute; overflow: hidden; border: 2px solid var(--ink); display: flex; cursor: pointer; transition: filter .3s, opacity .3s, box-shadow .3s; }
.ad.split-v { flex-direction: column; }
.ad.split-h { flex-direction: row; }
.ad .pic { flex: 1 1 50%; min-width: 0; min-height: 0; display: block; overflow: hidden; }
.ad .pic img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ad .txt { flex: 1 1 50%; min-width: 0; min-height: 0; padding: 12px; font-size: 16px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden; color: inherit; text-decoration: none; display: block; }
.ad .txt .nm { display: block; font-family: var(--serif); font-weight: 700; font-size: 1.5em; line-height: 1.1; margin-bottom: 6px; }
.ad .badge { position: absolute; right: 4px; top: 4px; font-size: 11px; font-weight: 600; background: #FFF4D6; color: var(--ink); border: 1px solid var(--ink); border-radius: 999px; padding: 1px 7px; pointer-events: none; }
.reserved { position: absolute; background: repeating-linear-gradient(45deg, #e4dfd2 0 10px, #ece8de 10px 20px); border: 2px dashed #8C8576; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--muted); pointer-events: none; }
#world.focus .ad:not(.focused), #world.focus .zone, #world.focus .reserved, #world.focus .zlabel { filter: blur(8px); opacity: .55; }
#world.focus .ad.focused { box-shadow: 0 24px 80px rgba(27, 26, 23, .45); z-index: 5; }
.sel { position: absolute; border: 4px solid var(--blue); background: rgba(31, 79, 184, .16); cursor: move; z-index: 6; }
.sel.bad { border-color: #B42318; background: rgba(180, 35, 24, .14); }
.sel .dims { position: absolute; left: 0; top: -34px; background: var(--blue); color: #fff; font-size: 18px; font-weight: 600; padding: 3px 8px; white-space: nowrap; }
.sel.bad .dims { background: #B42318; }

.iconbtn { width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 8px; background: var(--card); color: var(--ink); font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.iconbtn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
#menuBtn { position: fixed; left: 16px; top: 16px; z-index: 20; }
#menu { position: fixed; left: 16px; top: 72px; width: 280px; z-index: 20; background: var(--card); border: 2px solid var(--ink); border-radius: 8px; box-shadow: 0 12px 32px rgba(27, 26, 23, .25); padding: 8px; display: flex; flex-direction: column; }
#menu[hidden] { display: none; }
#menu .brand { font-family: var(--serif); font-size: 24px; font-weight: 700; padding: 10px 12px 12px; }
#menu a, #menu button { display: flex; align-items: center; min-height: 48px; padding: 0 12px; border-radius: 6px; color: var(--ink); text-decoration: none; font: inherit; font-weight: 500; border: 0; background: none; cursor: pointer; text-align: left; }
#menu a.primary { background: var(--ink); color: var(--paper); font-weight: 600; }
#menu a:hover, #menu button:hover { background: #ECE7DA; } #menu a.primary:hover { background: #2E2C27; }
#zoomCtl { position: fixed; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
#hint { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-size: 13px; color: var(--soft); white-space: nowrap; z-index: 10; }
#unfocus { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); min-height: 48px; padding: 0 20px; background: var(--card); border: 2px solid var(--ink); border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; z-index: 15; }
#unfocus[hidden] { display: none; }

#panel { position: fixed; right: 16px; top: 16px; bottom: 16px; width: min(440px, calc(100vw - 32px)); z-index: 30; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; box-shadow: 0 16px 48px rgba(27, 26, 23, .3); overflow: auto; padding: 24px; }
#panel[hidden] { display: none; }
#panel.wide { width: min(820px, calc(100vw - 32px)); }
#panel .close { position: sticky; float: right; top: 0; width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 8px; background: var(--card); font-size: 24px; cursor: pointer; }
#panel h1 { font-family: var(--serif); font-size: 34px; line-height: 1.05; margin: 0 0 12px; }
#panel h2 { font-size: 18px; margin: 24px 0 8px; }
#panel p, #panel li { font-size: 15px; line-height: 1.55; color: var(--soft); }
.price { font-family: var(--serif); font-size: 48px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; margin: 8px 0; }
.small { font-size: 13px !important; color: var(--muted) !important; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; margin-top: 10px; }
label.f input, label.f textarea, label.f select { font: inherit; font-weight: 400; padding: 10px; border: 1px solid var(--ink); border-radius: 6px; background: var(--card); min-height: 44px; width: 100%; }
label.f textarea { min-height: 110px; resize: vertical; }
label.f input[type=color] { padding: 4px; height: 44px; }
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin-top: 14px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; border: 2px solid var(--ink); background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.seg button { min-height: 44px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); font: inherit; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.msg { padding: 10px 12px; border-radius: 6px; border: 1px solid var(--ink); background: #FFF4D6; font-size: 14px; margin-top: 12px; }
.msg.err { background: #FBE4E1; border-color: #B42318; }
.msg.ok { background: #E3F1E6; border-color: #1F7A42; }
table.prices { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border: 2px solid var(--ink); }
table.prices th { background: var(--ink); color: var(--paper); text-align: left; padding: 8px 10px; }
table.prices td { padding: 8px 10px; border-top: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--ink); margin-right: 6px; vertical-align: -1px; }
pre.code { background: var(--ink); color: #E6E0D0; padding: 12px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  #panel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 62vh; }
  #panel.wide { width: auto; max-height: 85vh; }
  #hint { display: none; }
}
#hint[hidden] { display: none; }
