:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --text: #25231f;
  --muted: #6d675e;
  --line: #ded8cc;
  --accent: #28645a;
  --accent-text: #ffffff;
  --danger: #9d2f2f;
  --shadow: 0 8px 24px rgba(37, 35, 31, 0.12);
  font-family:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

body.menu-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

main,
section,
article,
form,
label,
input,
textarea,
select,
button,
a,
p,
h1,
h2,
h3,
dd {
  min-width: 0;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  transform: translateY(-150%);
  background: var(--text);
  color: var(--surface);
  padding: 0.5rem 0.75rem;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  width: fit-content;
  text-decoration: none;
  font-weight: 700;
}

.header-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: right;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 11;
  background: rgba(37, 35, 31, 0.35);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 12;
  display: flex;
  width: min(19rem, 84vw);
  flex-direction: column;
  gap: 0.25rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar[hidden],
.sidebar-backdrop[hidden] {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.sidebar a,
.link-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0.8rem 0.7rem;
  text-align: left;
  text-decoration: none;
}

.sidebar a:hover,
.link-button:hover {
  background: var(--bg);
}

main {
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.85rem 0.85rem calc(2rem + env(safe-area-inset-bottom));
}

.page,
.stack {
  display: grid;
  gap: 1rem;
}

.page-header {
  display: grid;
  gap: 0.25rem;
}

.page-header.with-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.1rem;
}

.page-header p,
.hint,
.empty,
.meta {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  color: var(--text);
  padding: 0.65rem 0.7rem;
}

textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.button-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.primary-button,
.secondary-button,
.danger-button,
.small-button {
  display: inline-flex;
  width: 100%;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  text-decoration: none;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.secondary-button,
.small-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid var(--danger);
  background: var(--surface);
  color: var(--danger);
}

.action-list,
.item-list,
.picture-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.action-list a,
.item-card {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.85rem;
  text-decoration: none;
}

.item-card h2,
.item-card h3 {
  margin: 0;
  font-size: 1rem;
}

.item-card p {
  color: var(--muted);
}

.facts {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.facts div {
  display: grid;
  gap: 0.25rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.picture-list {
  grid-template-columns: 1fr;
}

.picture-card {
  display: grid;
  gap: 0.5rem;
}

.picture-card img,
.item-card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
}

.item-card img {
  aspect-ratio: 4 / 3;
}

.picture-controls {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr;
}

.picture-controls .secondary-button,
.picture-controls .danger-button {
  min-height: 2.25rem;
  padding: 0.4rem;
  font-size: 0.85rem;
}

.status {
  position: fixed;
  left: 0.85rem;
  right: 0.85rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 15;
  max-width: none;
  margin: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow);
}

.status:empty {
  display: none;
}

.status.error {
  background: var(--danger);
}

@media (min-width: 48rem) {
  main {
    padding-top: 2rem;
  }

  h1 {
    font-size: 2.1rem;
  }

  .panel,
  .action-list a,
  .item-card {
    padding: 1rem;
  }

  .button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .small-button {
    width: auto;
  }

  .facts div {
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 0.75rem;
  }

  .picture-list {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  }

  .picture-controls {
    grid-template-columns: repeat(3, 1fr);
  }

  .status {
    left: auto;
    right: 1rem;
    max-width: min(30rem, calc(100vw - 2rem));
  }
}
