/* Screenshot Annotator — すべてローカル。外部フォント/外部リソースは読み込まない */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
          system-ui, sans-serif;

  --accent: #0A84FF;
  --accent-ink: #ffffff;

  --bg: #ececf0;
  --bg-grad: radial-gradient(120% 100% at 50% 0%, #f7f7fa 0%, #e7e7ec 62%, #e2e2e8 100%);
  --ink: #1c1c1e;
  --ink-2: #6b6b72;
  --ink-3: #97979e;

  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;
  --panel-border: rgba(0, 0, 0, 0.09);
  --hairline: rgba(0, 0, 0, 0.07);
  --hover: rgba(0, 0, 0, 0.055);
  --press: rgba(0, 0, 0, 0.1);
  --sel-bg: rgba(10, 132, 255, 0.13);

  --shadow-panel: 0 10px 34px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.07),
                  0 0 0 0.5px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-canvas: 0 14px 40px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);

  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 8px;

  --t: 150ms cubic-bezier(0.32, 0.72, 0, 1);

  --topbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --bg-grad: radial-gradient(120% 100% at 50% 0%, #232326 0%, #171719 60%, #101012 100%);
    --ink: #f2f2f5;
    --ink-2: #a0a0a8;
    --ink-3: #75757c;

    --panel: rgba(44, 44, 48, 0.72);
    --panel-solid: #2a2a2e;
    --panel-border: rgba(255, 255, 255, 0.1);
    --hairline: rgba(255, 255, 255, 0.08);
    --hover: rgba(255, 255, 255, 0.08);
    --press: rgba(255, 255, 255, 0.14);
    --sel-bg: rgba(10, 132, 255, 0.26);

    --shadow-panel: 0 12px 40px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4),
                    0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-card: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-canvas: 0 18px 48px rgba(0, 0, 0, 0.6), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-grad);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ───────────────────────── Top bar ───────────────────────── */

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  min-width: 0;
}
.brand .ico { width: 19px; height: 19px; }
.brand-name {
  font-size: 13px;
  font-weight: 590;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-sep {
  width: 1px;
  height: 20px;
  margin: 0 2px;
  background: var(--hairline);
}

/* ───────────────────────── Buttons ───────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--panel-border);
  border-radius: var(--r-sm);
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 510;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t),
              transform var(--t), opacity var(--t), box-shadow var(--t);
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover { background: color-mix(in srgb, var(--panel-solid) 85%, var(--hover)); }
.btn:active { transform: scale(0.975); background: color-mix(in srgb, var(--panel-solid) 78%, var(--press)); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-primary:active { background: color-mix(in srgb, var(--accent) 78%, #000); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  font-size: 12px;
  gap: 4px;
}
.btn-ghost:hover { background: var(--hover); color: var(--ink); }

.btn-lg {
  min-height: 36px;
  padding: 0 18px;
  font-size: 13.5px;
  border-radius: var(--r-md);
}

.btn:focus-visible,
.tool:focus-visible,
.swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ───────────────────────── Stage ───────────────────────── */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: default;
}

/* ───────────────────────── Empty state ───────────────────────── */

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}
.empty[hidden] { display: none; }

.empty-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 40px 48px;
  border-radius: 20px;
  border: 1px solid var(--hairline);
  background: var(--panel);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-card);
  animation: rise 420ms cubic-bezier(0.22, 0.7, 0.15, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.empty-art {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  color: var(--ink-3);
}
.empty-art svg {
  width: 64px; height: 64px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.empty-title {
  margin: 0;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.empty-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.empty-note {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

.empty-tip {
  width: 100%;
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-3);
}
.empty-tip:empty { display: none; }
.empty-tip kbd { font-size: 11px; padding: 1px 5px; }

kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 560;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-solid);
  box-shadow: 0 1px 0 var(--hairline);
}

/* ───────────────────────── Toolbar ───────────────────────── */

.toolbar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  max-width: calc(100% - 32px);
  flex-wrap: wrap;
  justify-content: center;
  border-radius: var(--r-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-panel);
  z-index: 20;
  transition: opacity var(--t), transform var(--t);
}
.toolbar[hidden] { display: none; }

.group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.group[hidden] { display: none; }

.sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 5px;
  background: var(--hairline);
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: background var(--t), color var(--t), transform var(--t), opacity var(--t);
}
.tool .ico { width: 19px; height: 19px; }
.tool:hover { background: var(--hover); }
.tool:active { transform: scale(0.94); }
.tool.is-active { background: var(--sel-bg); color: var(--accent); }
.tool:disabled { opacity: 0.32; pointer-events: none; }

.tool-sm { width: 32px; height: 36px; }
.tool-sm .ico { width: 20px; height: 20px; }

.label-s, .label-m, .label-l { font-weight: 600; letter-spacing: -0.02em; }
.label-s { font-size: 11px; }
.label-m { font-size: 14px; }
.label-l { font-size: 17px; }

.swatches { gap: 3px; padding: 0 2px; }

.swatch {
  position: relative;
  width: 26px;
  height: 36px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.swatch i {
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  transition: transform var(--t), box-shadow var(--t);
}
@media (prefers-color-scheme: dark) {
  .swatch i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
}
.swatch:hover i { transform: scale(1.12); }
.swatch.is-active i {
  transform: scale(1.0);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2),
              0 0 0 2px var(--panel-solid),
              0 0 0 4px var(--accent);
}

#badge-next { font-size: 14px; line-height: 1; }

/* ───────────────────────── Text editor overlay ───────────────────────── */

.text-editor {
  position: absolute;
  display: none;
  min-width: 12px;
  max-width: 70%;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
  caret-color: currentColor;
  z-index: 15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  transform-origin: 0 0;
}
.text-editor.is-open { display: block; }

/* ───────────────────────── Dropzone ───────────────────────── */

.dropzone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
  z-index: 40;
}
.dropzone.is-on { opacity: 1; }

.dropzone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 56px;
  border-radius: 20px;
  border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--panel);
  color: var(--accent);
  font-size: 14px;
  font-weight: 560;
  box-shadow: var(--shadow-card);
}
.dropzone-card .ico { width: 34px; height: 34px; stroke-width: 1.5; }

/* ───────────────────────── Footer ───────────────────────── */

.footer {
  position: fixed;
  right: 14px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
  pointer-events: none;
  z-index: 10;
}
.footer .ico { width: 12px; height: 12px; stroke-width: 1.9; }

/* ───────────────────────── Toasts ───────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--topbar-h) + 16px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-panel);
  font-size: 12.5px;
  font-weight: 510;
  color: var(--ink);
  animation: toast-in 220ms cubic-bezier(0.22, 0.7, 0.15, 1) both;
}
.toast.is-out { animation: toast-out 180ms ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 720px) {
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 8px; }
  .brand-name { display: none; }
}
