:root {
  --bg: #fff;
  --ink: #222;
  --muted: #8a8a8a;
  --soft: #c4c4c4;
  --line: rgba(0, 0, 0, 0.06);
  --panel: rgba(250, 250, 250, 0.82);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

@font-face {
  font-family: "DFPLiSong-Lt";
  src: url("/font/lisong.ttf") format("truetype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "DFPLiSong-Lt", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  transition: opacity 0.35s ease;
}

.splash h1 {
  margin: 0 0 12px;
  font-size: 48px;
  font-weight: 500;
}

.splash p {
  margin: 0;
  color: #666;
  font-size: 14px;
}

.works-button {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  z-index: 60;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--line);
  color: #424242;
  cursor: pointer;
  line-height: 1.25;
  backdrop-filter: blur(20px);
}

.home {
  min-height: 100vh;
  background: #fff;
  padding: 48px 24px 80px;
}

.home-header {
  text-align: center;
  margin-bottom: 42px;
}

.home-header h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 500;
}

.home-header p {
  color: var(--soft);
  line-height: 1.55;
}

.home-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 24px 0 56px;
}

.home-upload .upload-card {
  width: min(520px, calc(100% - 32px));
  padding: 88px 32px;
  border-radius: 22px;
  border: 1.5px dashed var(--soft);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.home-upload .upload-card:hover {
  border-color: #888;
  background: rgba(245, 245, 245, 0.95);
  transform: translateY(-2px);
}

.home-upload .upload-card p {
  margin: 0 0 10px;
  font-size: 20px;
  color: #222;
}

.home-error {
  margin-top: 18px;
  width: min(520px, calc(100% - 32px));
}

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

.template-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #d0d0d0;
}

.template-card img {
  width: 100%;
  border-radius: 8px;
  display: block;
  background: #f3f3f3;
  aspect-ratio: 1280 / 1820;
  object-fit: cover;
}

.text-link {
  background: transparent;
  color: #555;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
}

.text-link:hover {
  color: #111;
  background: rgba(0, 0, 0, 0.04);
}

.about {
  max-width: 880px;
  margin: 0 auto;
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.about h2 {
  margin: 0 0 22px;
  font-size: 30px;
  font-weight: 500;
}

.about p {
  margin: 0 0 16px;
  color: #555;
  font-size: 18px;
  line-height: 1.85;
}

.editor {
  min-height: 100vh;
  background: #faf9f7;
  padding-bottom: 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 26px;
}

.topbar-title {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

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

.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #d1d5db;
}

.step-line {
  width: 36px;
  height: 2px;
  background: #d1d5db;
}

.step-on {
  background: #666;
}

.panel {
  width: min(760px, calc(100% - 32px));
  margin: 16px auto 0;
}

.upload-box {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-card {
  width: min(420px, 100%);
  padding: 64px 28px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  text-align: center;
  cursor: pointer;
}

.upload-card p {
  margin: 0 0 8px;
}

.upload-card span,
.caption {
  color: #777;
  font-size: 13px;
}

.error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
}

.crop-shell {
  display: grid;
  gap: 16px;
}

.ratio-row,
.filter-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.pill {
  min-width: 72px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #555;
  cursor: pointer;
}

.pill.active {
  border-color: #222;
  color: #111;
}

.crop-area {
  height: min(68vh, 720px);
  border-radius: 14px;
  overflow: hidden;
  background: #eee;
}

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

.filter-preview {
  width: min(420px, 100%);
  margin: 0 auto 18px;
  border-radius: 14px;
  overflow: hidden;
  background: #eee;
  box-shadow: var(--shadow);
}

.filter-preview img {
  width: 100%;
  display: block;
}

.field-card {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.field-card label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  font-size: 13px;
}

.field-card textarea,
.field-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(250, 250, 250, 0.6);
  padding: 10px 12px;
  outline: 0;
  color: #111;
  font-size: 15px;
  line-height: 1.5;
}

.meta-line {
  margin-top: 8px;
  color: #aaa;
  font-size: 12px;
}

.primary,
.secondary {
  min-width: 130px;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
}

.primary {
  background: #111;
  color: #fff;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary {
  background: #f0f0f0;
  color: #555;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(430px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  padding: 22px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
}

.result-img {
  width: 100%;
  border-radius: 14px;
  display: block;
  background: #f3f3f3;
}

.modal-title {
  margin: 16px 0;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.close-x {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #f4f4f4;
  cursor: pointer;
}

.works-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.work-item img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  background: #f3f3f3;
}

.loading {
  text-align: center;
  color: #666;
  line-height: 1.8;
}

@media (max-width: 760px) {
  .home {
    padding: 32px 16px 60px;
  }

  .home-header {
    margin-bottom: 28px;
  }

  .home-header h1 {
    font-size: 26px;
  }

  .home-upload {
    margin: 12px 0 36px;
  }

  .home-upload .upload-card {
    padding: 64px 24px;
  }

  .about {
    display: none;
  }

  .panel {
    width: calc(100% - 24px);
  }

  .template-grid {
    gap: 12px;
  }

  .template-card {
    padding: 10px;
  }

  .crop-area {
    height: 58vh;
  }

  .action-row {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: #faf9f7;
  }
}
