:root {
  color-scheme: light dark;
  --bg: #f7f4ee;
  --bg-top: rgb(247 244 238 / 0.96);
  --bg-bottom: rgb(237 241 232 / 0.94);
  --text: #1f2523;
  --muted: #69716d;
  --surface: #fffefa;
  --line: #d9d2c7;
  --red: #d74f45;
  --red-dark: #8f2c25;
  --green: #3f9b68;
  --green-dark: #1f6640;
  --button: #26312d;
  --button-text: #ffffff;
  --secondary-button: #e7e0d5;
  --empty-bg: rgb(255 254 250 / 0.62);
  --pattern-image: url("./icons/pantry-pattern.svg");
  --pattern-size: auto;
  --pattern-mask-image: none;
  --pattern-mask-size: auto;
  --pattern-mask-position: 0 0;
  --pattern-rgb: 31 37 35;
  --pattern-alpha: 0.42;
  --pattern-blend-mode: multiply;
  --shadow: 0 10px 24px rgb(31 37 35 / 0.1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --text: #f3f1ea;
  --muted: #b5bbb5;
  --surface: #202722;
  --line: #4a514b;
  --button: #eef2ea;
  --button-text: #151a17;
  --secondary-button: #333b35;
  --empty-bg: rgb(32 39 34 / 0.7);
  --pattern-rgb: 255 255 255;
  --pattern-alpha: 0.46;
  --pattern-blend-mode: screen;
  --shadow: 0 12px 28px rgb(0 0 0 / 0.28);
}

html[data-pattern-color="red"] {
  --pattern-rgb: 178 45 74;
  --pattern-alpha: 0.58;
}

html[data-pattern-color="blue"] {
  --pattern-rgb: 45 99 142;
  --pattern-alpha: 0.54;
}

html[data-pattern-color="green"] {
  --pattern-rgb: 43 122 78;
  --pattern-alpha: 0.54;
}

html[data-pattern-color="gold"] {
  --pattern-rgb: 154 113 31;
  --pattern-alpha: 0.54;
}

html[data-theme="dark"][data-pattern-color="red"] {
  --pattern-rgb: 255 132 154;
  --pattern-alpha: 0.62;
}

html[data-theme="dark"][data-pattern-color="blue"] {
  --pattern-rgb: 122 194 230;
  --pattern-alpha: 0.58;
}

html[data-theme="dark"][data-pattern-color="green"] {
  --pattern-rgb: 117 214 158;
  --pattern-alpha: 0.58;
}

html[data-theme="dark"][data-pattern-color="gold"] {
  --pattern-rgb: 241 196 92;
  --pattern-alpha: 0.58;
}

html[data-accent="sage"] {
  --bg: #f7f4ee;
  --bg-top: rgb(247 244 238 / 0.96);
  --bg-bottom: rgb(237 241 232 / 0.94);
}

html[data-accent="rose"] {
  --bg: #f4dbe3;
  --bg-top: rgb(249 226 234 / 0.97);
  --bg-bottom: rgb(235 198 211 / 0.95);
}

html[data-accent="sky"] {
  --bg: #dceff3;
  --bg-top: rgb(226 246 249 / 0.97);
  --bg-bottom: rgb(196 226 233 / 0.95);
}

html[data-accent="plum"] {
  --bg: #eadff0;
  --bg-top: rgb(242 228 248 / 0.97);
  --bg-bottom: rgb(218 197 229 / 0.95);
}

html[data-accent="graphite"] {
  --bg: #e4e7e3;
  --bg-top: rgb(238 241 237 / 0.97);
  --bg-bottom: rgb(207 214 207 / 0.95);
}

html[data-theme="dark"][data-accent="sage"] {
  --bg: #101612;
  --bg-top: rgb(16 22 18 / 0.98);
  --bg-bottom: rgb(27 40 32 / 0.96);
}

html[data-theme="dark"][data-accent="rose"] {
  --bg: #211419;
  --bg-top: rgb(33 20 25 / 0.98);
  --bg-bottom: rgb(54 30 41 / 0.96);
}

html[data-theme="dark"][data-accent="sky"] {
  --bg: #0f171d;
  --bg-top: rgb(15 23 29 / 0.98);
  --bg-bottom: rgb(23 42 53 / 0.96);
}

html[data-theme="dark"][data-accent="plum"] {
  --bg: #1a1420;
  --bg-top: rgb(26 20 32 / 0.98);
  --bg-bottom: rgb(41 31 53 / 0.96);
}

html[data-theme="dark"][data-accent="graphite"] {
  --bg: #121314;
  --bg-top: rgb(18 19 20 / 0.98);
  --bg-bottom: rgb(33 36 38 / 0.96);
}

html[data-pattern="none"] {
  --pattern-image: none;
  --pattern-size: auto;
  --pattern-mask-image: none;
  --pattern-mask-size: auto;
  --pattern-mask-position: 0 0;
  --pattern-alpha: 0;
}

html[data-pattern="none"][data-pattern-color] {
  --pattern-alpha: 0;
}

html[data-theme="dark"][data-pattern="none"][data-pattern-color] {
  --pattern-alpha: 0;
}

html[data-pattern="pantry"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='74' height='54' viewBox='0 0 74 54'%3E%3Cg fill='none' stroke='%231f2523' stroke-opacity='0.28' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 39h50'/%3E%3Cpath d='M20 38V24c0-4 3-6 6-6s6 2 6 6v14'/%3E%3Cpath d='M42 38V20h12v18'/%3E%3Cpath d='M43 25h10'/%3E%3Cpath d='M23 18h6'/%3E%3C/g%3E%3C/svg%3E");
  --pattern-size: 74px 54px;
  --pattern-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='74' height='54' viewBox='0 0 74 54'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 39h50'/%3E%3Cpath d='M20 38V24c0-4 3-6 6-6s6 2 6 6v14'/%3E%3Cpath d='M42 38V20h12v18'/%3E%3Cpath d='M43 25h10'/%3E%3Cpath d='M23 18h6'/%3E%3C/g%3E%3C/svg%3E");
  --pattern-mask-size: 74px 54px;
  --pattern-mask-position: 0 0;
}

html[data-pattern="dots"] {
  --pattern-image: radial-gradient(circle, rgb(var(--pattern-rgb) / var(--pattern-alpha)) 3px, transparent 3.4px);
  --pattern-size: 34px 34px;
  --pattern-mask-image: radial-gradient(circle, #000 3px, transparent 3.4px);
  --pattern-mask-size: 34px 34px;
  --pattern-mask-position: 0 0;
}

html[data-pattern="grid"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath d='M28 8 48 28 28 48 8 28Z' fill='none' stroke='%231f2523' stroke-opacity='0.28' stroke-width='1.6'/%3E%3C/svg%3E");
  --pattern-size: 56px 56px;
  --pattern-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath d='M28 8 48 28 28 48 8 28Z' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E");
  --pattern-mask-size: 56px 56px;
  --pattern-mask-position: 0 0;
}

html[data-pattern="kitchen"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='82' height='64' viewBox='0 0 82 64'%3E%3Cg fill='none' stroke='%231f2523' stroke-opacity='0.3' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 18c0 4-2 7-5 7s-5-3-5-7 2-7 5-7 5 3 5 7Z'/%3E%3Cpath d='M12 25v18'/%3E%3Cpath d='M32 13v30'/%3E%3Cpath d='M27 13v10'/%3E%3Cpath d='M32 13v10'/%3E%3Cpath d='M37 13v10'/%3E%3Cpath d='M53 35h18'/%3E%3Cpath d='M57 29h10a4 4 0 0 1 4 4v2H53v-2a4 4 0 0 1 4-4Z'/%3E%3Cpath d='M58 29v-4h8v4'/%3E%3C/g%3E%3C/svg%3E");
  --pattern-size: 82px 64px;
  --pattern-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='82' height='64' viewBox='0 0 82 64'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 18c0 4-2 7-5 7s-5-3-5-7 2-7 5-7 5 3 5 7Z'/%3E%3Cpath d='M12 25v18'/%3E%3Cpath d='M32 13v30'/%3E%3Cpath d='M27 13v10'/%3E%3Cpath d='M32 13v10'/%3E%3Cpath d='M37 13v10'/%3E%3Cpath d='M53 35h18'/%3E%3Cpath d='M57 29h10a4 4 0 0 1 4 4v2H53v-2a4 4 0 0 1 4-4Z'/%3E%3Cpath d='M58 29v-4h8v4'/%3E%3C/g%3E%3C/svg%3E");
  --pattern-mask-size: 82px 64px;
  --pattern-mask-position: 0 0;
}

html[data-theme="dark"][data-pattern="pantry"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='74' height='54' viewBox='0 0 74 54'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.32' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 39h50'/%3E%3Cpath d='M20 38V24c0-4 3-6 6-6s6 2 6 6v14'/%3E%3Cpath d='M42 38V20h12v18'/%3E%3Cpath d='M43 25h10'/%3E%3Cpath d='M23 18h6'/%3E%3C/g%3E%3C/svg%3E");
}

html[data-theme="dark"][data-pattern="grid"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath d='M28 8 48 28 28 48 8 28Z' fill='none' stroke='%23ffffff' stroke-opacity='0.34' stroke-width='1.6'/%3E%3C/svg%3E");
}

html[data-pattern="hearts"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%231f2523' fill-opacity='0.22'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
  --pattern-size: 42px 42px;
  --pattern-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%23000'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
  --pattern-mask-size: 42px 42px;
  --pattern-mask-position: 0 0;
}

html[data-theme="dark"][data-pattern="hearts"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%23ffffff' fill-opacity='0.22'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-pattern="hearts"][data-pattern-color="red"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%23b22d4a' fill-opacity='0.42'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-pattern="hearts"][data-pattern-color="blue"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%232d638e' fill-opacity='0.4'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-pattern="hearts"][data-pattern-color="green"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%232b7a4e' fill-opacity='0.4'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-pattern="hearts"][data-pattern-color="gold"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%239a711f' fill-opacity='0.4'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-theme="dark"][data-pattern="hearts"][data-pattern-color="red"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%23ff849a' fill-opacity='0.48'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-theme="dark"][data-pattern="hearts"][data-pattern-color="blue"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%237ac2e6' fill-opacity='0.46'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-theme="dark"][data-pattern="hearts"][data-pattern-color="green"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%2375d69e' fill-opacity='0.46'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

html[data-theme="dark"][data-pattern="hearts"][data-pattern-color="gold"] {
  --pattern-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Ctext x='21' y='27' text-anchor='middle' font-size='17' fill='%23f1c45c' fill-opacity='0.46'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

input,
select,
textarea {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

button,
input,
select,
label,
h1,
h2,
p,
.item-name {
  max-width: 100%;
}

button,
input,
select,
label,
h1,
h2,
p {
  overflow-wrap: anywhere;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 760px);
  height: 100svh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  overflow: hidden;
}

.app-shell::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background: rgb(var(--pattern-rgb) / var(--pattern-alpha));
  mix-blend-mode: var(--pattern-blend-mode);
  -webkit-mask-image: var(--pattern-mask-image);
  mask-image: var(--pattern-mask-image);
  -webkit-mask-size: var(--pattern-mask-size);
  mask-size: var(--pattern-mask-size);
  -webkit-mask-position: var(--pattern-mask-position);
  mask-position: var(--pattern-mask-position);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
}

.app-shell > * {
  position: relative;
  z-index: 1;
}

.topbar {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.cloud-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.cloud-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cloud-sync-mini {
  min-width: 34px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

.cloud-button.is-idle {
  background: var(--surface);
  border-color: var(--line);
}

.cloud-button.is-ok {
  color: #ffffff;
  background: #1f8a42;
  border-color: #176832;
}

.cloud-button.is-error {
  color: #ffffff;
  background: #be2f2f;
  border-color: #8f2323;
}

.topbar-list-switcher {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.list-selector-button {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 6px;
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.list-selector-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.7rem, 2.18rem, 2.18rem);
  font-weight: 900;
  line-height: 1;
}

.list-selector-caret {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
}

.list-selector-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  min-width: min(300px, 86vw);
  max-height: min(54vh, 420px);
  overflow-y: auto;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.list-selector-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--button);
  background: transparent;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.list-selector-item.is-active {
  color: var(--button-text);
  background: var(--button);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 2.45rem, 2.45rem);
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 1.2rem;
}

.clear-button,
.icon-button,
.input-row button {
  border: 0;
  border-radius: 8px;
  color: var(--button-text);
  background: var(--button);
  cursor: pointer;
  touch-action: manipulation;
}

.clear-button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: normal;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.secondary-button {
  color: var(--text);
  background: var(--secondary-button);
}

.clear-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.add-form {
  margin-bottom: 12px;
}

.add-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
}

.input-row input {
  min-width: 0;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  text-overflow: ellipsis;
}

.input-row input:focus {
  border-color: var(--button);
  box-shadow: 0 0 0 3px rgb(38 49 45 / 0.16);
}

.input-row button {
  min-width: 48px;
  min-height: 48px;
  font-size: 1.45rem;
  font-weight: 800;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.list-section {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.grid-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px 18px 2px;
  scrollbar-gutter: stable;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 3), minmax(0, 1fr));
  gap: 14px;
}

.recent-section {
  position: relative;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}

.recent-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}

