* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --card-width: 700px;
  --card-height: 1000px;
  --card-scale: 1;
  --preview-zoom: 1;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Noto Sans JP", sans-serif;
  background: #e8e8e8;
  color: #333;
  overscroll-behavior: none;
}

.container {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  width: 100%;
  min-height: 100svh;
}

.panel {
  width: 340px;
}

.preview {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 30px;
}

.card-shell {
  width: calc(var(--card-width) * var(--card-scale));
  height: calc(var(--card-height) * var(--card-scale));
  flex-shrink: 0;
}

#card {
  transform: scale(var(--card-scale));
  transform-origin: top left;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: 16px;
}

@media (max-width: 900px) {
  .container {
    display: flex;
    flex-direction: column-reverse;
  }

  .panel {
    width: 100%;
  }

  .preview {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    background: #dcdcdc;
    justify-content: center;
    overflow: hidden;
  }
}

/* =========================
   Ver25 Mobile UI
   ========================= */
.mobile-tabs,
.mobile-floating-actions,
.ios-install-hint {
  display: none;
}

@media (max-width: 900px) {
  body {
    background: #f1f5f9;
    padding-bottom: 88px;
  }

  .container {
    display: block;
    min-height: 100svh;
  }

  .mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(241, 245, 249, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }

  .mobile-tabs button {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  }

  .mobile-tabs button.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
  }

  body.mobile-edit .preview {
    display: none !important;
  }

  body.mobile-preview .panel,
  body.mobile-layout .panel {
    display: none !important;
  }

  body.mobile-preview .preview,
  body.mobile-layout .preview {
    display: flex !important;
    position: static;
    min-height: calc(100svh - 64px);
    padding: 18px 12px 96px;
    background: radial-gradient(circle at top, #ffffff 0, #e2e8f0 48%, #cbd5e1 100%);
    overflow: auto;
    align-items: flex-start;
  }

  body.mobile-preview .card-shell,
  body.mobile-layout .card-shell {
    margin: 0 auto;
    filter: drop-shadow(0 18px 26px rgba(15, 23, 42, 0.24));
  }

  body.mobile-layout .preview {
    background: radial-gradient(circle at top, #fff7ed 0, #e2e8f0 50%, #cbd5e1 100%);
  }

  body.mobile-layout .layout-hint-bar {
    display: block;
  }

  body.mobile-preview .mobile-preview-zoom {
    display: flex;
  }

  body.mobile-preview .layout-hint-bar {
    display: none;
  }

  body.mobile-preview #card {
    pointer-events: none;
  }

  body.mobile-preview .card-shell {
    width: calc(var(--card-width) * var(--card-scale) * var(--preview-zoom));
    height: calc(var(--card-height) * var(--card-scale) * var(--preview-zoom));
  }

  body.mobile-preview #card {
    transform: scale(calc(var(--card-scale) * var(--preview-zoom)));
  }

  .mobile-preview-zoom {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    z-index: 1001;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 10px 26px rgba(15,23,42,.22);
    backdrop-filter: blur(10px);
  }

  .mobile-preview-zoom button {
    min-width: 42px;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-weight: 800;
  }

  .mobile-preview-zoom #previewZoomReset {
    min-width: 74px;
    background: #ffffff;
    color: #0f172a;
  }

  .mobile-preview-zoom span {
    min-width: 54px;
    text-align: center;
    font-weight: 800;
    color: #0f172a;
  }

  .layout-hint-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    z-index: 1001;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(15,23,42,.88);
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 26px rgba(15,23,42,.22);
  }

  .panel {
    padding: 16px;
    background: #f8fafc;
  }

  .panel h2 {
    font-size: 20px;
    margin: 8px 0 14px;
  }

  .notice-box,
  .noframe-options,
  .job-group {
    border-radius: 14px;
  }

  .main-job-buttons label,
  .sub-job-buttons label {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .mobile-floating-actions {
    position: fixed;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
  }

  .mobile-floating-actions button {
    border: none;
    border-radius: 999px;
    padding: 13px 18px;
    min-height: 48px;
    background: #0f172a;
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
  }

  .mobile-floating-actions #installPwaButton {
    background: #2563eb;
  }

  .panel #saveButton {
    display: none;
  }

  .ios-install-hint {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 1002;
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.92);
    color: #ffffff;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.26);
  }

  .ios-install-hint[hidden],
  .mobile-floating-actions button[hidden] {
    display: none !important;
  }
}

