/* KYOAI v1 - minimal, practical UI for librarians */

:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.08);
  --line: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.68);
  --accent: #9be7ff;
  --accent2: #b3ffcb;
  --danger: #ff7b7b;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  --cellW: 56px; /* zoom changes this */
  --cellH: 24px; /* zoom changes this */
  --cellGap: 3px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(155,231,255,.12), transparent 55%),
              radial-gradient(900px 600px at 100% 30%, rgba(179,255,203,.08), transparent 50%),
              var(--bg);
  color: var(--text);
}

.topbar{
  position: sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,14,28,.72);
  backdrop-filter: blur(10px);
}

.brand{ display:flex; flex-direction:column; gap:2px; }
.brand__title{
  font-weight:800;
  letter-spacing:.06em;
  font-size: 18px;
}
.brand__subtitle{
  font-size: 12px;
  color: var(--muted);
}

.actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

.sep{
  width:1px;
  height:22px;
  background: var(--line);
  margin: 0 4px;
}

.btn{
  appearance:none;
  border:1px solid rgba(155,231,255,.22);
  color: var(--text);
  background: linear-gradient(180deg, rgba(155,231,255,.22), rgba(155,231,255,.08));
  padding: 9px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight:650;
  font-size: 13px;
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
}
.btn:hover{ filter: brightness(1.06); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.5; cursor:not-allowed; transform:none; }

.btn--ghost{
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  box-shadow:none;
}
.btn--small{
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.inline{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
  color: var(--muted);
}

.select, .input, .textarea{
  width:100%;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline:none;
}
.select{ width:auto; padding: 8px 10px; }
.input:focus, .select:focus, .textarea:focus{
  border-color: rgba(155,231,255,.42);
  box-shadow: 0 0 0 3px rgba(155,231,255,.16);
}

.status{
  font-size: 12px;
  color: var(--muted);
  min-width: 180px;
  text-align:right;
}

.layout{
  display:grid;
  grid-template-columns: 320px 1fr 360px;
  gap: 14px;
  padding: 14px;
  align-items:start;
}

.sidebar, .canvas, .editor{
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height: 70vh;
}

.panel__header{
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  background: rgba(255,255,255,.04);
}
.panel__title{ font-weight:800; letter-spacing:.03em; }
.panel__hint{ color: var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.shelfList{
  padding: 10px;
  display:flex;
  flex-direction:column;
  gap: 8px;
  overflow:auto;
  max-height: calc(70vh - 200px);
}

.shelfItem{
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  cursor:pointer;
}
.shelfItem:hover{ background: rgba(255,255,255,.06); }
.shelfItem.is-selected{
  border-color: rgba(155,231,255,.45);
  background: rgba(155,231,255,.10);
}
.shelfItem__top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.shelfItem__name{ font-weight:800; }
.shelfItem__meta{ font-size:12px; color: var(--muted); margin-top:2px; display:flex; gap:10px; flex-wrap:wrap; }
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  font-size: 12px;
  color: var(--muted);
}

.totals{
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.totals__row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding: 4px 0;
  font-size: 12px;
}
.totals__label{ color: var(--muted); }
.totals__value{ font-weight:750; }

.canvasGrid{
  padding: 12px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow:auto;
  max-height: 70vh;
}

.shelfCard{
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  padding: 10px;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.shelfCard:hover{ background: rgba(255,255,255,.06); }
.shelfCard.is-selected{
  border-color: rgba(155,231,255,.52);
  background: rgba(155,231,255,.10);
}

.shelfViewport{
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  border-radius: 14px;
}
.shelfViewport::-webkit-scrollbar{ height: 10px; }
.shelfViewport::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.12);
  border-radius: 999px;
}
.shelfViewport::-webkit-scrollbar-track{
  background: rgba(255,255,255,.04);
  border-radius: 999px;
}
.shelfCard__head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.shelfCard__title{
  font-weight:900;
  letter-spacing:.02em;
}
.shelfCard__sub{
  font-size:12px;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.shelfGrid{
  display:flex;
  gap: var(--cellGap);
  align-content:start;
  justify-content:start;
  align-items:flex-start;
  user-select:none;
  width: max-content;
  max-width: 100%;
}

.shelfCol{
  display:flex;
  flex-direction:column;
  gap: var(--cellGap);
}


.cell{
  width: var(--cellW);
  height: var(--cellH);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.05);
  overflow: hidden;
}

