/* ==========================================================================
   MOJIGUMI 排版工藝 - Swiss Editorial Bento Edition
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, Monaco, monospace;

  /* Swiss Editorial Light (Warm Paper & Ink) */
  --bg-page: #f3f1ec;
  --bg-surface: #ffffff;
  --bg-surface-warm: #fffdf9;
  --bg-stage: #f3f1ec;
  --bg-control: #f3f1ec;
  --bg-control-active: #141413;

  --text-main: #141413;
  --text-muted: #57534e;
  --text-sub: #78716c;

  --ink: #141413;
  --border-ink: 1.5px solid #141413;
  --border-dashed: 1.5px dashed #c7c2b8;
  --border-ruler: 1px dashed #b8b4ac;

  --accent-orange: #ff4f00;
  --accent-orange-hover: #e04500;
  --accent-ink: #141413;
  --accent-ink-text: #ffffff;

  --shadow-bento: 5px 5px 0 #141413;
  --shadow-sm: 3px 3px 0 #141413;
  --shadow-hover: 2px 2px 0 #141413;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  /* Swiss Editorial Dark (Carbon Press & Cream Ink) */
  --bg-page: #111110;
  --bg-surface: #1b1b19;
  --bg-surface-warm: #201f1d;
  --bg-stage: #141413;
  --bg-control: #141413;
  --bg-control-active: #f3f1ec;

  --text-main: #f3f1ec;
  --text-muted: #a8a29e;
  --text-sub: #78716c;

  --ink: #e7e5e0;
  --border-ink: 1.5px solid #44423e;
  --border-dashed: 1.5px dashed #3a3834;
  --border-ruler: 1px dashed #44423e;

  --accent-orange: #ff5912;
  --accent-orange-hover: #ff6e30;
  --accent-ink: #f3f1ec;
  --accent-ink-text: #141413;

  --shadow-bento: 5px 5px 0 #000000;
  --shadow-sm: 3px 3px 0 #000000;
  --shadow-hover: 2px 2px 0 #000000;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 22px 24px 56px;
}

/* ==========================================================================
   Header (Swiss Editorial Bar)
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: var(--border-ink);
  border-radius: 18px;
  padding: 14px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background-color: var(--accent-ink);
  color: var(--accent-ink-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-jp {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sample-btn {
  background: var(--bg-control);
  border: var(--border-ink);
  color: var(--text-main);
  padding: 0 15px;
  height: 38px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.sample-btn:hover {
  background: var(--bg-surface);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.icon-btn {
  background: var(--bg-control);
  border: var(--border-ink);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

[data-theme="light"] .moon-icon { display: block; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }

/* ==========================================================================
   Tool Tabs (Swiss Numbered Pills)
   ========================================================================== */

.tool-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  border: var(--border-ink);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 3px 3px 0 var(--ink);
  transition: all 0.14s ease;
}

.tab-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

.tab-btn.active {
  background: var(--accent-ink);
  color: var(--accent-ink-text);
  box-shadow: 3px 3px 0 var(--accent-orange);
}

.tab-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-orange);
}

.tab-btn.active .tab-num {
  color: #ff854d;
}

.tab-icon {
  font-size: 0.95rem;
}

/* ==========================================================================
   Main Bento Workspace Layout
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.module-kicker {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-orange);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

/* ==========================================================================
   Editor Pane (Left Bento Box)
   ========================================================================== */

.editor-pane {
  background: var(--bg-surface);
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-bento);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: var(--border-dashed);
}

.panel-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.panel-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.w-30 { width: 35%; }

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
  flex-wrap: wrap;
}

.label-row label {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.hint {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--text-muted);
}

.mini-action-btn {
  background: var(--bg-control);
  border: var(--border-ink);
  color: var(--text-main);
  padding: 3px 11px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.mini-action-btn:hover {
  background: var(--accent-orange);
  color: #ffffff;
}

textarea, input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-stage);
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.5;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
}

textarea:focus, input[type="text"]:focus {
  outline: none;
  background: var(--bg-surface);
  box-shadow: 3px 3px 0 var(--accent-orange);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 600px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
}

.segmented-control {
  display: flex;
  background: var(--bg-stage);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: var(--border-ink);
  gap: 3px;
}

.seg-btn {
  flex: 1;
  padding: 7px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: center;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background: var(--bg-control-active);
  color: var(--accent-ink-text);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.slider-badge {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--accent-ink);
  color: var(--accent-ink-text);
  padding: 2px 9px;
  border-radius: 6px;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-orange);
  cursor: pointer;
}

.editor-spec-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 8px;
  border-top: var(--border-dashed);
  gap: 8px;
  flex-wrap: wrap;
}

.spec-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.spec-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-ink);
  color: var(--accent-ink-text);
  padding: 3px 9px;
  border-radius: 6px;
}

/* ==========================================================================
   Preview Pane (Right Bento Proof Box)
   ========================================================================== */

.preview-pane {
  position: sticky;
  top: 20px;
}

.preview-card {
  background: var(--bg-surface-warm);
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-bento);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: var(--border-dashed);
  margin-bottom: 16px;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  background-color: var(--accent-orange);
}

.preview-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fold-sim-btn {
  background: var(--bg-stage);
  border: var(--border-ink);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
}

