:root {
  --bar-bg: #fbfbfa; --bar-ink: #1f2328; --bar-muted: #6b6f76; --bar-line: #e6e6e3;
  --btn-hover: #efefec; --accent: #2f6fdd; --toast-bg: #1f2328; --toast-ink: #fff;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bar-bg: #1e1e1e; --bar-ink: #e6e7ea; --bar-muted: #9a9ea6; --bar-line: #2d2d2d;
  --btn-hover: #2c2c2c; --accent: #7aa7ff; --toast-bg: #e6e7ea; --toast-ink: #15171c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bar-bg); color: var(--bar-ink);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
.bar {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 44px; padding: 0 10px; padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--bar-line); background: var(--bar-bg);
  -webkit-app-region: drag; app-region: drag;
}
.bar a, .bar button { -webkit-app-region: no-drag; app-region: no-drag; }
.brand {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 2px; border-radius: 6px;
  color: inherit; text-decoration: none; font-weight: 600; letter-spacing: .01em; font-size: 14px;
}
.brand:hover { background: var(--btn-hover); }
.brand img { border-radius: 5px; display: block; }
.actions { display: flex; align-items: center; gap: 2px; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--bar-line); }
.bar button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.bar button:hover { background: var(--btn-hover); }
.bar button:focus-visible, .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.bar button.secondary { color: var(--bar-muted); }
.doc { flex: 1; min-width: 0; display: flex; justify-content: center; }
.docname {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--bar-muted); font-size: 13px;
}
.docname.dirty::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.status { color: var(--bar-muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.bar button.install { color: var(--accent); }
#editor { flex: 1; width: 100%; border: 0; display: block; background: transparent; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 9px 14px; border-radius: 8px; background: var(--toast-bg); color: var(--toast-ink);
  box-shadow: 0 6px 24px rgb(0 0 0 / .18); transition: opacity .18s, transform .18s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }
@media (max-width: 720px) {
  .bar button .label, .brand .word, .status { display: none; }
  .bar button { padding: 0 8px; }
}
@media (max-width: 420px) { .bar button.secondary { display: none; } }
