/* アクティビティ図作成君 - 白黒・角ばったシンプルなデザイン（回路図計算君と同じ） */
:root {
  --fg: #111;
  --mute: #6b6b6b;
  --line: #111;
  --soft: #d4d4d4;
  --panel: #f3f3f3;
  --hi: #e8e8e8;
  --font: "BIZ UDPGothic", "BIZ UDゴシック", "Yu Gothic UI", "Meiryo", sans-serif;
  --mono: "BIZ UDGothic", "Consolas", "Menlo", monospace;
  --math: "Cambria Math", "Cambria", "Times New Roman", "BIZ UDPMincho", serif;
}
* { box-sizing: border-box; border-radius: 0; }
html, body { margin: 0; height: 100%; background: #fff; color: var(--fg); font-family: var(--font); font-size: 13px; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }

#app {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

/* ---------- ヘッダー（ツールバー） ---------- */
header {
  grid-column: 1 / 3;
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid var(--line);
  background: #fff;
  min-width: 0;
  overflow-x: auto;
}
.brand {
  display: flex; align-items: center;
  padding: 0 16px;
  font-size: 15px; font-weight: 700; letter-spacing: .12em;
  border-right: 2px solid var(--line);
  white-space: nowrap;
}
.group { display: flex; border-right: 2px solid var(--line); }
[hidden] { display: none !important; }   /* hidden 属性を付けた要素は、display の指定があっても必ず隠す */
.group.right { border-right: none; border-left: 2px solid var(--line); }
.spacer { flex: 1; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 58px; padding: 6px 8px;
  border: none; border-right: 1px solid var(--soft);
  background: #fff; cursor: pointer; white-space: nowrap;
}
.group .tool:last-child { border-right: none; }
.tool.sm { min-width: 58px; }
.tool svg { width: 28px; height: 16px; display: block; }
.tool .k { font-family: var(--mono); font-size: 10px; color: var(--mute); }
.tool:hover { background: var(--hi); }
.tool.active { background: var(--fg); color: #fff; }
.tool.active .k { color: #bdbdbd; }
/* 画面が狭いときはボタンを詰めて、右端（パネル・Pro）まで見えるようにする */
@media (max-width: 1700px) {
  .brand { padding: 0 10px; letter-spacing: .06em; }
  .tool { min-width: 50px; padding: 6px 6px; }
  .tool.sm { min-width: 46px; }
}
@media (max-width: 1560px) {
  .brand { padding: 0 8px; letter-spacing: 0; font-size: 14px; }
  .tool { min-width: 40px; padding: 6px 3px; font-size: 12px; }
  .tool.sm { min-width: 38px; }
  .tool .k { font-size: 9px; }
}
@media (max-width: 1420px) {
  .ed-badge { display: none; }
  .tool { min-width: 36px; padding: 6px 2px; font-size: 11px; }
  .tool .k { display: none; }
  
}
/* さらに狭い画面（ウィンドウを半分にしたとき・タブレット）：ツールバーは 2 段に折り返し、右のパネルを細くする */
@media (max-width: 1100px) {
  #app { grid-template-columns: 1fr 300px; }
  header { flex-wrap: wrap; overflow-x: visible; }
  header .group { border-bottom: 1px solid var(--line); }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr 260px; }
  .brand { font-size: 13px; padding: 6px 10px; line-height: 1.5; }
  footer .hint { display: none; }
}
/* スマホ：見出しは 1 行に、ツールのボタンも折り返す */
@media (max-width: 600px) {
  .brand { flex: 1 0 100%; border-right: none; border-bottom: 1px solid var(--line); }
  header .group { flex-wrap: wrap; }
}
/* タッチ画面ではキーボードの表記（Ctrl+R・Del・Enter など）を出さない */
@media (hover: none) and (pointer: coarse) {
  #props .pft small, .tool .k.key, kbd { display: none; }
}

/* ---------- キャンバス ---------- */
#stage { position: relative; overflow: hidden; border-right: 2px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
#cvWrap { position: relative; flex: 1; min-height: 0; }
#cv { display: block; width: 100%; height: 100%; }

/* ---------- 右パネル ---------- */
aside { background: var(--panel); overflow-y: auto; }
aside section + section { border-top: 2px solid var(--line); }
aside h2 {
  margin: 0; padding: 6px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .15em;
  background: var(--fg); color: #fff;
}
.sec { padding: 10px 12px; }
.st { padding: 6px 8px; margin-bottom: 6px; border: 1px solid var(--line); background: #fff; line-height: 1.5; }
.st-ok { border-left: 6px solid var(--fg); }
.st-e { border: 2px solid var(--fg); font-weight: 700; }
.st-w { border-style: dashed; }
.st-i { color: var(--mute); }
.chk { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; color: var(--mute); cursor: pointer; }
.chk input { accent-color: #111; margin: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; }
th, td { border: 1px solid #9a9a9a; padding: 4px 6px; text-align: left; vertical-align: top; }
th { background: #e2e2e2; font-weight: 700; }
td:nth-child(3), td:nth-child(4) { font-family: var(--mono); white-space: nowrap; text-align: center; width: 28px; }
.tot { margin-top: 8px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); line-height: 1.6; }
.mute { color: var(--mute); }

.fl { background: #fff; border: 1px solid #b5b5b5; padding: 6px 8px; margin-bottom: 6px; }
.ft { font-size: 11px; color: var(--mute); margin-bottom: 3px; }
.fh { font-family: var(--math); font-size: 15px; line-height: 1.9; }
.fh b { font-family: var(--math); }

.help dl { margin: 0 0 8px; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.help dt { font-family: var(--mono); font-size: 11px; font-weight: 700; white-space: nowrap; }
.help dd { margin: 0; }
.help p { margin: 8px 0 0; line-height: 1.6; }

/* ---------- 分数・添字 ---------- */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; line-height: 1.25; }
.frac > span { padding: 0 3px; white-space: nowrap; }
.frac > span:first-child { border-bottom: 1px solid currentColor; }
sub, sup { font-size: 70%; line-height: 0; }

/* ---------- ステータスバー ---------- */
footer {
  grid-column: 1 / 3;
  display: flex; align-items: stretch;
  border-top: 2px solid var(--line);
  font-size: 12px; background: #fff; white-space: nowrap; overflow: hidden;
}
footer span { padding: 4px 12px; border-right: 1px solid var(--soft); }
#sbMode { font-weight: 700; }
#sbPos { font-family: var(--mono); min-width: 80px; }
footer .hint { color: var(--mute); overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
#sbMsg { border-right: none; border-left: 1px solid var(--soft); }
#sbMsg.on { background: var(--fg); color: #fff; }
#sbMsg:empty { display: none; }
#sbMsg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-btn { flex: none; margin-left: auto; border: none; border-left: 1px solid var(--soft); background: #fff; padding: 4px 12px; cursor: pointer; white-space: nowrap; }
.sb-btn:hover { background: var(--fg); color: #fff; }
#cv { touch-action: none; }                 /* タッチ操作はアプリで処理する（ページのスクロール・拡大をしない） */
#cv:focus { outline: none; }

/* ---------- 公式ツールチップ ---------- */
#tooltip {
  position: fixed; z-index: 50; display: none; pointer-events: none;
  max-width: 560px; max-height: calc(100vh - 16px); overflow: hidden; background: #fff;
  border: 2px solid var(--fg); box-shadow: 5px 5px 0 rgba(0, 0, 0, .18);
}
.tt-h { display: flex; align-items: baseline; gap: 8px; padding: 5px 10px; background: var(--fg); color: #fff; font-family: var(--math); font-size: 16px; font-weight: 700; }
.tt-h small { font-family: var(--font); font-size: 11px; font-weight: 400; color: #ccc; }
.tt-sum { padding: 6px 10px; border-bottom: 1px solid var(--soft); font-family: var(--math); font-size: 14px; background: #f4f4f4; }
.tt-s { padding: 6px 10px 2px; font-size: 12px; font-weight: 700; }
#tooltip .fl { margin: 3px 10px 5px; }
.tt-n { margin: 3px 10px 6px; padding: 4px 8px; border-left: 3px solid var(--fg); background: #f4f4f4; font-size: 12px; line-height: 1.5; }
#tooltip > :last-child { margin-bottom: 10px; }

/* ---------- プロパティ ---------- */
#props {
  position: fixed; z-index: 60; display: none; width: 300px;
  background: #fff; border: 2px solid var(--fg); box-shadow: 5px 5px 0 rgba(0, 0, 0, .18);
}
.phd { display: flex; justify-content: space-between; align-items: center; background: var(--fg); color: #fff; padding: 0 0 0 10px; font-weight: 700; letter-spacing: .1em; }
.px { border: none; background: transparent; color: #fff; width: 30px; height: 28px; font-size: 16px; cursor: pointer; }
.px:hover { background: #444; }
.pbd { padding: 10px; }
.pf { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 2px 8px; margin-bottom: 8px; }
.pl { font-size: 12px; }
.pf input, .pf select { width: 100%; padding: 4px 6px; border: 1px solid var(--fg); background: #fff; font-family: var(--mono); }
.pf input:focus, .pf select:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
.ph { grid-column: 2; font-size: 11px; color: var(--mute); line-height: 1.4; }
.pv { font-family: var(--mono); font-size: 12px; }
.pres { padding: 6px 8px; background: var(--panel); border: 1px solid var(--soft); font-size: 12px; line-height: 1.6; }
.pft { display: flex; border-top: 1px solid var(--fg); }
.pft button { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 5px 0; border: none; border-right: 1px solid var(--soft); background: #fff; cursor: pointer; }
.pft button:last-child { border-right: none; }
.pft button:hover { background: var(--hi); }
.pft button.pri { background: var(--fg); color: #fff; }
.pft button.pri:hover { background: #333; }
.pft small { font-family: var(--mono); font-size: 10px; color: var(--mute); }
.pft .pri small { color: #bbb; }

/* ---------- 交流まわり ---------- */
.pin2 { display: flex; gap: 4px; }
.pin2 input { flex: 1; min-width: 0; }
.pin2 select { width: 64px; flex: none; }
.polar { font-size: 13px; color: var(--mute); margin-left: 4px; }
.ana .pf { grid-template-columns: 120px 1fr; }
#anaInfo { font-size: 12px; line-height: 1.6; }
.help code { font-family: var(--mono); font-size: 11px; background: #fff; border: 1px solid var(--soft); padding: 0 3px; }
th { white-space: nowrap; }

.pin3 { display: flex; gap: 4px; align-items: center; }
.pin3 select { flex: 1; min-width: 0; }
.pin3 input { width: 52px; flex: none; }
.pin3 input:disabled { color: #aaa; border-color: #bbb; }
.pin3 span { font-size: 11px; white-space: nowrap; }
#secRange .sec { background: #fff; }
#secRange .fl { border-color: #888; }
.rg-h { font-size: 11px; margin-bottom: 6px; }

#cvWrap #cv { position: absolute; inset: 0; }
/* 公式が長くて画面に入らないときは2段組みにする */
#tooltip.cols2 { max-width: min(1120px, calc(100vw - 16px)); column-count: 2; column-gap: 0; column-rule: 1px solid var(--soft); }
#tooltip.cols2 .tt-h, #tooltip.cols2 .tt-sum { column-span: all; }
#tooltip .fl, #tooltip .tt-n { break-inside: avoid; }
#tooltip .tt-s { break-after: avoid; }
.k-hint { font-family: var(--mono); font-size: 10px; color: #999; margin-left: 4px; }

.ed-badge { margin-left: 8px; padding: 1px 6px; border: 1px solid currentColor; font-size: 11px; letter-spacing: .05em; font-weight: 400; }
body.noside #app { grid-template-columns: 1fr; }
body.noside #side { display: none; }
body.noside #stage { border-right: none; }
aside h2 { cursor: pointer; user-select: none; }
aside h2::before { content: "▾ "; }
aside section.folded h2::before { content: "▸ "; }
aside section.folded > :not(h2) { display: none !important; }
aside section.user-hidden { display: none !important; }
#panelCfg { padding: 6px 12px; border-bottom: 2px solid var(--line); background: #fff; font-size: 12px; }
#panelCfg summary { cursor: pointer; font-weight: 700; }
#panelCfgList label { display: block; margin: 3px 0; }

/* ---------- アクティビティ図作成君で足したもの ---------- */
.st-n { color: #444; border-style: dotted; font-size: 12px; }
.st.clk, tr.clk { cursor: pointer; }
.st.clk:hover { background: var(--hi); }
tr.clk:hover td { background: var(--hi); }
.stat { margin: 8px 0 4px; font-size: 12px; }
.pf textarea { width: 100%; padding: 4px 6px; border: 1px solid var(--fg); background: #fff; font: inherit; resize: vertical; line-height: 1.5; }
.pf textarea:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
.pin2 input { font-family: var(--mono); }
.pbtns { display: flex; gap: 6px; margin: 0 0 8px; }
.pbtns button, .run-btns button, .choice { border: 1px solid var(--fg); background: #fff; cursor: pointer; padding: 4px 8px; }
.pbtns button:hover, .run-btns button:hover, .choice:hover { background: var(--hi); }
.pbtns button:disabled, .run-btns button:disabled { opacity: .4; cursor: default; background: #fff; }
.pbtns button { flex: 1; font-size: 12px; }
.run-btns { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; margin-bottom: 10px; }
.run-btns button { display: flex; flex-direction: column; align-items: center; padding: 5px 2px; border-right-width: 0; white-space: nowrap; }
.run-btns button:last-child { border-right-width: 1px; }
.run-btns small { font-family: var(--mono); font-size: 10px; color: var(--mute); }
#runChoice .ft { margin: 4px 0; font-size: 12px; color: var(--fg); font-weight: 700; }
.choice { display: block; width: 100%; text-align: left; margin-bottom: 4px; padding: 6px 8px; background: #fff; }
.choice b { display: inline-block; min-width: 18px; text-align: center; background: var(--fg); color: #fff; margin-right: 6px; font-family: var(--mono); }
#runLog { margin: 8px 0 0; padding: 0; list-style: none; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid #b5b5b5; font-size: 12px; }
#runLog:empty { display: none; }
#runLog li { display: flex; gap: 6px; padding: 3px 6px; border-bottom: 1px solid #eee; line-height: 1.5; }
#runLog li .n { flex: none; min-width: 22px; text-align: right; font-family: var(--mono); color: var(--mute); }
#runLog li.now { background: var(--hi); font-weight: 700; }
.lib { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.lib svg { flex: none; margin-top: 2px; }
.lib .ft { color: var(--fg); font-weight: 700; font-size: 12px; margin-bottom: 1px; }
#tooltip .fl { font-family: var(--font); font-size: 13px; }

/* ---------- PlantUML の読み込み ---------- */
#pumlDlg { border: 2px solid var(--line); padding: 0; width: min(680px, 94vw); box-shadow: 5px 5px 0 rgba(0, 0, 0, .18); }
#pumlDlg::backdrop { background: rgba(0, 0, 0, .35); }
#pumlForm { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
#pumlForm h3 { margin: 0; font-size: 15px; }
.dl-note { margin: 0; font-size: 12px; color: var(--mute); line-height: 1.6; }
#pumlText { font-family: var(--mono); font-size: 13px; line-height: 1.5; padding: 8px; border: 1px solid var(--line); resize: vertical; tab-size: 2; }
#pumlText:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
#pumlMsg { font-size: 12px; line-height: 1.6; max-height: 120px; overflow-y: auto; }
#pumlMsg:empty { display: none; }
.fb-row { display: flex; align-items: center; gap: 8px; }
.fb-row .sp { flex: 1; }
.fb-row button { padding: 6px 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.fb-row button:hover { background: var(--hi); }
.fb-row button.primary { background: var(--fg); color: #fff; }
.fb-row button.primary:hover { background: #333; }
.fb-row button small { font-family: var(--mono); font-size: 10px; color: #bbb; }
body.drop #stage::after { content: "ここに放すと読み込みます（.json・.puml）"; position: absolute; inset: 8px; border: 3px dashed var(--fg); background: rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; pointer-events: none; }

/* ---------- ウェブ版だけの部品（感想・利用規約・ほかのソフト） ---------- */
body:not(.web) [data-web] { display: none !important; }
#webBar { padding: 8px 12px; border-bottom: 2px solid var(--line); background: #fff; }
#trialNote { font-size: 12px; margin-bottom: 6px; }
.web-links { font-size: 11px; margin-top: 6px; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; }
.web-links a, .fb-note a, .help a { color: var(--fg); }
#hubLink { flex-basis: 100%; text-align: left; font-weight: 700; }
/* バージョンの表記（目立たないように薄く） */
#webBar .app-ver { font-size: 10px; color: var(--mute); opacity: .65; text-align: right; margin-top: 2px; letter-spacing: .03em; }
#webBar .app-ver:empty { display: none; }
.me-note { font-size: 11px; color: var(--mute); margin-top: 6px; }
.fb-btn { width: 100%; padding: 6px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; font: inherit; font-weight: 700; }
.fb-btn:hover { background: var(--fg); color: #fff; }
#fbDialog { border: 2px solid var(--line); padding: 0; width: min(520px, 92vw); box-shadow: 5px 5px 0 rgba(0, 0, 0, .18); }
#fbDialog::backdrop { background: rgba(0, 0, 0, .35); }
#fbForm { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
#fbForm h3 { margin: 0 0 4px; font-size: 15px; }
#fbForm label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 12px; }
#fbForm label.chk { flex-direction: row; align-items: flex-start; font-weight: 400; }
#fbForm select, #fbForm input:not([type=checkbox]), #fbForm textarea { font: inherit; font-weight: 400; padding: 6px; border: 1px solid var(--line); background: #fff; }
#fbForm textarea { resize: vertical; }
#fbForm .fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#fbForm .fb-note { margin: 0; font-size: 11px; color: var(--mute); }
#fbMsg { flex: 1; font-size: 12px; }
.fb-row button:disabled { opacity: .5; cursor: default; }