@media (max-width: 420px) {
  body.mobile-preview .preview {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* =========================
   Ver27 Stability
   ========================= */
@media (max-width: 900px) {
  html,
  body {
    min-height: 100svh;
    overflow-x: auto;
    overscroll-behavior-y: contain;
  }

  body.mobile-preview,
  body.mobile-layout {
    overflow-y: auto;
  }

  body.mobile-preview .preview,
  body.mobile-layout .preview {
    height: auto;
    max-height: none;
    overflow-y: auto !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: contain;
  }

  body.mobile-preview .card-shell {
    flex: 0 0 auto;
  }

  body.mobile-edit .panel {
    min-height: calc(100svh - 64px);
    overflow: visible;
  }
}

.mobile-preview-zoom,.layout-hint-bar{display:none;}
@media (min-width:901px){.mobile-preview-zoom,.layout-hint-bar{display:none!important;}}


/* =========================
   v33.1 Mobile spread landscape workspace
   ========================= */
.landscape-prompt,
.mobile-landscape-toolbar {
  display: none;
}

@media (max-width: 900px) {
  body.mobile-spread-workspace.mobile-needs-landscape .landscape-prompt {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: linear-gradient(135deg, rgba(15,23,42,.92), rgba(51,65,85,.84));
    color: #fff;
  }

  .landscape-prompt-card {
    width: min(420px, 100%);
    padding: 24px 20px;
    border-radius: 24px;
    background: rgba(255,255,255,.96);
    color: #0f172a;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
  }

  .landscape-prompt-icon {
    font-size: 40px;
    margin-bottom: 8px;
  }

  .landscape-prompt-card h3 {
    font-size: 21px;
    margin: 0 0 10px;
  }

  .landscape-prompt-card p {
    margin: 0 0 18px;
    line-height: 1.7;
    font-size: 14px;
    color: #334155;
  }

  .landscape-prompt-actions {
    display: grid;
    gap: 10px;
  }

  .landscape-prompt-actions button {
    min-height: 46px;
    border: none;
    border-radius: 999px;
    font-weight: 800;
  }

  #landscapeFullscreenButton {
    background: #0f172a;
    color: #fff;
  }

  #landscapeContinueButton {
    background: #e2e8f0;
    color: #0f172a;
  }

  body.mobile-spread-workspace.mobile-landscape .mobile-tabs,
  body.mobile-spread-workspace.mobile-landscape .mobile-floating-actions {
    display: none !important;
  }

  body.mobile-spread-workspace.mobile-landscape {
    padding-bottom: 0;
    overflow: hidden;
    background: #020617;
  }

  body.mobile-spread-workspace.mobile-landscape .container {
    min-height: 100svh;
  }

  body.mobile-spread-workspace.mobile-landscape .preview {
    position: fixed !important;
    inset: 0;
    z-index: 1800;
    display: flex !important;
    width: 100vw;
    height: 100svh;
    min-height: 100svh;
    padding: 44px 10px 54px;
    background: radial-gradient(circle at center, #334155 0, #0f172a 58%, #020617 100%);
    overflow: auto !important;
    align-items: flex-start;
    justify-content: center;
    touch-action: pan-x pan-y pinch-zoom;
  }

  body.mobile-spread-workspace.mobile-landscape .mobile-landscape-toolbar {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    z-index: 1900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(15,23,42,.76);
    color: #fff;
    backdrop-filter: blur(10px);
  }

  .mobile-landscape-toolbar button {
    min-height: 32px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
    padding: 4px 12px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
  }

  .mobile-landscape-toolbar span {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .08em;
  }

  body.mobile-spread-workspace.mobile-landscape .layout-hint-bar,
  body.mobile-spread-workspace.mobile-landscape .mobile-preview-zoom {
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }

  body.mobile-spread-workspace.mobile-landscape .card-shell {
    margin: 0 auto;
  }

  body.mobile-spread-workspace.mobile-landscape.mobile-preview .card-shell {
    width: calc(var(--card-width) * var(--card-scale) * var(--preview-zoom));
    height: calc(var(--card-height) * var(--card-scale) * var(--preview-zoom));
  }

  body.mobile-spread-workspace.mobile-landscape.mobile-preview #card {
    transform: scale(calc(var(--card-scale) * var(--preview-zoom)));
  }
}


/* =========================
   v33.1.1 Android edit scroll stability
   ========================= */
@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
  }

  body.mobile-edit {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100dvh;
    touch-action: pan-y;
  }

  body.mobile-edit .container {
    display: block;
    min-height: 100dvh;
    height: auto !important;
    overflow: visible !important;
  }

  body.mobile-edit .panel {
    display: block !important;
    position: relative;
    height: auto !important;
    min-height: calc(100dvh - 64px);
    max-height: none !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  body.mobile-input-focused,
  body.mobile-input-focused .container,
  body.mobile-input-focused .panel {
    overflow-y: auto !important;
    overscroll-behavior-y: auto;
  }

  body.mobile-edit .preview {
    display: none !important;
    position: static !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  body.mobile-spread-workspace.mobile-landscape.mobile-layout,
  body.mobile-spread-workspace.mobile-landscape.mobile-preview {
    overflow: hidden !important;
    height: 100dvh;
  }

  body.mobile-spread-workspace.mobile-landscape .preview {
    height: 100dvh;
    min-height: 100dvh;
  }
}