.recent-section summary::-webkit-details-marker {
  display: none;
}

.recent-section summary::before {
  width: 1.2em;
  flex: 0 0 auto;
  content: "▶";
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.recent-section[open] summary::before {
  content: "▼";
}

.recent-section summary span:last-child {
  margin-left: auto;
  margin-right: 52px;
  color: var(--muted);
  font-size: 0.9rem;
}

.list-menu-button {
  position: absolute;
  top: 11px;
  right: 0;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: var(--button);
  background: rgb(255 255 255 / 0.5);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 2px var(--line);
  cursor: pointer;
  touch-action: manipulation;
}

.list-menu-button:focus-visible,
.list-menu button:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

.list-menu {
  position: absolute;
  z-index: 5;
  top: 58px;
  right: 0;
  min-width: 150px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.list-menu button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--button);
  background: transparent;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.list-menu button:disabled {
  color: var(--muted);
  cursor: default;
}

.list-menu button:not(:disabled):hover {
  background: rgb(255 255 255 / 0.58);
}

.recent-grid {
  padding-bottom: 8px;
}

.category-section {
  margin-top: 14px;
}

.bottom-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 6px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgb(0 0 0 / 0.08);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-version {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
  opacity: 0.72;
}

.bottom-tabbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 14px rgb(0 0 0 / 0.08);
}

