:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --text: #2b2b2b;
  --muted: #6b6b6b;
  --accent: #2f855a;
  --border: #e4e1d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #f7f5ef 0%, #f2eee3 100%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: none;
  width: 100%;
  margin: 48px auto;
  padding: 0 24px;
}

.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
}

.subtitle-compact {
  margin: 0 0 14px;
}

.search-row {
  margin: 0 0 16px;
}

.search-row-compact {
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 86px;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn-secondary {
  background: #e9f2ec;
  color: var(--accent);
  border: 1px solid #cfe1d4;
}

.form-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.fab-add {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(47, 133, 90, 0.35);
  cursor: pointer;
  z-index: 30;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.dialog-backdrop.open {
  display: flex;
}

.dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  position: relative;
}

.dialog-fullscreen {
  width: calc(100vw - 28px);
  max-width: none;
  height: calc(100vh - 28px);
  max-height: none;
}

.dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

#addDishTitle {
  margin: 0 0 12px;
}

#dishDetailTitle {
  margin: 0 0 10px;
}

.form-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.category {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.category h2 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 1.2rem;
}

.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.category-head h2 {
  margin: 0;
}

.category-head-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.category-open {
  font-size: 0.85rem;
  padding: 8px 10px;
}

.category-rename {
  font-size: 0.85rem;
  padding: 8px 10px;
}

.category ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 12px;
  scrollbar-width: thin;
  padding-bottom: 4px;
}

.dish {
  background: #faf8f2;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex: 0 0 220px;
}

.dish:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dish img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #ece7da;
}

.dish-name {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(1px);
}

.status {
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
}

.detail-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 12px;
  background: #ece7da;
}

.detail-meta {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-value {
  margin: 4px 0 12px;
  white-space: pre-wrap;
}

.detail-actions {
  margin-top: 6px;
}

.category-list-fullscreen {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100% - 74px);
  align-items: stretch;
  scrollbar-width: thin;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.category-list-fullscreen .dish {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: center;
  min-height: 172px;
  border-radius: 10px;
  width: 100%;
}

.category-list-fullscreen .dish img {
  width: 100%;
  height: 172px;
  border-radius: 10px 0 0 10px;
}

.category-list-fullscreen .dish-name {
  position: static;
  background: transparent;
  color: var(--text);
  backdrop-filter: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 12px;
}

@media (min-width: 701px) {
  .category-list-fullscreen {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
  }

  .category-list-fullscreen .dish {
    margin: 0;
    grid-template-columns: 220px 1fr;
    min-height: 150px;
  }

  .category-list-fullscreen .dish img {
    height: 150px;
  }
}

@media (min-width: 1300px) {
  .category-list-fullscreen {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-list-fullscreen .dish {
    grid-template-columns: 200px 1fr;
    min-height: 138px;
  }

  .category-list-fullscreen .dish img {
    height: 138px;
  }
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 14px;
  }

  .dish {
    flex-basis: 190px;
  }

  .category-list-fullscreen .dish {
    grid-template-columns: 220px 1fr;
  }

  .category-list-fullscreen .dish img {
    height: 164px;
  }
}

/* ===== SCHEDULE SECTION ===== */

.schedule-section {
  margin-bottom: 20px;
}

.schedule-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.schedule-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent);
}

.schedule-nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.schedule-nav-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.schedule-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  padding-bottom: 4px;
}

.schedule-day {
  flex: 0 0 140px;
  background: #faf8f2;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  scroll-snap-align: start;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-day--today {
  border-color: var(--accent);
  background: #f0f9f4;
}

.schedule-day-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-day-weekday {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.schedule-day-date {
  font-size: 0.82rem;
  color: var(--muted);
}

.schedule-day-dishes {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.schedule-chip {
  display: flex;
  align-items: center;
  background: #e9f2ec;
  border: 1px solid #cfe1d4;
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}

.schedule-chip-name {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  text-align: left;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-chip-name:hover {
  background: #d5eadc;
}

.schedule-chip-remove {
  flex-shrink: 0;
  width: 22px;
  height: 100%;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-left: 1px solid #cfe1d4;
  border-radius: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.schedule-chip-remove:hover {
  background: #fde8e8;
  color: #c0392b;
}

.schedule-add-btn {
  padding: 4px 6px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.schedule-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0f9f4;
}

@media (min-width: 700px) {
  .schedule-strip {
    overflow-x: visible;
  }

  .schedule-day {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* ===== ASSIGN SCHEDULE DIALOG ===== */

.assign-dish-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assign-dish-btn {
  width: 100%;
  background: #faf8f2;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assign-dish-btn:hover {
  background: #f0f9f4;
  border-color: var(--accent);
}

.assign-dish-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.assign-dish-category {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ===== QUICK SCHEDULE DIALOG ===== */

.schedule-dish-label {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.schedule-date-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  font: inherit;
  background: #fff;
}

/* ===== DISH DETAIL SCHEDULE SECTION ===== */

.dish-schedule-section {
  margin: 14px 0 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.dish-schedule-list {
  list-style: none;
  margin: 6px 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dish-schedule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
  padding: 6px 10px;
  background: #faf8f2;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.schedule-remove-btn {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 4px 8px;
}

.schedule-dish-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

.schedule-dish-add .schedule-date-input {
  flex: 1;
}

.schedule-loading {
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ===== DISH CARD SCHEDULE BUTTON ===== */

.dish-schedule-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.88);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.dish-schedule-btn:hover {
  background: #fff;
  border-color: var(--accent);
}

/* ===== SHOPPING LIST ===== */

.shopping-section {
  margin-bottom: 20px;
}

.shopping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.shopping-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent);
}

.shopping-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

.shopping-toggle-row input {
  width: 16px;
  height: 16px;
}

.shopping-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.shopping-items {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #faf8f2;
  cursor: grab;
}

.shopping-item:active {
  cursor: grabbing;
}

.shopping-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
}

.shopping-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shopping-item-drag-hint {
  font-size: 0.76rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
}

.shopping-item-main input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.shopping-item-name {
  line-height: 1.2;
}

.shopping-item-dishes {
  margin: 6px 0 0 28px;
  color: var(--muted);
  font-size: 0.83rem;
}

.shopping-item--checked .shopping-item-name,
.shopping-item--checked .shopping-item-dishes {
  text-decoration: line-through;
  color: #8a8a8a;
}

.shopping-item--dragging {
  opacity: 0.45;
}

.shopping-item--drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

@media (max-width: 820px) {
  .shopping-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 580px) {
  .shopping-controls {
    grid-template-columns: 1fr;
  }

  .shopping-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
