:root {
  color-scheme: dark;
  --orange: #ff4f00;
  --ink: #101010;
  --paper: #f5efe6;
  --muted: #aaa49c;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 240px;
  height: 100%;
  min-height: 282px;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font: 13px/1.2 system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
}

button { font: inherit; }

#app, .view {
  position: absolute;
  inset: 0;
}

.view { display: none; }
.view.active { display: block; }

#camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050505;
}

.camera-topbar,
.toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: linear-gradient(#000b, transparent);
}

.brand { font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.counter, .pill { padding: 4px 7px; border-radius: 999px; background: #000a; font-size: 10px; }

.camera-message {
  position: absolute;
  top: 50%;
  left: 15px;
  right: 15px;
  transform: translateY(-50%);
  padding: 10px;
  border: 1px solid #ffffff55;
  border-radius: 8px;
  color: white;
  background: #000c;
  font-weight: 700;
  text-align: center;
}

.camera-message:empty { display: none; }

.camera-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.round-button, .icon-button, .shutter {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: #111c;
}

.round-button, .icon-button { width: 39px; height: 39px; font-size: 20px; }
.shutter { width: 56px; height: 56px; border: 3px solid white; background: #0006; }
.shutter span { width: 42px; height: 42px; border-radius: 50%; background: var(--orange); }
.shutter:active span { transform: scale(.86); }

.panel { background: var(--paper); color: var(--ink); }
.panel .toolbar { position: relative; background: var(--orange); color: white; }
.toolbar h1 { margin: 0; font-size: 15px; }
.text-button { border: 0; padding: 8px 0; color: inherit; background: none; }

.gallery {
  height: calc(100% - 42px);
  padding: 5px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 74px;
  gap: 4px;
}

.thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 5px;
  padding: 0;
  overflow: hidden;
  background: #ddd;
}

.thumb.selected { border-color: var(--orange); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .star { position: absolute; right: 3px; top: 2px; color: #ffd64a; text-shadow: 0 1px 2px #000; }
.empty { position: absolute; inset: 42px 15px 0; display: grid; place-items: center; margin: 0; text-align: center; color: #625d57; }
.gallery:not(:empty) + .empty { display: none; }

.viewer { background: #000; }
.viewer > img { width: 100%; height: 100%; object-fit: contain; }
.toolbar.overlay { background: linear-gradient(#000c, transparent); }
.viewer-actions {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 7px;
  display: flex;
  justify-content: center;
  gap: 5px;
}

.action-button {
  min-height: 34px;
  border: 1px solid #ffffff55;
  border-radius: 7px;
  padding: 0 10px;
  color: white;
  background: #222e;
}
.danger { background: #a52820e8; }

.toast {
  position: absolute;
  z-index: 9;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px;
  border-radius: 7px;
  background: #000e;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.toast.show { opacity: 1; }

dialog {
  width: 210px;
  border: 0;
  border-radius: 10px;
  padding: 14px;
  color: white;
  background: #242424;
}
dialog::backdrop { background: #000a; }
dialog p { margin: 0 0 14px; text-align: center; }
dialog div { display: flex; justify-content: center; gap: 6px; }

@media (min-width: 300px) {
  #app { width: 240px; height: 282px; top: 50%; left: 50%; transform: translate(-50%, -50%); box-shadow: 0 8px 50px #0008; }
}