.fold-sim-btn:hover {
  background: var(--accent-orange);
  color: #ffffff;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: var(--border-ink);
  background: var(--bg-surface);
  color: var(--text-main);
  white-space: nowrap;
}

.badge.warning {
  background: var(--accent-orange);
  color: #ffffff;
}

/* X Post Mock UI (Proof Stage) */
.x-post-mock {
  display: flex;
  gap: 12px;
  background: var(--bg-stage);
  border: var(--border-ink);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.x-post-avatar .avatar-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--accent-ink);
  color: var(--accent-ink-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  border: var(--border-ink);
  flex-shrink: 0;
}

.x-post-content {
  flex: 1;
  min-width: 0;
}

.x-post-user {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.user-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.user-handle {
  font-size: 0.8rem;
  color: var(--text-sub);
  font-family: var(--font-mono);
}

/* 16em Typography Ruler */
.type-ruler {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-sub);
  border-bottom: var(--border-ruler);
  padding-bottom: 4px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  max-width: 260px;
  user-select: none;
}

.x-post-text-wrapper {
  margin-bottom: 12px;
}

.x-post-text {
  font-size: 0.975rem;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--text-main);
  user-select: text;
}

.x-show-more-btn {
  background: none;
  border: none;
  color: var(--accent-orange);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 0 0;
  cursor: pointer;
  display: inline-block;
  text-decoration: underline;
}

/* X Action Icons */
.x-post-actions {
  display: flex;
  justify-content: space-between;
  max-width: 380px;
  padding-top: 10px;
  border-top: var(--border-ruler);
}

.action-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-sub);
  font-size: 0.76rem;
  font-family: var(--font-mono);
}

.action-item svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* Options Strip */
.options-strip {
  margin-bottom: 14px;
  padding: 9px 14px;
  background: var(--bg-stage);
  border: var(--border-ink);
  border-radius: var(--radius-sm);
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background-color: var(--text-sub);
  border-radius: var(--radius-full);
  position: relative;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background-color: #ffffff;
  border-radius: var(--radius-full);
  transition: transform 0.2s;
}

.toggle-control input:checked + .toggle-slider {
  background-color: var(--accent-orange);
}

.toggle-control input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Action Buttons */
.action-buttons-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-btn, .accent-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: var(--border-ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
}

.primary-btn {
  background: var(--bg-surface);
  color: var(--text-main);
}

.primary-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-hover);
  background: var(--bg-stage);
}

.accent-btn {
  background: var(--accent-orange);
  color: #ffffff;
}

.accent-btn:hover {
  background: var(--accent-orange-hover);
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-hover);
}

/* ==========================================================================
   Footer Bar (Swiss Ink Status Bar + Creator Credit)
   ========================================================================== */

.app-footer {
  margin-top: 22px;
  background: #141413;
  color: #ffffff;
  border: var(--border-ink);
  border-radius: 20px;
  padding: 16px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status-dot {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #ff5912;
  letter-spacing: 0.04em;
}

.status-desc {
  font-size: 0.82rem;
  color: #d6d3d1;
  font-weight: 600;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.share-service-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--accent-orange);
  color: #ffffff;
  border: 1.5px solid #ffffff;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.14s ease;
}

.share-service-footer-btn:hover {
  background: var(--accent-orange-hover);
  transform: translateY(-1px);
}

.creator-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 6px;
  background: #262523;
  border: 1.5px solid #44423e;
  border-radius: var(--radius-full);
  text-decoration: none;
  color: #ffffff;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.creator-badge:hover {
  transform: translateY(-1px);
  border-color: var(--accent-orange);
}

.creator-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1.5px solid #ffffff;
}

.creator-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.creator-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: #a8a29e;
  font-weight: 600;
}

.creator-handle {
  font-size: 0.84rem;
  font-weight: 700;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(140px);
  opacity: 0;
  visibility: hidden;
  background: #141413;
  color: #ffffff;
  border: 2px solid var(--accent-orange);
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: 4px 4px 0 var(--accent-orange);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Mobile Responsive Overrides (iPhone / Compact Screens)
   ========================================================================== */

@media (max-width: 640px) {
  .app-container {
    padding: 14px 12px 44px;
  }

  .app-header {
    padding: 12px 14px;
    border-radius: 16px;
    gap: 8px;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .brand-title-row {
    gap: 6px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
    gap: 5px;
  }

  .brand-jp {
    font-size: 0.78rem;
  }

  .brand-sub {
    font-size: 0.65rem;
  }

  .header-actions {
    gap: 6px;
  }

  .sample-btn {
    padding: 0 11px;
    height: 34px;
    font-size: 0.75rem;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .editor-pane,
  .preview-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .panel-header h2 {
    font-size: 1.15rem;
  }

  .action-buttons-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .app-footer {
    padding: 16px;
    border-radius: 18px;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .footer-status {
    justify-content: center;
  }

  .footer-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .share-service-footer-btn {
    width: 100%;
    justify-content: center;
    padding: 13px 18px;
    font-size: 0.9rem;
  }

  .creator-badge {
    width: 100%;
    justify-content: center;
    padding: 9px 18px;
  }

  .creator-info {
    text-align: left;
  }
}
