:root {
  --bg: #e7e7e7;
  --paper: #fbfbf8;
  --ink: #101010;
  --muted: #7d7d74;
  --line: #d9d8cf;
  --blue: #1592e6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.phone {
  width: min(430px, calc(100vw - 16px));
  max-width: 100%;
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  border-radius: 36px;
  background: var(--paper);
  padding: 18px 12px 120px;
  position: relative;
  overflow-x: hidden;
}

.hero-card,
.category-rail,
.recipe-card,
.panel,
.dialog-card {
  background: rgba(255, 255, 255, 0.62);
  border: 1.5px solid var(--line);
  backdrop-filter: blur(12px);
}

.hero-card {
  border-radius: 28px;
  padding: 20px 22px;
}

.hero-card p,
.section-heading p,
.panel p {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.hero-card h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  font-weight: 900;
}

.layout {
  display: flex;
  gap: 14px;
  margin-top: 18px;
  max-width: 100%;
  min-width: 0;
}

.category-rail {
  width: 86px;
  flex: 0 0 86px;
  border-radius: 28px;
  padding: 14px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.category-item {
  width: 70px;
  min-height: 92px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0;
  font-weight: 800;
}

.category-item.active {
  color: var(--ink);
}

.category-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: white;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
}

.category-item.active .category-icon {
  border: 3px solid var(--blue);
}

.category-name {
  text-align: center;
  line-height: 1.15;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

#screen,
.panel,
.import-panel,
.import-preview,
.import-dish-card,
.import-info-card,
.sub-panel {
  max-width: 100%;
  min-width: 0;
}

.section-heading {
  min-height: 78px;
  position: relative;
  padding-right: 156px;
}

.section-heading h2,
.panel h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  font-weight: 900;
}

.heading-actions {
  position: absolute;
  right: 0;
  top: 8px;
  display: flex;
  gap: 7px;
}

