:root {
  --bg: #f5f5f7;
  --surface: #e7eeec;
  --paper: #ffffff;
  --slot: #d8d9de;
  --text: #0d1328;
  --muted: #59648b;
  --stroke: #141414;
  --brand: #f3f3f3;
  --line: rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

.mobile-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 16px 12px 128px;
}

.frame-card {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.canvas-wrap {
  width: 100%;
  border-radius: 0;
  overflow: hidden;
}

#editorCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.4142;
  touch-action: none;
  background: var(--paper);
  user-select: none;
  -webkit-user-select: none;
}

.panel {
  margin-top: 16px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0 4px;
}

.panel h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(28px, 8vw, 36px);
  letter-spacing: -0.02em;
  font-weight: 700;
}

.sub {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: clamp(15px, 4.8vw, 17px);
}

.controls {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.text-input-wrap {
  width: 360px;
  max-width: 100%;
  margin: 0 auto;
}

.headline-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  font-size: clamp(15px, 4.6vw, 17px);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.82);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.headline-input::placeholder {
  color: rgba(15, 23, 42, 0.45);
}

.headline-input:focus {
  border-color: rgba(17, 24, 39, 0.44);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.headline-input.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.headline-warning {
  margin: 6px 2px 0;
  min-height: 18px;
  color: #dc2626;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  min-height: 44px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: clamp(16px, 5vw, 18px);
  font-weight: 450;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  filter: saturate(0.35);
  transform: none;
  box-shadow: none;
}

.btn:disabled:active {
  transform: none;
}

.btn-upload {
  background: rgba(211, 211, 211, 0.5);
  color: #0f172a;
  width: 360px;
    /* กำหนดตามที่ต้องการ */
    max-width: 100%;
    margin: 0 auto;
    /* ให้อยู่กลาง */

}

.btn-svg {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 480px);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(236, 236, 236, 0.95);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
}

.bottom-bar .btn {
  width: auto;
  min-width: 108px;
  padding: 0 18px;
}

.btn-download {
  background: #dcffdb;
  color: #111827;
  border-color: rgba(15, 23, 42, 0.08);
}

.btn-print {
  background: #f8f8f8;
  color: #111827;
  border-color: #f3f3f3;
}

.btn-print .btn-svg {
  filter: brightness(0) invert(0);
}

@media (orientation: landscape) and (max-width: 920px) {
  .mobile-shell {
    width: 100%;
    max-width: 700px;
  }

  .panel h1 {
    font-size: 30px;
  }

  .sub {
    font-size: 15px;
  }
}
