:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f5f7fb;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 24px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary > div,
.search,
.food-card,
.empty {
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.summary > div {
  padding: 18px;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: #6b7788;
  font-size: 13px;
}

.summary strong {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #256f65;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions a,
.actions button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: #172033;
  color: #ffffff;
  font: inherit;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.actions a:last-child,
.actions button {
  background: #256f65;
}

.actions form {
  margin: 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.login-panel h1 {
  margin-bottom: 20px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.login-form button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: #256f65;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.form-footnote {
  margin: 16px 0 0;
  text-align: center;
}

.form-footnote a {
  color: #256f65;
  font-weight: 700;
  text-decoration: none;
}

.card-actions {
  margin-top: 16px;
}

.card-actions a,
.generate-panel button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: #256f65;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.search {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.search button,
.search a,
.pager a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: #172033;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.search a {
  background: #eef2f7;
  color: #172033;
}

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

.food-card {
  padding: 18px;
}

.card-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 14px;
}

.card-head span {
  color: #6b7788;
  font-size: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dt {
  margin-bottom: 4px;
  color: #256f65;
  font-size: 13px;
  font-weight: 700;
}

dd {
  margin: 0;
  color: #4b596b;
  line-height: 1.7;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0;
}

.pager span {
  color: #9aa5b5;
}

.empty {
  padding: 30px;
  color: #536173;
  text-align: center;
}

.notice {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px 16px;
  font-weight: 700;
}

.notice.error {
  border: 1px solid #efb8b8;
  background: #fff0f0;
  color: #9f1d1d;
}

.notice.success {
  border: 1px solid #a9d9c7;
  background: #eefaf5;
  color: #17624f;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.detail-card {
  min-height: 100%;
}

.generate-panel {
  position: sticky;
  top: 20px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.generate-panel strong {
  display: block;
  margin-bottom: 10px;
  font-size: 20px;
}

.generate-panel code {
  display: block;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  color: #536173;
  font-size: 13px;
}

.generate-panel p {
  margin: 0 0 16px;
  color: #536173;
  line-height: 1.6;
}

.prompt-preview {
  display: block;
  width: 100%;
  min-height: 220px;
  margin: 0 0 16px;
  resize: vertical;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
  color: #172033;
  font: 13px/1.6 Consolas, "Segoe UI", Arial, sans-serif;
  white-space: pre-wrap;
}

.image-action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.upload-image-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.upload-image-form label {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  font-weight: 700;
  cursor: pointer;
}

.upload-image-form input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-image-form span {
  overflow: hidden;
  padding: 0 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-image-meta {
  grid-column: 1 / -1;
  margin: 0;
  color: #536173;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.image-grid a {
  overflow: hidden;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.image-grid img {
  display: block;
  width: 100%;
  height: auto;
}

.splitter-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.splitter-panel {
  position: sticky;
  top: 20px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.file-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 16px;
  border-radius: 6px;
  background: #256f65;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.control-field {
  display: block;
  margin-bottom: 16px;
}

.control-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 16px;
  border: 0;
  padding: 0;
}

.segmented-control legend {
  grid-column: 1 / -1;
  margin-bottom: 6px;
  color: #6b7788;
  font-size: 13px;
}

.segmented-control label {
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cbd4e3;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  font-weight: 700;
  cursor: pointer;
}

.segmented-control input:checked + span {
  border-color: #256f65;
  background: #eaf6f2;
  color: #17624f;
}

.splitter-meta {
  margin-bottom: 16px;
}

.splitter-meta strong {
  display: block;
  font-size: 18px;
}

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

.splitter-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: #172033;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.splitter-actions button:last-child {
  background: #256f65;
}

.splitter-workspace {
  min-width: 0;
}

.splitter-stage {
  position: relative;
  display: grid;
  min-height: 360px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.splitter-stage img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
}

.drop-hint {
  color: #6b7788;
  font-weight: 700;
}

.line-layer {
  position: absolute;
  pointer-events: none;
}

.split-line {
  position: absolute;
  border: 0;
  background: #f2b705;
  box-shadow: 0 0 0 2px rgba(23, 32, 51, 0.35);
  pointer-events: auto;
  cursor: grab;
}

.split-line:active {
  cursor: grabbing;
}

.split-line.is-horizontal {
  left: 0;
  width: 100%;
  height: 4px;
  transform: translateY(-2px);
}

.split-line.is-vertical {
  top: 0;
  width: 4px;
  height: 100%;
  transform: translateX(-2px);
}

.slice-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.slice-card {
  overflow: hidden;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.06);
}

.slice-card img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f8fafc;
}

.slice-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  color: #536173;
  font-size: 13px;
}

.slice-card strong {
  color: #172033;
  font-size: 16px;
}

@media (max-width: 760px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .search {
    align-items: stretch;
    flex-direction: column;
  }

  .summary,
  .grid,
  .detail-layout,
  .image-grid,
  .splitter-layout,
  .slice-preview {
    grid-template-columns: 1fr;
  }

  .generate-panel,
  .splitter-panel {
    position: static;
  }
}
