:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f1f1ef;
  --text: #151515;
  --muted: #6b6b67;
  --border: #d9d9d4;
  --border-strong: #b9b9b3;
  --field: #ffffff;
  --ok: #3e5948;
  --warn: #6a5a35;
  --error: #7a3b3b;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(960px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

main {
  flex: 1;
  display: flex;
}

.view {
  width: 100%;
  padding: 24px 16px 48px;
}

.compose-layout {
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 0.74fr) minmax(320px, 1.26fr);
  gap: 16px;
  align-items: start;
}

.intro-panel,
.form-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.intro-panel {
  min-height: 240px;
  padding: 28px;
}

.slot-visual {
  width: 100%;
  height: 96px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  position: relative;
}

.slot-visual::before {
  content: "";
  position: absolute;
  left: 28%;
  right: 28%;
  top: 34px;
  height: 2px;
  background: var(--text);
}

.slot-visual::after {
  content: "";
  position: absolute;
  left: 28%;
  right: 28%;
  bottom: 24px;
  height: 22px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.slot-visual span {
  display: none;
}

.kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.desktop-break {
  display: block;
}

.form-panel {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  outline: none;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 240px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--text);
}

::placeholder {
  color: #9b9b96;
}

.form-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.upload-field {
  display: grid;
  gap: 10px;
}

.image-picker {
  min-height: 82px;
  align-content: center;
  gap: 5px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.image-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-picker strong {
  color: var(--text);
  font-size: 15px;
}

.image-picker small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
}

.selected-image {
  min-height: 164px;
  display: grid;
  grid-template-rows: 92px 1fr auto;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.selected-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-soft);
}

.selected-image div {
  min-width: 0;
}

.selected-image strong,
.selected-image span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-image strong {
  color: var(--text);
  font-size: 12px;
}

.selected-image span {
  color: var(--muted);
  font-size: 12px;
}

.selected-image button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 700;
}

.hidden-field {
  position: absolute;
  left: -9999px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
}

.counter,
.status-line {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status-line.success {
  color: var(--ok);
  font-weight: 700;
}

.status-line.error {
  color: var(--error);
  font-weight: 700;
}

.status-line.info {
  color: var(--warn);
  font-weight: 700;
}

.upload-progress {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.upload-progress span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--text);
}

.primary-button {
  min-height: 40px;
  min-width: 104px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--surface);
  background: var(--text);
  font-weight: 700;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #000000;
  outline: none;
}

.primary-button[disabled] {
  cursor: wait;
  opacity: 0.68;
}

.button-icon {
  line-height: 1;
}

@media (max-width: 760px) {
  .topbar {
    width: min(100% - 24px, 960px);
    min-height: 56px;
  }

  .view {
    padding: 12px 12px 28px;
  }

  .compose-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .intro-panel {
    min-height: auto;
    padding: 20px;
  }

  .slot-visual {
    height: 70px;
    margin-bottom: 18px;
  }

  .slot-visual::before {
    top: 25px;
  }

  .slot-visual::after {
    bottom: 16px;
    height: 16px;
  }

  .form-panel {
    min-height: auto;
    padding: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .desktop-break {
    display: none;
  }

  textarea {
    min-height: 220px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 30px;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }
}
