:root {
  --blue: #1746a2;
  --ink: #14213d;
  --muted: #5a6784;
  --line: #d5dbe8;
  --bg: #f3f5f9;
  color-scheme: light;
  font: 17px/1.4 system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0 auto;
  max-width: 640px;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
  -webkit-tap-highlight-color: transparent;
}
h1 { margin: 0; font-size: 26px; line-height: 1.2; }
p { margin: 0; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.danger { color: #b3261e; }
.link { display: flex; margin: 40px auto 0; border: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 400; }
:focus-visible { outline: 3px solid #f5b800; outline-offset: 2px; }
.busy { opacity: .6; pointer-events: none; }

input:not([type=file]) {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #8c97b0;
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.error { color: #b3261e; font-size: 15px; }
.error:empty { display: none; }

#install { display: grid; gap: 12px; margin-bottom: 20px; padding: 14px 16px; border-radius: 12px; background: #fff3c4; font-size: 15px; }

#login { display: grid; justify-items: center; gap: 12px; max-width: 340px; margin: 10vh auto 0; }
#login img { border-radius: 20px; }
#login form { display: grid; gap: 10px; width: 100%; margin-top: 12px; }

header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
#total { color: var(--muted); }
#add { position: relative; white-space: nowrap; }
#add:focus-within { outline: 3px solid #f5b800; outline-offset: 2px; }
#file { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
#file::file-selector-button { cursor: pointer; }
#notice { margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: #fff3c4; font-size: 15px; }
#empty { padding: 48px 24px; text-align: center; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { display: block; width: 100%; padding: 0; overflow: hidden; text-align: left; }
.card img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #e6eaf2; }
.card span { display: block; padding: 10px 14px; font-variant-numeric: tabular-nums; }
.card .unknown { color: var(--muted); font-weight: 400; }
#used img { filter: grayscale(1); opacity: .5; }
details { margin-top: 28px; }
summary { padding: 12px 0; color: var(--muted); cursor: pointer; }

dialog {
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: calc(env(safe-area-inset-top) + 8px) 0 calc(env(safe-area-inset-bottom) + 24px);
  border: 0;
  background: #fff;
  color: inherit;
}
#close { position: sticky; top: 0; z-index: 1; display: flex; width: 48px; margin: 0 12px 8px auto; padding: 0; border-radius: 50%; }
#photo { display: block; width: 100%; max-width: 640px; margin: 0 auto; }
#edit { display: grid; gap: 10px; max-width: 640px; margin: 0 auto; padding: 24px 16px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .error + .row { margin-top: 8px; }
#toggle-used { flex: 1; }