.tab-button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  background: color-mix(in srgb, var(--secondary-button) 72%, transparent);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
}

.tab-icon {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1;
}

.tab-label {
  display: block;
  max-width: 100%;
  white-space: normal;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
  min-height: calc(1.05em * 2);
}

.tab-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.tab-button:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

.tab-button:not(:disabled):active {
  background: color-mix(in srgb, var(--button) 26%, var(--surface));
}

.item-card {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 8px;
  padding: 0 8px;
  color: #fff;
  background: var(--red);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.item-card.is-bought {
  background: var(--green);
}

.item-card.is-recent {
  background: var(--green);
}

.item-card.is-template {
  background: var(--green);
}

.item-card:focus-visible {
  outline: 3px solid var(--button);
  outline-offset: 3px;
}

.item-letter {
  display: grid;
  flex: 0 0 auto;
  position: absolute;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  place-items: center;
  width: calc(100% - 16px);
  aspect-ratio: 4 / 3;
  border: 2px solid rgb(255 255 255 / 0.74);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.18);
  font-size: var(--item-letter-size, 3.6rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  overflow: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.item-letter.has-photo {
  border-color: rgb(255 255 255 / 0.9);
  background: rgb(255 255 255 / 0.24);
}

.item-letter.has-icon {
  border-color: rgb(255 255 255 / 0.88);
  background: rgb(255 255 255 / 0.26);
}

.item-letter img,
.dialog-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.item-symbol {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
}

.dialog-symbol {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
}

.item-name {
  position: absolute;
  right: 8px;
  bottom: var(--item-name-bottom, 5px);
  left: 8px;
  top: var(--item-name-top, 79%);
  width: auto;
  display: -webkit-box;
  margin-top: 0;
  padding-top: 2px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-align: center;
  font-size: var(--item-name-size, 0.88rem);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.empty-state {
  margin: 26px 0 0;
  padding: 22px 16px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--empty-bg);
  text-align: center;
  font-weight: 700;
}

.item-dialog {
  width: min(calc(100% - 28px), 420px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: transparent;
}

.item-dialog::backdrop {
  background: rgb(31 37 35 / 0.54);
}

.item-dialog-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgb(31 37 35 / 0.24);
}

.dialog-preview {
  display: grid;
  justify-items: start;
}

.dialog-media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, 34%);
  gap: 10px;
  align-items: start;
}