.cellFill{
  height: 100%;
  width: var(--fillW, 0%);
  background: rgba(155,231,255,.75);
  border-radius: 5px;
}

.cell.is-picked{
  outline: 2px solid rgba(155,231,255,.55);
  outline-offset: 1px;
}
.cell.is-locked{ opacity:.65; }

.editorBody{
  padding: 12px 14px;
  overflow:auto;
  max-height: 70vh;
}

.section{
  padding: 10px 0 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.section:last-child{ border-bottom:none; }

.section__title{
  font-weight:850;
  margin-bottom: 10px;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}
.section__sub{ color: var(--muted); font-size:12px; }

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field{ display:flex; flex-direction:column; gap:6px; }
.field__label{ font-size:12px; color: var(--muted); }

.rowControls{
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.rowControl{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 10px;
}
.rowControl__top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.rowControl__name{
  font-weight:850;
}
.rowControl__tools{
  display:flex;
  align-items:center;
  gap:8px;
  color: var(--muted);
  font-size:12px;
}

.sliderRow{
  display:flex;
  align-items:center;
  gap: 10px;
}
.range{
  width: 100%;
}
.kv{
  display:flex;
  gap:8px;
  font-size:12px;
  color: var(--muted);
  align-items:center;
}
.kv strong{ color: var(--text); }

.editorActions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
}
.btn--danger{
  border-color: rgba(255,123,123,.35);
  background: rgba(255,123,123,.12);
}

.mutedInline{ color: var(--muted); font-weight: 650; font-size: 12px; }
.note{
  font-size:12px;
  color: var(--muted);
  line-height:1.6;
}

.dialog{
  border:1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 0;
  background: rgba(10,14,28,.92);
  color: var(--text);
  width: min(560px, 92vw);
}
.dialog::backdrop{
  background: rgba(0,0,0,.55);
}
.dialog__form{
  padding: 16px;
}
.dialog__title{
  font-weight:900;
  letter-spacing:.03em;
  margin-bottom: 12px;
}
.dialog__actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top: 14px;
}
.dialog__footnote{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height:1.6;
}


/* Popup slider for selected cell */
.cellPopup{
  position: fixed;
  z-index: 9999;
  width: 260px;
  max-width: calc(100vw - 24px);
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(10,14,28,.94);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  padding: 10px;
}
.cellPopup__title{
  font-size: 12px;
  color: var(--muted);
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}
.cellPopup__value{
  font-weight: 850;
  color: var(--text);
}
.cellPopup__row{
  display:flex;
  align-items:center;
  gap:10px;
}
.cellPopup__close{
  appearance:none;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  border-radius: 10px;
  padding: 4px 8px;
  cursor:pointer;
  font-size: 12px;
}
.cellPopup__close:hover{ filter: brightness(1.07); }

.footer{
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
}
.footer__inner{
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 10px;
  display:flex;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
}
.muted{ color: var(--muted); }

@media (max-width: 1100px){
  .layout{
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto;
  }
  .editor{
    grid-column: 1 / -1;
  }
  .canvasGrid, .editorBody, .shelfList{ max-height: none; }
}
@media (max-width: 760px){
  .layout{
    grid-template-columns: 1fr;
  }
  .sidebar{ order: 1; }
  .canvas{ order: 2; }
  .editor{ order: 3; }
  .status{ min-width: 0; text-align:left; }
  .canvasGrid{ grid-template-columns: 1fr; }
}


.rangeRow{ display:flex; align-items:center; gap:10px; }
.rangeRow .pill{ flex:0 0 auto; }

.dialog__message{ margin-top:10px; line-height:1.6; color: rgba(255,255,255,.9); white-space:pre-wrap; }

a,a:hover,a:visited{
    color: inherit;
}
