/* dark by default */
:root {
  color-scheme: dark;
  --bg: #1a1a1a;
  --fg: #d4d4d4;
  --panel: #262626;
  --border: #3c3c3c;
  --accent: #4a9eff;
}
:root:not(.dark) {
  color-scheme: light;
  --bg: #f5f5f5;
  --fg: #222;
  --panel: #fff;
  --border: #ccc;
  --accent: #1a73e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
}

h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

/* ---- menu ---- */
#menu {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
}
#menu-btn {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.35rem 0.6rem;
}
#menu-panel {
  position: absolute;
  top: 2.4rem;
  right: 0;
  min-width: 15rem;
  padding: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
#menu-panel hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.4rem 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.3rem;
  font-size: 0.9rem;
  white-space: nowrap;
}
label.row { cursor: pointer; }
label.row:hover { background: var(--bg); border-radius: 4px; }
#opt-threshold { flex: 1; min-width: 0; }
#threshold-val {
  min-width: 2.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- controls ---- */
#controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

button {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 1.1rem;
  font: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }

/* ---- preview ---- */
#preview {
  border: 1px dashed var(--border);
  border-radius: 6px;
  min-height: 16rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  overflow: auto;
}
#preview.dragover { border-color: var(--accent); }
#result {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  /* keep the iOS long-press menu ("Add to Photos") available */
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
#placeholder {
  margin: 0;
  opacity: 0.6;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.6;
}

#info {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  opacity: 0.7;
}

#hint {
  font-size: 0.8rem;
  opacity: 0.7;
  white-space: nowrap;
}
