:root{
  --bg1:#071c33;
  --bg2:#0b2f55;
  --panel:rgba(235,250,255,.82);
  --shadow:0 10px 30px rgba(0,0,0,.25);
  --radius:14px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Hiragino Kaku Gothic ProN","Noto Sans JP","Segoe UI",sans-serif;
  color:#082033;
  background:
    radial-gradient(1200px 800px at 70% -10%, rgba(255,255,255,.25), transparent 55%),
    radial-gradient(900px 700px at 20% 10%, rgba(120,200,255,.18), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg1));
}

/* Top bar */
.topbar{
  position:sticky; top:0;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  display:flex; align-items:center; gap:12px;
  background:
    radial-gradient(900px 200px at 50% 0%, rgba(255,255,255,.25), transparent 60%),
    linear-gradient(180deg, rgba(7,29,55,.92), rgba(6,22,40,.88));
  border-bottom:1px solid rgba(255,255,255,.18);
  z-index:20;
}
.topTitle{
  flex:1;
  text-align:center;
  font-weight:700;
  letter-spacing:.08em;
  color:#e9f7ff;
  text-shadow:0 2px 10px rgba(0,0,0,.35);
  font-size:22px;
}
.iconBtn{
  width:42px; height:42px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.08);
  color:#e9f7ff;
  font-size:20px;
}

/* Drawer */
.backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.40);
  opacity:0; pointer-events:none;
  transition:.2s;
  z-index:30;
}
.backdrop.show{opacity:1; pointer-events:auto}
.drawer{
  position:fixed; top:0; left:0;
  width:min(86vw, 360px);
  height:100%;
  padding-top: var(--safe-top);
  background:
    radial-gradient(900px 700px at 30% 10%, rgba(120,200,255,.18), transparent 60%),
    linear-gradient(180deg, rgba(6,22,40,.98), rgba(5,18,34,.98));
  transform:translateX(-105%);
  transition:.25s;
  z-index:40;
  border-right:1px solid rgba(255,255,255,.14);
}
.drawer.open{transform:translateX(0)}
.drawerHeader{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 12px 8px;
  color:#e9f7ff;
}
.drawerTitle{font-weight:700; letter-spacing:.08em}
.drawerBody{padding:10px 12px 18px}
.drawerLabel{display:block; color:rgba(233,247,255,.85); margin:10px 0 6px; font-size:13px}
.drawerSelect{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.22);
  background:rgba(255,255,255,.10);
  color:#e9f7ff;
  outline:none;
}
.drawerRow{display:flex; gap:10px; margin-top:12px}
.divider{
  height:1px;
  background:rgba(255,255,255,.18);
  margin:14px 0;
}
.miniNoteDrawer{font-size:12px; opacity:.8; color:rgba(233,247,255,.85); margin-top:8px}

/* Buttons */
.btn{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.08);
  color:#e9f7ff;
  font-weight:700;
}
.btn.primary{
  margin-top:14px;
  border-color:rgba(120,220,255,.55);
  background:linear-gradient(180deg, rgba(110,225,255,.55), rgba(50,160,220,.35));
  color:#06233d;
}
.btn.ghost{background:rgba(255,255,255,.06)}
.btn.danger{border-color:rgba(255,120,120,.45); color:#ffdede}
.fileBtn{display:block; text-align:center; position:relative; overflow:hidden}
.fileBtn input{position:absolute; inset:0; opacity:0}

/* Screens */
.screen{
  padding:14px 12px calc(22px + var(--safe-bottom));
  max-width:520px;
  margin:0 auto;
}
.hidden{display:none}

/* Panels */
.panel{
  background: rgba(235,250,255,.82);
  border:1px solid rgba(255,255,255,.65);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding:12px;
  margin:12px 0;
  backdrop-filter: blur(10px);
}
.headerPanel{text-align:center; padding:14px 12px 12px}
.roman{font-size:16px; letter-spacing:.06em; font-weight:700; opacity:.9}
.jpName{font-size:44px; font-weight:900; margin:6px 0 0; letter-spacing:.06em; color:#051a2b}
.furigana{font-size:16px; font-weight:700; opacity:.9}

.upperPanel{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  align-items:stretch;
}

/* Image box */
.imgBox{
  position:relative;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  background:rgba(255,255,255,.55);
  overflow:hidden;
  min-height:170px;
}
.imgBox img{
  width:100%; height:100%;
  object-fit:cover;
  display:none;
}
.imgPlaceholder{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-weight:800;
  opacity:.7;
}

.statsBox{
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  background:rgba(255,255,255,.55);
  padding:10px;
}
.statRow{
  display:grid;
  gap:6px;
  padding:8px 6px;
  border-bottom:1px solid rgba(0,0,0,.08);
}
.statRow:last-child{border-bottom:none}
.statLabel{font-weight:800; opacity:.85; font-size:14px}
.statVal{font-weight:700; font-size:14px; color:#06233d}

.bigPanel{padding:10px 12px}
.bigLabel{font-weight:900; font-size:18px; margin-bottom:8px}
.bigVal{
  white-space:pre-wrap;
  line-height:1.55;
  font-weight:700;
  opacity:.92;
  min-height:64px;
}

.hint{
  text-align:center;
  color:rgba(233,247,255,.85);
  font-size:12px;
  margin-top:10px;
}

/* Edit UI */
.editHeader{text-align:center}
.editTitle{font-size:20px; font-weight:900}
.editSub{font-size:12px; opacity:.85; margin-top:4px}

.editPanel label{font-weight:800; font-size:13px; opacity:.9}
.subLabel{display:block; margin-top:10px; font-weight:800; font-size:12px; opacity:.75}
.editPanel input, .editPanel select, .editPanel textarea{
  width:100%;
  padding:12px 12px;
  margin-top:6px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  background:rgba(255,255,255,.8);
  outline:none;
  font-size:16px; /* iPhoneズーム防止 */
}
.formRow{margin:12px 0}
.formGrid{display:grid; grid-template-columns: 1fr 1fr; gap:12px}
.unitInput{display:flex; gap:10px; align-items:center}
.unitInput span{font-weight:900; opacity:.75}
.imgPreviewWrap{
  margin-top:10px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  overflow:hidden;
  background:rgba(255,255,255,.55);
  min-height:160px;
}
#eImagePreview{width:100%; height:220px; object-fit:cover; display:none}
.miniNote{font-size:12px; opacity:.8; margin-top:6px}
.editActions{display:flex; gap:10px; margin-top:16px}