.list-tools {
  margin: 12px 0 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-version {
  margin: -4px 0 12px;
  color: #99978f;
  font-size: 11px;
  text-align: right;
}

.list-tools label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.list-tools select {
  min-height: 36px;
  max-width: 154px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 900;
}

.pill,
.recipe-actions button,
.panel-nav button,
.dialog-actions button,
.shopping-float button {
  min-height: 38px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 13px;
  font-weight: 900;
}

.dark,
.heading-actions .pill:first-child,
.recipe-actions button.active,
.shopping-float button {
  background: var(--ink);
  color: white;
}

.recipe-list {
  display: grid;
  gap: 16px;
}

.recipe-card {
  border-radius: 24px;
  padding: 14px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  touch-action: pan-y;
}

.recipe-card.pressing {
  box-shadow: inset 0 0 0 2px rgba(180, 35, 24, 0.18);
}

.recipe-card.swipe-delete-hint {
  transform: translateX(-18px);
  box-shadow: 12px 0 0 #b42318;
}

.recipe-card img {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border-radius: 18px;
  border: 1.5px solid var(--line);
}

.recipe-card h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.recipe-card p {
  margin: 6px 0;
  color: var(--muted);
  font-weight: 700;
}

.recipe-card span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.recipe-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.recipe-actions button {
  padding: 0 8px;
}

.recipe-actions .heart-button {
  font-size: 20px;
  line-height: 1;
}

.empty,
.form-message {
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  padding: 13px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  border: 1.5px solid var(--line);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
  text-align: center;
  font-weight: 900;
  line-height: 1.35;
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-toast.warning {
  background: #fff;
  color: var(--ink);
}

.panel {
  border-radius: 28px;
  padding: 18px;
  overflow: hidden;
}

.panel-nav {
  margin-bottom: 16px;
}

.panel label {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 800;
}

.panel input,
.panel select,
.panel textarea,
.dialog-card input {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

.panel textarea {
  min-height: 78px;
  resize: vertical;
}

.link-import-box {
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
  padding: 14px;
  margin-top: 16px;
}

.link-import-box label {
  margin-top: 0;
}

.cover-tools,
.detail-actions,
.shopping-actions,
.import-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.cover-tools button,
.upload-button,
.detail-actions button,
.shopping-actions button,
.import-actions button {
  min-height: 42px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.import-actions .submit {
  margin-top: 0;
}

.import-actions button:disabled {
  opacity: 0.52;
}

.cover-tools input[type="file"],
.screenshot-button input[type="file"] {
  display: none;
}

.screenshot-button {
  min-height: 44px;
  margin-top: 12px;
  border-radius: 999px;
  border: 1.5px dashed var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 900;
  text-align: center;
}

.cover-preview,
.detail-cover {
  width: 100%;
  border-radius: 24px;
  border: 1.5px solid var(--line);
  object-fit: cover;
  background: white;
}

.cover-preview {
  height: 180px;
  margin-top: 14px;
}

.detail-cover {
  height: 220px;
  margin-top: 16px;
}

.detail-note,
.sub-panel {
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
  margin-top: 16px;
}

.detail-note span {
  line-height: 1.45;
}

.detail-actions button.active {
  background: var(--ink);
  color: white;
}

.sub-panel h3 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 900;
}

.import-preview {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.import-dish-card,
.import-info-card {
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
  padding: 14px;
  overflow: hidden;
}

.import-dish-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.import-dish-card > div {
  min-width: 0;
}

.import-dish-card img {
  width: 82px;
  height: 82px;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  object-fit: cover;
  background: white;
}

.import-dish-card p,
.import-dish-card span,
.import-info-card p {
  color: var(--muted);
  font-weight: 750;
}

.import-dish-card h3,
.import-info-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
}

.import-dish-card p,
.import-dish-card span,
.import-info-card p {
  margin: 0 0 8px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.editable-field {
  min-height: 30px;
  white-space: pre-wrap;
  border-radius: 12px;
  padding: 4px 6px;
}

.editable-field.editing {
  outline: 2px solid var(--blue);
  background: white;
  color: var(--ink);
}

.blocked-card {
  border-style: dashed;
}

.media-panel {
  display: grid;
  gap: 12px;
}

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

.image-grid img,
.video-list video {
  width: 100%;
  max-width: 100%;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: white;
}

.image-grid img {
  aspect-ratio: 1;
  object-fit: cover;
}

.video-list {
  display: grid;
  gap: 10px;
}

.video-list video {
  display: block;
  aspect-ratio: 9 / 16;
  max-height: 560px;
  object-fit: contain;
}

.embed-preview {
  display: grid;
  gap: 10px;
}

.embed-preview iframe {
  width: 100%;
  max-width: 100%;
  min-height: 360px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: white;
}

.import-info-card video {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.source-link {
  min-height: 44px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.submit {
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.danger-button {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: #b42318;
  font-weight: 900;
}

.feedback-list,
.shopping-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.feedback-list article,
.shopping-list article,
.recipe-tags {
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.feedback-list h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.feedback-list p,
.shopping-list span {
  color: var(--muted);
  font-weight: 700;
}

.recipe-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.recipe-tags span {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: white;
  font-weight: 900;
}

.shopping-list strong {
  display: block;
  font-size: 22px;
  margin-bottom: 8px;
}

.shopping-float {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(386px, calc(100% - 42px));
  min-height: 72px;
  border-radius: 24px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
}

.hidden {
  display: none !important;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.24);
  display: grid;
  place-items: end center;
  padding: 18px;
}

.dialog-card {
  width: min(430px, 100%);
  border-radius: 28px;
  padding: 22px;
}

.dialog-card h2 {
  margin: 0 0 16px;
}

.dialog-card label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.crop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.34);
  display: grid;
  place-items: end center;
  padding: 16px;
}

.crop-card {
  width: min(430px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 28px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 18px;
}

.crop-card h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 900;
}

.crop-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.crop-canvas {
  display: block;
  width: 100%;
  max-height: 42vh;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: white;
  object-fit: contain;
  touch-action: none;
  cursor: move;
}

.crop-card label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 900;
}

.crop-card select,
.crop-card input[type="range"] {
  width: 100%;
}

.crop-card select {
  min-height: 40px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 900;
}

.crop-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.crop-actions button {
  min-height: 44px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 900;
}

.crop-actions .dark {
  background: var(--ink);
  color: white;
}

@media (max-width: 370px) {
  .phone {
    width: calc(100vw - 8px);
    padding: 14px 8px 120px;
  }

  .category-rail {
    width: 74px;
    flex-basis: 74px;
  }

  .category-item {
    width: 62px;
    font-size: 13px;
  }

  .category-icon {
    width: 48px;
    height: 48px;
  }

  .section-heading {
    padding-right: 0;
  }

  .heading-actions {
    position: static;
    margin-top: 12px;
  }

  .import-dish-card {
    grid-template-columns: 1fr;
  }

  .import-dish-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}