.dialog-photo-preview,
.camera-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgb(215 79 69 / 0.11);
  overflow: hidden;
}

.dialog-photo-preview {
  display: grid;
  place-items: center;
  color: var(--red-dark);
  font-size: 4.2rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.camera-preview {
  object-fit: cover;
  background: #1f2523;
}

.dialog-photo-actions {
  display: grid;
  gap: 8px;
}

.dialog-photo-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--button-text);
  background: var(--button);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.dialog-photo-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.dialog-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.dialog-field input,
.dialog-field select {
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.dialog-field input:focus,
.dialog-field select:focus {
  border-color: var(--button);
  box-shadow: 0 0 0 3px rgb(38 49 45 / 0.16);
}

.grid-columns-chooser {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.grid-choice {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 112px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px 6px 6px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.grid-choice.is-active {
  border-color: var(--button);
  box-shadow: 0 0 0 2px rgb(38 49 45 / 0.18) inset;
}

.grid-choice-preview {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  align-content: start;
  gap: 3px;
  width: 100%;
  max-width: 48px;
  aspect-ratio: 9 / 14;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px 3px 4px;
  background: linear-gradient(180deg, #f7f9f8 0%, #eff3f1 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.7);
  position: relative;
}

.grid-choice-preview::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 16px;
  height: 2px;
  border-radius: 99px;
  background: rgb(35 45 41 / 0.22);
  transform: translateX(-50%);
}

.grid-choice-preview span {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: var(--red);
}

.grid-choice-label {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.setting-chooser {
  display: grid;
  gap: 8px;
}

.setting-chooser-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.setting-chooser-colors {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.setting-chooser-patterns {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.setting-choice {
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.setting-choice.is-active {
  border-color: var(--button);
  box-shadow: 0 0 0 2px rgb(38 49 45 / 0.18) inset;
}

.setting-choice:disabled {
  opacity: 0.36;
  cursor: default;
}

.setting-choice-color {
  min-height: 36px;
  padding: 0;
}

.setting-choice-color[data-swatch="sage"] { background: #e7f1e7; }
.setting-choice-color[data-swatch="rose"] { background: #f4dbe3; }
.setting-choice-color[data-swatch="sky"] { background: #dceff3; }
.setting-choice-color[data-swatch="plum"] { background: #eadff0; }
.setting-choice-color[data-swatch="graphite"] { background: #d2d8d2; }
.setting-choice-color[data-swatch="auto"] { background: linear-gradient(135deg, #ecebe8 0%, #363c38 100%); }
.setting-choice-color[data-swatch="red"] { background: #b22d4a; }
.setting-choice-color[data-swatch="blue"] { background: #2d638e; }
.setting-choice-color[data-swatch="green"] { background: #2b7a4e; }
.setting-choice-color[data-swatch="gold"] { background: #9a711f; }

html[data-theme="dark"] .setting-choice-color[data-swatch="sage"] { background: linear-gradient(135deg, #101612 0%, #2b4034 100%); }
html[data-theme="dark"] .setting-choice-color[data-swatch="rose"] { background: linear-gradient(135deg, #211419 0%, #563043 100%); }
html[data-theme="dark"] .setting-choice-color[data-swatch="sky"] { background: linear-gradient(135deg, #0f171d 0%, #274859 100%); }
html[data-theme="dark"] .setting-choice-color[data-swatch="plum"] { background: linear-gradient(135deg, #1a1420 0%, #45345a 100%); }
html[data-theme="dark"] .setting-choice-color[data-swatch="graphite"] { background: linear-gradient(135deg, #121314 0%, #3a3f43 100%); }

.setting-choice-pattern {
  min-height: 40px;
  padding: 0;
}

.pattern-glyph {
  display: block;
  font-size: 1.12rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.setting-chooser.is-disabled {
  opacity: 0.55;
}

.dialog-actions,
.dialog-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-maintenance {
  display: flex;
}

.dialog-actions button,
.dialog-footer button,
.settings-list-tools button,
.settings-maintenance button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--button-text);
  background: var(--button);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.dialog-actions button {
  flex: 1 1 120px;
}

.settings-list-tools button {
  flex: 1 1 130px;
}

.settings-maintenance button {
  flex: 1 1 auto;
}

.dialog-footer {
  justify-content: flex-end;
}

.dialog-footer-top {
  margin-top: -4px;
  margin-bottom: -2px;
}

.item-dialog .dialog-footer {
  justify-content: stretch;
}

.item-dialog .dialog-footer button {
  flex: 1 1 0;
  min-width: 0;
}

.item-dialog .dialog-footer .secondary-button {
  color: #ffffff;
  background: var(--red-dark);
}

.item-dialog .dialog-footer button[type="submit"] {
  color: #ffffff;
  background: var(--green-dark);
}

.dialog-footer .secondary-button,
.settings-list-tools .secondary-button,
.settings-maintenance .secondary-button {
  color: var(--text);
  background: var(--secondary-button);
}

.settings-maintenance .secondary-button.is-update-available {
  background: linear-gradient(160deg, #b22d4a 0%, #8f2c25 100%);
  color: #fff7f8;
  border: 1px solid color-mix(in srgb, #8f2c25 70%, var(--line) 30%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12), 0 10px 18px rgb(143 44 37 / 0.24);
}

.dialog-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.dialog-actions .danger-button {
  color: #ffffff;
  background: var(--red-dark);
}

.settings-list-tools .danger-button {
  color: #ffffff;
  background: var(--red-dark);
}

.settings-list-tools button:disabled {
  opacity: 0.45;
  cursor: default;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.cloud-family-section {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 2px solid var(--line);
}

.cloud-server-section {
  display: grid;
  gap: 10px;
}

.cloud-server-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.cloud-family-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.cloud-debug {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.icon-picker {
  display: grid;
  gap: 10px;
}

.icon-editor-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.icon-editor-actions button {
  min-height: 38px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.icon-picker h3,
.photo-picker h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.icon-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 2px;
}

.icon-choice {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 90px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.icon-choice.is-active {
  border-color: var(--button);
  box-shadow: 0 0 0 2px rgb(38 49 45 / 0.18) inset;
}

.icon-choice-image {
  width: 40px;
  height: 40px;
  object-fit: contain !important;
  transform: scale(1.65);
  transform-origin: center;
}

.icon-choice-label {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-picker {
  display: grid;
  gap: 10px;
}

.photo-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 2px;
}

.photo-choice {
  display: grid;
  place-items: center;
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: var(--surface);
  cursor: pointer;
}

.photo-choice img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
}

.photo-choice.is-active {
  border-color: var(--button);
  box-shadow: 0 0 0 2px rgb(38 49 45 / 0.18) inset;
}

.photo-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.icon-editor-preview-wrap {
  display: grid;
}

.icon-editor-canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgb(31 37 35 / 0.08) 1px, transparent 1px),
    linear-gradient(rgb(31 37 35 / 0.08) 1px, transparent 1px),
    #f9fbf9;
  background-size: 24px 24px;
  cursor: crosshair;
  touch-action: none;
}

.icon-editor-section {
  display: grid;
  gap: 6px;
}

.icon-editor-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.icon-editor-chooser {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.icon-editor-text-controls {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  align-items: end;
}

.icon-editor-text-controls .dialog-field {
  margin: 0;
}

.icon-editor-text-controls input,
.icon-editor-text-controls select {
  width: 100%;
}

.icon-editor-colors {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}

.icon-editor-choice {
  min-height: 30px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.icon-editor-shape-choice {
  min-height: 28px;
  border-radius: 6px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.icon-editor-choice.is-active {
  border-color: var(--button);
  box-shadow: 0 0 0 2px rgb(38 49 45 / 0.18) inset;
}

.icon-editor-color-choice {
  min-height: 0;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 5px;
  padding: 0;
  background: var(--editor-color);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .app-shell {
    width: 100%;
    height: 100svh;
    height: 100dvh;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .topbar {
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
  }

  .eyebrow {
    display: none;
  }

  .list-selector-title {
    font-size: 1.42rem;
    line-height: 0.96;
  }

  .list-selector-menu {
    min-width: min(260px, 90vw);
  }

  .add-form {
    margin-bottom: 6px;
  }

  .add-form label {
    margin-bottom: 4px;
    font-size: 0.78rem;
  }

  .input-row {
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .input-row input,
  .input-row button {
    min-height: 44px;
  }

  .input-row button {
    min-width: 44px;
  }

  .dialog-media-row {
    grid-template-columns: minmax(0, 1fr) minmax(112px, 36%);
    gap: 8px;
  }

  .dialog-photo-preview,
  .camera-preview {
    width: 100%;
  }

  .dialog-photo-actions button {
    min-height: 36px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .bottom-actions {
    gap: 6px;
    padding-top: 6px;
  }

  .bottom-tabbar {
    gap: 6px;
    padding: 4px;
  }

  .tab-button {
    min-height: 44px;
    padding: 0 6px;
    font-size: 0.74rem;
  }

  .tab-icon {
    font-size: 1rem;
  }

  .tab-label {
    font-size: 0.62rem;
    line-height: 1.05;
  }

  .setting-chooser {
    gap: 6px;
  }

  .setting-choice {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.74rem;
  }

  .setting-choice-color,
  .setting-choice-pattern {
    min-height: 34px;
  }

  .pattern-glyph {
    font-size: 1rem;
  }

  .grid-columns-chooser {
    gap: 6px;
  }

  .grid-choice {
    min-height: 102px;
    padding: 6px 4px 5px;
  }

  .grid-choice-preview {
    max-width: 44px;
    padding: 7px 2px 4px;
  }

  .grid-choice-label {
    font-size: 0.68rem;
  }

  .section-heading {
    margin-bottom: 10px;
  }

  .item-grid {
    gap: 10px;
  }

  .icon-choices {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    max-height: 190px;
  }

  .icon-editor-actions {
    grid-template-columns: 1fr;
  }

  .icon-editor-chooser {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .icon-editor-colors {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .icon-editor-text-controls {
    grid-template-columns: 1fr;
  }

  .icon-choice {
    min-height: 98px;
    padding: 8px;
  }

  .icon-choice-image {
    width: 44px;
    height: 44px;
    transform: scale(1.75);
  }

  .icon-choice-label {
    font-size: 0.78rem;
  }

  .photo-choices {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-height: 190px;
  }

  .photo-choice {
    min-height: 74px;
  }
}
