* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #eef1f5;
  color: #182230;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 0 40px rgba(15, 22, 32, 0.08);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.view-home {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

.home-media,
.home-media img,
.home-scrim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.home-media img {
  object-fit: cover;
}

.home-scrim {
  background: linear-gradient(
    180deg,
    rgba(13, 20, 29, 0.14) 0%,
    rgba(13, 20, 29, 0.28) 52%,
    rgba(13, 20, 29, 0.64) 100%
  );
}

.home-inner {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.brand {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  display: flex;
  align-items: center;
  color: #ffffff;
  font-size: 18px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 21px;
  font-weight: 700;
}

.entry-panel {
  width: 100%;
  max-width: 440px;
  padding: 22px 18px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 44px rgba(8, 14, 22, 0.22);
}

.panel-label {
  display: block;
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 600;
}

.entry-panel input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid #e2e6ec;
  border-radius: 9px;
  outline: none;
  background: #f7f9fb;
  font-size: 17px;
}

.entry-panel input:focus {
  border-color: #1e2632;
  background: #ffffff;
}

.primary-btn,
.secondary-btn,
.icon-button,
.text-button {
  height: 48px;
  border-radius: 9px;
}

.primary-btn {
  width: 100%;
  margin-top: 14px;
  background: #1e2632;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
}

.primary-btn:disabled {
  background: #b7bec9;
}

.view-editor,
.view-done {
  min-height: 100vh;
  min-height: 100dvh;
  background: #f3f5f8;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(22, 31, 44, 0.08);
}

.icon-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: transparent;
  color: #182230;
  font-size: 22px;
}

.icon-button:disabled,
.text-button:disabled {
  color: #b7bec9;
}

.topbar-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 8px;
}

.topbar-copy strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-copy span {
  margin-top: 2px;
  color: #7a8593;
  font-size: 11px;
}

.ratio-badge {
  flex: none;
  margin-left: auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf2fb;
  color: #1e4f9f;
  font-size: 12px;
  font-weight: 600;
}

.editor-body,
.done-body {
  padding: 18px 16px max(24px, env(safe-area-inset-bottom));
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 18px;
  border-radius: 12px;
  background: #1d222b;
}

.empty-panel {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 264px;
  border: 1px dashed rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  color: #ffffff;
}

.add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e4573d;
  color: #ffffff;
  font-size: 36px;
}

.empty-panel p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
}

.crop-panel {
  position: relative;
}

#cropCanvas {
  display: block;
  border-radius: 2px;
  touch-action: none;
  background: #ffffff;
}

.crop-marks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.crop-marks::before,
.crop-marks::after {
  position: absolute;
  content: "";
  opacity: 0.28;
}

.crop-marks::before {
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px solid #ffffff;
  transform: translateX(-50%);
}

.crop-marks::after {
  top: 50%;
  right: 0;
  left: 0;
  border-top: 1px solid #ffffff;
  transform: translateY(-50%);
}

.tool-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #ffffff;
}

.toolbar {
  display: flex;
  align-items: center;
}

.toolbar .icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid #e5e9ef;
  background: #ffffff;
}

.toolbar .icon-button + .icon-button {
  margin-left: 8px;
}

.text-button {
  flex: 1;
  margin-left: 8px;
  padding: 0 10px;
  border: 1px solid #e5e9ef;
  background: #ffffff;
  color: #182230;
  font-size: 14px;
}

.text-button + .text-button {
  margin-left: 8px;
}

.zoom-row {
  display: flex;
  align-items: center;
  margin-top: 14px;
  color: #586475;
  font-size: 13px;
}

.zoom-row input {
  flex: 1;
  min-width: 0;
  margin: 0 12px;
  accent-color: #1e2632;
}

.zoom-row output {
  min-width: 46px;
  color: #182230;
  font-size: 13px;
  text-align: right;
}

.done-title {
  margin-bottom: 10px;
  color: #182230;
  font-size: 15px;
  font-weight: 600;
}

.done-frame {
  margin: 0 auto;
  overflow: hidden;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(23, 35, 61, 0.14);
}

.done-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.done-size {
  margin-top: 10px;
  color: #7a8593;
  font-size: 12px;
  text-align: center;
}

.done-actions {
  display: flex;
  margin-top: 26px;
}

.secondary-btn {
  flex: 1;
  border: 1px solid #dfe4ea;
  background: #ffffff;
  color: #182230;
  font-size: 15px;
  font-weight: 600;
}

.done-actions .primary-btn {
  flex: 2;
  margin: 0 0 0 10px;
}

.toast {
  position: fixed;
  top: 18%;
  left: 50%;
  z-index: 100;
  max-width: 78%;
  padding: 11px 18px;
  border-radius: 9px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  background: rgba(24, 34, 48, 0.92);
  color: #ffffff;
  font-size: 14px;
  text-align: center;
}

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

@media (min-width: 900px) {
  .app {
    max-width: none;
    box-shadow: none;
  }

  .view-editor,
  .view-done {
    box-shadow: 0 0 40px rgba(15, 22, 32, 0.08);
  }

  .home-inner {
    padding: 44px;
  }

  .brand {
    top: 28px;
    left: 44px;
    font-size: 22px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 24px;
  }

  .entry-panel {
    max-width: 480px;
    padding: 32px 28px 26px;
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(8, 14, 22, 0.26);
  }

  .panel-label {
    margin-bottom: 12px;
    font-size: 16px;
  }

  .entry-panel input {
    height: 56px;
    padding: 0 18px;
    font-size: 18px;
  }

  .primary-btn {
    height: 54px;
    margin-top: 18px;
    font-size: 17px;
  }

  .editor-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto auto;
    gap: 20px 26px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }

  .stage {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: 380px;
    padding: 24px;
  }

  .tool-panel {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
  }

  #finishButton {
    grid-column: 2;
    grid-row: 2;
    height: 54px;
  }

  .done-body {
    max-width: 920px;
    margin: 0 auto;
    padding: 32px max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }
}
