:root {
  --ink: #193643;
  --text: #1f2933;
  --muted: #63717a;
  --line: #d8dee3;
  --surface: #ffffff;
  --page: #f5f7f8;
  --accent: #00a7a5;
  --accent-dark: #007a79;
  --shadow: 0 18px 50px rgba(25, 54, 67, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

.page-header,
.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.page-header {
  padding: 40px 0 18px;
}

.page-header img {
  display: block;
  width: 126px;
  height: auto;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(420px, 1fr);
  gap: 28px;
  padding: 0 0 40px;
}

.editor,
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor {
  padding: 28px;
}

h1 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0;
}

.intro {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

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

.form-surface {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

label {
  display: grid;
  gap: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-half {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input,
select {
  height: 32px;
  min-height: 32px;
  padding: 4px 8px;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(6, 89, 255, 0.16);
  box-shadow: 0 0 0 1px #0659ff;
}

input {
  color: var(--ink);
  box-shadow: 0 0 0 1px #cee2ea;
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
}

input::placeholder {
  color: #63717a;
  opacity: 1;
}

.field.has-error input {
  box-shadow: 0 0 0 1px #c21200;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding-top: 4px;
  color: #c21200;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.field-error[hidden] {
  display: none;
}

.field-error::before,
.status.is-error::before {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1.6px solid #c21200;
  border-radius: 50%;
  color: #c21200;
  content: "i";
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  text-align: center;
}

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

button {
  min-height: 32px;
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.high-emphasis {
  color: #fff;
  background: linear-gradient(0deg, #0659ff 0%, #377dff 100%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 0 0 1px #0659ff;
  text-shadow: 0 1px 2px rgba(25, 54, 67, 0.1);
}

button.high-emphasis:hover {
  background: linear-gradient(0deg, #0047d5 0%, #246bff 100%);
}

button.low-emphasis,
button.secondary {
  color: #0047d5;
  background: transparent;
}

button.low-emphasis:hover,
button.secondary:hover {
  color: #0038a8;
  background: rgba(6, 89, 255, 0.08);
}

button.destructive-low {
  color: #b42318;
  background: transparent;
}

button.destructive-low:hover {
  color: #8a1c14;
  background: rgba(180, 35, 24, 0.08);
}

.generate-section {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.storage-notice {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.generate-button {
  width: 100%;
}

.generation-progress {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.generation-progress[hidden] {
  display: none;
}

.progress-bar {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 100px;
  background: #f1f7fa;
}

.progress-bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  border-radius: 100px;
  background: linear-gradient(90deg, rgba(6, 89, 255, 0), #377dff 55%, rgba(6, 89, 255, 0));
  animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(350%);
  }
}

.upload-dropzone {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 80px;
  padding: 24px;
  border: 1px dashed #cee2ea;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.upload-dropzone.has-file,
.upload-dropzone.has-error {
  align-items: center;
}

.upload-dropzone.has-file .upload-hint,
.upload-dropzone.has-error .upload-hint {
  display: none;
}

.upload-dropzone.is-dragging {
  border-color: #0659ff;
  background: #f8fbfd;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 6px;
  color: var(--ink);
  background: linear-gradient(0deg, #f8fbfd 0%, #ffffff 100%);
  box-shadow: 0 1px 1px rgba(25, 54, 67, 0.16), 0 0 0 1px #cee2ea;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}

.upload-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.upload-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.upload-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 24px;
}

.upload-status[hidden] {
  display: none;
}

.upload-status__icon {
  position: relative;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.upload-status__icon::before,
.upload-status__icon::after {
  position: absolute;
  content: "";
}

.upload-status.is-success .upload-status__icon::before {
  left: 5px;
  top: 7px;
  width: 13px;
  height: 8px;
  border-bottom: 2px solid #0047d5;
  border-left: 2px solid #0047d5;
  transform: rotate(-45deg);
}

.upload-status.is-error .upload-status__icon::before {
  inset: 4px;
  border: 2px solid #c21200;
  border-radius: 50%;
}

.upload-status.is-error .upload-status__icon::after {
  left: 11px;
  top: 8px;
  width: 2px;
  height: 8px;
  background: #c21200;
  box-shadow: 0 10px 0 #c21200;
}

.upload-status__copy {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.upload-status__name {
  display: flex;
  align-items: center;
  min-height: 24px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-status.is-success .upload-status__name {
  color: #0047d5;
}

.upload-status__message {
  display: none;
  color: #c21200;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.upload-status.is-error .upload-status__message {
  display: block;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #63717a;
  background: transparent;
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(25, 54, 67, 0.06);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.status {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--accent-dark);
  font-size: 13px;
}

.status.is-error {
  color: #c21200;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.photo-check {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 14px 14px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.photo-check[hidden] {
  display: none;
}

.photo-check__preview {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  flex: 0 0 70px;
  overflow: hidden;
  border-radius: 50%;
  background: #e8eef1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.photo-check__preview:active {
  cursor: grabbing;
}

.photo-check__preview:focus {
  outline: 3px solid rgba(0, 167, 165, 0.18);
  outline-offset: 3px;
}

.photo-check__preview img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.photo-check p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}


.preview-panel {
  display: grid;
  align-content: start;
  gap: 0;
  overflow: hidden;
}

.preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.preview-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0;
}

.preview-heading span {
  color: var(--muted);
  font-size: 13px;
}

.signature-preview {
  min-height: 260px;
  padding: 28px;
  overflow-x: auto;
  background: #fff;
}

.html-output {
  width: min(640px, calc(100% - 56px));
  margin: 12px 28px 28px;
  overflow: hidden;
  border: 1px solid #cee2ea;
  border-radius: 6px;
  background: #fff;
}

.html-output[hidden] {
  display: none;
}

.generated-actions {
  display: flex;
  gap: 12px;
  margin: 20px 28px 0;
}

.generated-actions[hidden] {
  display: none;
}

.html-output summary {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 0 24px;
  color: #0047d5;
  background: #fff;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  cursor: pointer;
  list-style: none;
}

.html-output summary::-webkit-details-marker {
  display: none;
}

.disclosure-icon {
  width: 8px;
  height: 8px;
  border-top: 2px solid #63717a;
  border-right: 2px solid #63717a;
  transform: rotate(45deg);
}

.html-output[open] .disclosure-icon {
  transform: rotate(135deg);
}

.hide-label {
  display: none;
}

.html-output[open] summary {
  border-bottom: 1px solid #cee2ea;
  background: #f3f9fc;
}

.html-output[open] .show-label {
  display: none;
}

.html-output[open] .hide-label {
  display: inline;
}

.html-output textarea {
  display: block;
  min-height: 240px;
  padding: 16px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 920px) {
  .page-header,
  .app-shell {
    width: min(720px, calc(100% - 28px));
  }

  .page-header {
    padding: 24px 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 0 0 24px;
  }
}

@media (max-width: 560px) {
  .editor {
    padding: 22px;
  }

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

  .form-surface {
    padding: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .preview-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .generated-actions {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
