
:root{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#edf4ff;background:#080e17;color-scheme:dark}*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button{cursor:pointer;color:inherit}header{padding:17px 20px;border-bottom:1px solid #263349;display:flex;justify-content:space-between;align-items:center;max-width:1100px;margin:auto}.logo{color:#645bff;font-size:24px}h1{font-size:17px;margin:0}h2{font-size:15px;margin:0 0 13px}.small{font-size:11px;color:#8fa1bb}.shell{max-width:1100px;margin:auto;padding:16px 18px 90px}.top{display:flex;gap:9px;align-items:center;margin-bottom:12px}.top select{max-width:250px}.modes{display:flex;gap:7px;margin-bottom:15px}.modes button{flex:1;background:#121c2c;border:1px solid #304059;border-radius:10px;padding:13px 5px;font-size:12px;font-weight:700}.modes button.on,.active{background:#3b36b9!important;border-color:#7770ff!important;color:#fff!important}.nav{display:flex;gap:7px;margin-bottom:15px}.nav button{flex:1;border:1px solid #29394d;background:#121a29;border-radius:10px;padding:11px 5px;font-size:12px}.nav button.on{border-color:#6c61ff;color:#b7b1ff}.columns{display:grid;grid-template-columns:minmax(310px,380px) 1fr;gap:15px}.panel{border:1px solid #293b52;background:linear-gradient(140deg,#132033,#0e1826);border-radius:16px;padding:17px;margin-bottom:13px}.field label{display:block;font-size:11px;color:#a3b5cc;margin:0 0 6px}.field input,.field select,.top select{width:100%;min-width:0;border:1px solid #35455e;border-radius:9px;background:#0a1422;padding:11px;color:white;font-size:15px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.wide{grid-column:span 2}.hint{font-size:11px;color:#8fa3bd;line-height:1.6}.hero{border-color:#695dff;background:radial-gradient(circle at 100% 0,#332e75aa,transparent 50%),#121e30}.hero .num{font-size:41px;color:#51e7c1;font-weight:800;letter-spacing:-1.7px;margin:11px 0}.kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.kpis div{font-size:11px;color:#98aac1}.kpis strong{display:block;font-size:17px;color:#eaf2ff;margin-top:5px}.section{display:flex;align-items:center;justify-content:space-between;margin:15px 0 10px}.cards{display:grid;grid-template-columns:repeat(2,1fr);gap:9px}.country{background:#121f2e;border:1px solid #2c3c52;border-radius:13px;padding:13px;text-align:left}.country .name{font-size:12px;font-weight:700}.country .amount{font-size:23px;font-weight:800;color:#50e5c1;margin:10px 0 3px}.country .sub{font-size:11px;color:#92a9c2}.country .pct{color:#50dfb8;font-size:12px}.btn{border:1px solid #394963;background:#1b293c;border-radius:10px;padding:10px 12px;font-size:12px}.primary{background:#4944df;border-color:#6860ff;font-weight:700}.full{width:100%}.page{display:none}.page.on{display:block}.row{display:flex;justify-content:space-between;gap:10px;align-items:center;border-bottom:1px solid #2a3b51;padding:11px 0;font-size:12px}.row:last-child{border:0}.row span{color:#a4b5cc}.row strong{font-variant-numeric:tabular-nums}.positive{color:#50e7bf!important}.negative{color:#ff9da8!important}.filters{display:flex;gap:7px;overflow:auto;margin:10px 0 15px}.filters button{flex-shrink:0}.modal{position:fixed;inset:0;background:#03070cc9;z-index:50;display:none;align-items:center;justify-content:center;padding:15px}.modal.open{display:flex}.sheet{background:#121e2d;border:1px solid #43536b;border-radius:20px;width:min(540px,100%);max-height:87vh;overflow:auto;padding:20px;box-shadow:0 30px 70px #000a}.sheethead{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.sheethead h2{font-size:20px;margin:0}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.metrics>div{border:1px solid #30435a;background:#0d1726;border-radius:11px;padding:11px 7px}.metrics small{font-size:10px;color:#91a6c0}.metrics b{display:block;font-size:18px;margin-top:8px}.blocktitle{margin:19px 0 4px;font-size:12px;font-weight:800;color:#c3d2e5}.divider{height:1px;background:#304158;margin:15px 0}details summary{padding:10px 0;font-size:12px;cursor:pointer;color:#c8d5eb}.toolbar{display:flex;gap:7px;flex-wrap:wrap}.toolbar button{flex:1}.sticky{display:none}.notice{font-size:11px;color:#8fa3bb;line-height:1.8}.hide{display:none!important}.editor{display:grid;grid-template-columns:1fr 1fr;gap:10px}.editor .wide{grid-column:span 2}textarea{background:#091421;color:#f2f5ff;border:1px solid #394b63;border-radius:10px;padding:10px;width:100%;min-height:90px}#compareCards{grid-template-columns:repeat(3,1fr)}@media(max-width:750px){header{padding:14px}.shell{padding:12px 12px 105px}.columns{grid-template-columns:1fr;gap:0}.panel{padding:15px}.modes{position:sticky;top:0;background:#080e17e8;padding:8px 0;z-index:10;backdrop-filter:blur(12px)}.modes button{font-size:11px;padding:12px 2px}.hero .num{font-size:37px}.sticky{display:flex;position:fixed;bottom:0;left:0;right:0;background:#111a2df2;border-top:1px solid #625aff;padding:13px 17px;justify-content:space-between;align-items:center;z-index:20;backdrop-filter:blur(15px)}.sticky strong{font-size:22px;color:#51e6bf}#compareCards{grid-template-columns:repeat(2,1fr)}.country .amount{font-size:21px}.sheet{padding:16px}.metrics b{font-size:16px}}


.nav{position:fixed!important;z-index:80;bottom:0;left:0;right:0;margin:0!important;padding:8px 12px calc(8px + env(safe-area-inset-bottom));background:#0a111e;border-top:1px solid #27354c;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px}
.nav button{border:0!important;background:transparent!important;border-radius:9px!important;min-height:54px;padding:5px 2px!important;color:#94a5c0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:11px!important}
.nav button.on{color:#9186ff!important}.nav-icon{font-size:20px;line-height:23px}
body{padding-bottom:calc(135px + env(safe-area-inset-bottom))}
.currency-pair{font-size:12px;color:#91a6c0;margin-top:5px;min-height:14px}
.sticky-amount{display:flex;flex-direction:column;align-items:flex-end;gap:1px}
.sticky-amount small{font-size:11px;color:#94a5c0;font-weight:400}
.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
.goal-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.goal-choices button{background:#0b1523;border:1px solid #35455f;border-radius:9px;padding:10px 4px;font-size:12px;min-height:42px}
.goal-choices button.on{border-color:#7568ff;background:#3530a4;color:white}

.nav svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.settings-intro{margin:4px 0 14px}.settings-intro h2{font-size:20px;margin:0 0 5px}.settings-intro p{font-size:12px;color:#94a7c1;margin:0}
.settings-group{border:1px solid #30415b;background:#121f31;border-radius:14px;margin-bottom:10px;overflow:hidden}
.settings-group summary{list-style:none;cursor:pointer;display:flex;justify-content:space-between;align-items:center;min-height:66px;padding:12px 15px}
.settings-group summary::-webkit-details-marker{display:none}
.settings-group summary strong{display:block;font-size:15px;color:#f0f4fc}
.settings-group summary small{display:block;font-size:11px;color:#92a7c3;margin-top:4px}
.settings-group summary i{border-right:2px solid #a5b4ce;border-bottom:2px solid #a5b4ce;width:8px;height:8px;transform:rotate(45deg);margin-right:5px}
.settings-group[open] summary i{transform:rotate(225deg)}
.settings-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 10px;padding:4px 13px 16px;border-top:1px solid #2b3c52}
.settings-fields .field{min-width:0;margin-top:10px}.settings-fields label{font-size:11px;line-height:1.35;min-height:29px;display:flex;align-items:end}
.settings-fields input,.settings-fields select{height:43px;min-height:43px;font-size:15px;padding:8px 10px;max-width:100%}
.settings-template,.settings-advanced{padding:14px;border-top:1px solid #2b3c52}
.settings-template .toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.settings-template .toolbar button{font-size:12px;padding:9px 6px;min-width:0}
#settings #apply{margin-top:12px}
@media(min-width:700px){.settings-fields{grid-template-columns:repeat(3,minmax(0,1fr))}}

/* v0.8.5 mobile-first currency pair placement */
#marketRow>.currency-pair,#priceRow>.currency-pair,#costRow>.currency-pair{display:block!important;position:static!important;grid-column:1/-1!important;width:100%!important;margin:6px 0 0!important;line-height:1.4!important;text-align:left!important}
#ratioRow{display:none!important}
@media(max-width:699px){#marketRow,#priceRow,#costRow{grid-column:1/-1!important}#marketRow .moneyrow,#priceRow .moneyrow,#costRow .moneyrow{width:100%;min-width:0}#marketRow>.currency-pair,#priceRow>.currency-pair,#costRow>.currency-pair{font-size:12px!important}}

#marketRow .market-input-line{display:grid;grid-template-columns:minmax(0,1fr) 86px;gap:8px;align-items:center;width:100%}
#marketRow .market-input-line input{min-width:0;width:100%}
#marketRow .market-input-line select{width:86px!important;max-width:86px!important;min-width:0}
#marketRow>#marketPair{display:block!important;position:static!important;margin:7px 0 0!important;width:100%!important;max-width:100%!important;grid-column:1/-1!important;text-align:left!important;white-space:normal!important;font-size:12px!important}
#ratioRow{display:none!important}

/* v0.8.8: iPhone viewport stability; vertical scrolling stays enabled */
html{width:100%;max-width:100%;overflow-x:clip;overscroll-behavior-x:none;overscroll-behavior-y:none}
body{width:100%;max-width:100%;min-width:0;overflow-x:clip;overscroll-behavior-x:none;overscroll-behavior-y:none}
.shell,header,.page,.columns,.panel,.grid,.field,.top,.modes,.section,.hero,.cards,.country,.settings-group,.settings-fields{min-width:0;max-width:100%}
input,select,textarea{max-width:100%}
.sheet{overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
@media(max-width:750px){
 html,body{touch-action:pan-y;overscroll-behavior:none}
 .shell{width:100%;overflow-x:clip}
 .top>*{min-width:0}
 .top select{max-width:100%}
 .columns,.grid{min-width:0}
 .country{overflow-wrap:anywhere}
 .field input,.field select,.top select,textarea{font-size:16px}
 .modal{max-width:100vw;overflow-x:hidden}
 .sheet{max-width:100%;overflow-x:hidden}
 .row{min-width:0}
 .row span{min-width:0;overflow-wrap:anywhere}
 .row strong{min-width:0;text-align:right;overflow-wrap:anywhere}
}

/* v0.8.13: detail overlay and accessible close control */
#modal.modal{z-index:120;align-items:center;padding:12px;overflow:hidden}
#modal .sheet{position:relative;max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scroll-padding-bottom:24px;padding-bottom:calc(28px + env(safe-area-inset-bottom))}
#modal .sheethead{position:sticky;top:-16px;z-index:2;min-height:44px;padding:4px 0 8px;background:linear-gradient(180deg,#121e2d 78%,rgba(18,30,45,.94));}
#modal .sheethead h2{padding-right:52px}
#modal .modal-close-circle{flex:none;display:flex;align-items:center;justify-content:center;width:42px;height:42px;min-width:42px;padding:0;border-radius:50%;border:1px solid rgba(210,224,244,.36);background:rgba(30,43,61,.72);color:#f0f5ff;font-size:27px;line-height:1;font-weight:400;box-shadow:0 2px 9px rgba(0,0,0,.15);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
#modal .modal-close-circle:focus-visible{outline:2px solid #50e7bf;outline-offset:2px}
@media(max-width:650px){#modal .sheethead{top:-16px}}

#modal .sheethead{top:0}

/* v0.8.14: title scrolls normally; only close control stays visible */
#modal .sheethead{position:static;min-height:44px;padding:4px 0 8px;background:none;z-index:auto}
#modal .modal-close-circle{position:sticky;top:0;z-index:5;margin-left:auto;margin-bottom:-42px}


/* Desktop layout */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  header { max-width: 1440px; padding: 20px 28px; }
  .shell { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; max-width: 1440px; padding: 72px 28px 60px; }
  .shell > .nav { position: absolute !important; top: -57px !important; right: 28px !important; left: auto !important; bottom: auto !important; width: auto !important; display: flex !important; flex-direction: row !important; background: transparent !important; border: 0 !important; gap: 8px; padding: 0; }
  .shell > .nav button { width: auto !important; min-width: 80px; padding: 10px 14px; font-size: 14px; }
  .shell > .nav svg { display: none; }
  .shell::before { content: '利益計算'; position: absolute; top: 22px; left: 28px; font-size: 26px; font-weight: 700; }
  .shell > .top { grid-column: 2; grid-row: 1; margin: 0; justify-self: end; width: min(420px,100%); }
  .shell > .modes { grid-column: 1 / -1; grid-row: 2; width: min(540px,100%); margin: 0; }
  .shell > .page { grid-column: 1 / -1; grid-row: 3; min-width: 0; }
  .shell > p { grid-column: 1 / -1; grid-row: 4; }
  #calc .columns { display: grid; grid-template-columns: minmax(0,.95fr) minmax(0,1.05fr); gap: 20px; align-items: start; }
  #calc .columns > div:nth-child(2) { display: contents; }
  #calc .panel { padding: 24px; border-radius: 14px; }
  #calc .hero { min-height: 340px; }
  #calc .section { grid-column: 1 / -1; }
  #previewCards { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
  #calc .moneyfield, #marketRow { display: grid; grid-template-columns: minmax(150px,1fr) minmax(220px,1.1fr); align-items: center; gap: 4px 12px; }
  #calc .moneyfield label, #marketRow label { grid-column: 1; }
  #calc .moneyrow, #marketRow .market-input-line { grid-column: 2; margin: 0; }
  #calc .currency-pair { grid-column: 2; }
  #calc .grid { gap: 12px; }
  #resetCardInputs, #saveHistory { width: auto; display: inline-block; margin-top: 12px; }
}
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  header > .small { visibility: hidden; }
  #calc .columns > div:first-child { position: relative; }
  #calc .columns > div:first-child > .panel { padding-bottom: 84px; }
  #resetCardInputs, #saveHistory { position: absolute; bottom: 24px; margin: 0; }
  #resetCardInputs { left: 24px; }
  #saveHistory { right: 24px; }
  #calc .hero::before { content: '計算結果'; display: block; font-size: 18px; font-weight: 700; margin-bottom: 18px; }
}
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .shell::before { content: none; }
  .shell:has(#calc.on)::before { content: '利益計算'; }
  #calc .hero { position: relative; }
  #calc .hero > div:first-child { position: absolute; top: 27px; right: 24px; gap: 10px; }
  #calc .hero > div:first-child strong { font-size: 14px; }
  #calc .hero #resultLabel { margin-top: 22px !important; }
  #calc #previewCards { grid-column: 1 / -1; }
  #calc .columns > div:first-child > .panel { min-height: 350px; }
  #calc .hero { min-height: 350px; }
}
