:root {
      --bg-body: #0b110e;
      --bg-card: #131b16;
      --bg-card-hover: #18241e;
      --border-color: #202d25;
      --gold: #cfa852;
      --gold-hover: #e0b860;
      --text-main: #f0f4f1;
      --text-muted: #8b9a91;
      --radius-sm: 8px;
      --radius-md: 12px;
      --radius-lg: 16px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
      background: var(--bg-body);
      color: var(--text-main);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
    }

    .icon {
      width: 18px;
      height: 18px;
      display: inline-block;
      vertical-align: middle;
      stroke-width: 2;
      stroke: currentColor;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
      flex-shrink: 0;
    }
    .icon-sm { width: 15px; height: 15px; }
    .icon-lg { width: 22px; height: 22px; }

    /* Top Header */
    header {
      background: var(--bg-card);
      border-bottom: 1px solid var(--border-color);
      padding: 12px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 100;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .brand-logo {
      height: 38px;
      width: auto;
      object-fit: contain;
      background: #ffffff;
      padding: 3px 6px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--gold);
    }
    .brand-meta h1 {
      font-size: 16px;
      font-weight: 800;
      color: #ffffff;
      letter-spacing: -0.01em;
    }
    .brand-meta p {
      font-size: 11px;
      color: var(--text-muted);
    }

    /* Mode Pill */
    .mode-switch {
      display: flex;
      background: #080d0a;
      border: 1px solid var(--border-color);
      border-radius: 30px;
      padding: 3px;
    }
    .mode-btn {
      padding: 7px 18px;
      border-radius: 24px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.2s ease;
    }
    .mode-btn.active {
      background: var(--gold);
      color: #0b110e;
    }

    /* Standard Harmonized Buttons */
    .btn {
      height: 42px;
      padding: 0 16px;
      border-radius: var(--radius-sm);
      font-weight: 600;
      font-size: 13px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: 1px solid transparent;
      transition: all 0.2s ease;
      font-family: inherit;
      white-space: nowrap;
      user-select: none;
    }
    .btn-gold {
      background: var(--gold);
      color: #0b110e;
    }
    .btn-gold:hover {
      background: var(--gold-hover);
    }
    .btn-outline {
      background: #18221b;
      color: #ffffff;
      border-color: var(--border-color);
    }
    .btn-outline:hover {
      background: var(--bg-card-hover);
      border-color: var(--gold);
    }
    .btn-whatsapp {
      background: #1f7a42;
      color: #ffffff;
    }
    .btn-whatsapp:hover {
      background: #258f4e;
    }
    .btn-facebook {
      background: #185a9d;
      color: #ffffff;
    }
    .btn-facebook:hover {
      background: #1d6cb8;
    }

    /* Main Workspace Grid (Fluid on PC, responsive on all devices) */
    main {
      flex: 1;
      display: grid;
      grid-template-columns: minmax(480px, 560px) 1fr;
      height: calc(100vh - 63px);
      overflow: hidden;
      width: 100%;
      max-width: 1600px;
      margin: 0 auto;
    }

    /* Left Stage View */
    .stage-view {
      padding: 20px 24px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 16px;
      background: #080d0a;
      overflow-y: auto;
    }

    /* Control Box (Date & Generate CTA) */
    .control-box {
      width: 100%;
      max-width: 530px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    /* 2-ROW BALANCED DATE CONTROL MODULE (Guaranteed 100% visible on PC & Mobile) */
    .date-card-module {
      display: flex;
      flex-direction: column;
      gap: 8px;
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: var(--radius-md);
      padding: 10px;
    }
    .date-picker-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      background: #090e0c;
      border: 1px solid var(--border-color);
      border-radius: var(--radius-sm);
      padding: 8px 12px;
      cursor: pointer;
      transition: all 0.2s ease;
      min-width: 0;
      box-sizing: border-box;
    }
    .date-picker-row:hover, .date-picker-row:focus-within {
      border-color: var(--gold);
      background: rgba(207, 168, 82, 0.05);
    }
    .date-icon-box {
      background: rgba(207, 168, 82, 0.15);
      color: var(--gold);
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .date-text-box {
      flex: 1;
      display: flex;
      flex-direction: column;
      text-align: left;
      overflow: hidden;
      min-width: 0;
    }
    .date-label-hint {
      font-size: 9px;
      color: var(--gold);
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }
    .date-label-val {
      font-size: 14px;
      font-weight: 800;
      color: #ffffff;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .date-native-input {
      color-scheme: dark;
      background: #18221b;
      border: 1px solid rgba(207, 168, 82, 0.35);
      border-radius: 6px;
      color: var(--gold);
      padding: 6px 10px;
      font-family: inherit;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      outline: none;
      flex-shrink: 0;
    }
    .date-native-input:focus {
      border-color: var(--gold);
    }

    /* 3 EQUAL BUTTONS ROW (1fr 1fr 1fr - Never cuts off!) */
    .date-buttons-row {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 8px;
      width: 100%;
      box-sizing: border-box;
    }
    .btn-nav {
      height: 38px;
      background: #18221b;
      border: 1px solid var(--border-color);
      border-radius: var(--radius-sm);
      color: #ffffff;
      padding: 0 8px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      transition: all 0.2s;
      white-space: nowrap;
      min-width: 0;
      overflow: hidden;
      box-sizing: border-box;
    }
    .btn-nav span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .btn-nav:hover {
      background: var(--gold);
      color: #0b110e;
    }
    .nav-label-short {
      display: none;
    }
    .nav-label-full {
      display: inline;
    }
    @media (max-width: 520px) {
      .nav-label-short {
        display: inline;
      }
      .nav-label-full {
        display: none;
      }
    }
    .btn-today {
      background: rgba(207, 168, 82, 0.12);
      border-color: rgba(207, 168, 82, 0.4);
      color: var(--gold);
      font-weight: 700;
    }
    .btn-today:hover {
      background: var(--gold);
      color: #0b110e;
    }

    /* HERO GENERATION BUTTON */
    .btn-generate-hero {
      width: 100%;
      background: linear-gradient(135deg, #cfa852 0%, #b88d36 100%);
      border: 1px solid #dfbb66;
      border-radius: var(--radius-md);
      padding: 12px 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 14px;
      color: #0b110e;
      box-shadow: 0 4px 18px rgba(207, 168, 82, 0.25);
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .btn-generate-hero:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 24px rgba(207, 168, 82, 0.4);
      background: linear-gradient(135deg, #dfbb66 0%, #cfa852 100%);
    }
    .btn-generate-hero:active {
      transform: translateY(0);
    }
    .btn-generate-hero:disabled {
      opacity: 0.6;
      cursor: not-allowed;
      transform: none;
    }
    /* LOCKED GENERATION BUTTON (Anti-duplication) */
    .btn-generate-hero.btn-locked {
      background: linear-gradient(135deg, rgba(30, 94, 61, 0.45) 0%, rgba(18, 48, 32, 0.65) 100%) !important;
      border: 1px solid rgba(52, 211, 153, 0.5) !important;
      color: #a7f3d0 !important;
      cursor: not-allowed !important;
      box-shadow: none !important;
      transform: none !important;
    }
    .btn-generate-hero.btn-locked .hero-icon-pulse {
      background: rgba(52, 211, 153, 0.22) !important;
      color: #34d399 !important;
      animation: none !important;
    }
    .btn-generate-hero.btn-locked .hero-title {
      color: #ecfdf5 !important;
    }
    .btn-generate-hero.btn-locked .hero-subtitle {
      color: #a7f3d0 !important;
      opacity: 0.9 !important;
    }
    .btn.action-disabled {
      opacity: 0.35 !important;
      pointer-events: none !important;
      cursor: not-allowed !important;
      filter: grayscale(0.5);
    }
    .hero-icon-pulse {
      background: rgba(11, 17, 14, 0.15);
      width: 40px;
      height: 40px;
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .hero-text-block {
      display: flex;
      flex-direction: column;
      text-align: left;
      overflow: hidden;
      min-width: 0;
      flex: 1;
    }
    .hero-title {
      font-size: 14px;
      font-weight: 800;
      letter-spacing: 0.04em;
      line-height: 1.25;
      white-space: normal;
    }
    .hero-subtitle {
      font-size: 11px;
      font-weight: 600;
      opacity: 0.85;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    /* Progress Banner */
    .gen-progress-bar {
      display: flex;
      align-items: center;
      gap: 10px;
      background: #18221b;
      border: 1px solid var(--gold);
      border-radius: var(--radius-sm);
      padding: 8px 14px;
      font-size: 12px;
      color: var(--gold);
      font-weight: 600;
    }
    .gen-spinner {
      width: 14px;
      height: 14px;
      border: 2px solid rgba(207, 168, 82, 0.3);
      border-top-color: var(--gold);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    /* Canvas Box */
    .poster-box {
      width: 100%;
      max-width: 530px;
      aspect-ratio: 1/1;
      box-shadow: 0 20px 50px -10px rgba(0,0,0,0.8), 0 0 0 1px rgba(207, 168, 82, 0.25);
      border-radius: var(--radius-sm);
      background: #faf8f2;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 0;
      box-sizing: border-box;
    }
    canvas#posterCanvas {
      display: block;
      width: 100% !important;
      height: auto !important;
      max-width: 100% !important;
      aspect-ratio: 1/1;
      border-radius: var(--radius-sm);
      box-sizing: border-box;
    }
    .poster-empty-state {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: radial-gradient(circle at center, rgba(30, 94, 61, 0.18) 0%, rgba(11, 17, 14, 0.97) 75%);
      padding: 24px;
      box-sizing: border-box;
      text-align: center;
    }
    .empty-state-frame {
      border: 1px dashed rgba(207, 168, 82, 0.4);
      border-radius: var(--radius-md);
      padding: 36px 22px;
      max-width: 380px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
      background: rgba(18, 28, 22, 0.65);
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }
    .empty-state-icon {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background: rgba(207, 168, 82, 0.12);
      border: 1px solid rgba(207, 168, 82, 0.35);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--gold);
    }
    .empty-state-title {
      font-family: var(--font-serif);
      font-size: 19px;
      font-weight: 700;
      color: var(--text-primary);
      margin: 0;
    }
    .empty-state-desc {
      font-size: 13px;
      color: var(--text-muted);
      line-height: 1.5;
      margin: 0;
    }
    .empty-state-pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(207, 168, 82, 0.15);
      border: 1px solid rgba(207, 168, 82, 0.3);
      color: var(--gold);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      padding: 6px 14px;
      border-radius: 999px;
    }
    .pulse-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--gold);
      animation: pulse 1.6s infinite ease-in-out;
    }
    @keyframes pulse {
      0%, 100% { opacity: 0.35; transform: scale(0.85); }
      50% { opacity: 1; transform: scale(1.15); }
    }

    /* Right Action Panel */
    .action-panel {
      background: var(--bg-card);
      border-left: 1px solid var(--border-color);
      display: flex;
      flex-direction: column;
      height: 100%;
      overflow-y: auto;
    }
    .panel-header-bar {
      padding: 14px 20px;
      border-bottom: 1px solid var(--border-color);
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #0d1510;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .panel-header-bar h2 {
      font-size: 14px;
      font-weight: 700;
      color: #ffffff;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .liturgy-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 700;
    }
    .chip-vert { background: rgba(30, 94, 61, 0.25); color: #6ee7a5; border: 1px solid #1e5e3d; }
    .chip-blanc { background: rgba(207, 168, 82, 0.25); color: #fde68a; border: 1px solid #cfa852; }
    .chip-rouge { background: rgba(122, 26, 34, 0.25); color: #fca5a5; border: 1px solid #7a1a22; }
    .chip-violet { background: rgba(68, 31, 99, 0.25); color: #d8b4fe; border: 1px solid #441f63; }

    .panel-body {
      padding: 20px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    /* UNIFIED HARMONIOUS ACTIONS GRID (2x2 Balanced, Zero Duplicates!) */
    .actions-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      width: 100%;
    }
    .actions-grid .btn {
      width: 100%;
    }

    .post-card {
      background: #0a100d;
      border: 1px solid var(--border-color);
      border-radius: var(--radius-md);
      padding: 16px;
      font-size: 13px;
      line-height: 1.6;
      color: #d1ded5;
      white-space: pre-wrap;
      max-height: 400px;
      overflow-y: auto;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .form-label {
      font-size: 11px;
      font-weight: 700;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .form-control {
      background: #090e0c;
      border: 1px solid var(--border-color);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
      color: #ffffff;
      font-family: inherit;
      font-size: 13px;
      outline: none;
      transition: border-color 0.2s;
    }
    .form-control:focus {
      border-color: var(--gold);
    }
    textarea.form-control {
      resize: vertical;
      min-height: 60px;
      line-height: 1.5;
    }

    /* Liturgical Colors Selector */
    .liturgy-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }
    .liturgy-option {
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border-color);
      background: #090e0c;
      color: #ffffff;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 10px;
      transition: all 0.2s;
      text-align: left;
    }
    .liturgy-option .swatch {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 2px solid #ffffff;
      flex-shrink: 0;
    }
    .liturgy-option.active {
      border-color: var(--gold);
      background: rgba(207, 168, 82, 0.12);
    }

    /* Sacred Art Gallery (Clean 3-column Grid) */
    .image-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }
    .img-card {
      border: 2px solid var(--border-color);
      border-radius: var(--radius-sm);
      overflow: hidden;
      cursor: pointer;
      position: relative;
      aspect-ratio: 4/3;
      background: #000;
      transition: all 0.2s;
    }
    .img-card:hover {
      border-color: rgba(207, 168, 82, 0.7);
    }
    .img-card.active {
      border-color: var(--gold);
      box-shadow: 0 0 10px rgba(207, 168, 82, 0.4);
    }
    .img-card img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .img-card span {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(0,0,0,0.85);
      font-size: 10px;
      text-align: center;
      padding: 3px 2px;
      color: #fff;
      font-weight: 600;
    }

    #toast {
      position: fixed;
      bottom: 20px;
      right: 20px;
      background: var(--gold);
      color: #0b110e;
      padding: 10px 18px;
      border-radius: var(--radius-sm);
      font-weight: 700;
      font-size: 13px;
      box-shadow: 0 10px 25px rgba(0,0,0,0.5);
      display: none;
      z-index: 1000;
    }

    /* Responsive Adaptation (Tablets & Mobile) */
    @media (max-width: 1024px) {
      header {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 12px;
      }
      .brand-meta h1 { font-size: 15px; }
      main {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        overflow-y: auto;
        width: 100%;
        max-width: 100vw;
      }
      .stage-view {
        padding: 14px 12px;
        height: auto;
        overflow: visible;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
      }
      .control-box {
        max-width: 530px;
        width: 100%;
        box-sizing: border-box;
      }
      .poster-box {
        max-width: 500px;
        width: 100%;
        box-sizing: border-box;
      }
      .action-panel {
        border-left: none;
        border-top: 1px solid var(--border-color);
        height: auto;
        overflow: visible;
        width: 100%;
        box-sizing: border-box;
      }
      .actions-grid {
        grid-template-columns: 1fr 1fr;
      }
      .image-grid {
        grid-template-columns: repeat(3, 1fr);
      }
    }

    @media (max-width: 600px) {
      header {
        padding: 8px 10px;
      }
      .brand-logo {
        height: 32px;
      }
      .brand-meta h1 {
        font-size: 14px;
      }
      .brand-meta p {
        font-size: 10px;
      }
      .header-actions {
        width: 100%;
      }
      .mode-switch {
        width: 100%;
      }
      .mode-btn {
        flex: 1;
        justify-content: center;
        padding: 6px 8px;
        font-size: 11px;
      }

      .stage-view {
        padding: 10px 8px;
        gap: 10px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
      }
      .control-box {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
      }
      .date-card-module {
        padding: 8px;
        box-sizing: border-box;
      }
      .date-picker-row {
        padding: 6px 8px;
        gap: 8px;
        box-sizing: border-box;
      }
      .date-icon-box {
        width: 28px;
        height: 28px;
        border-radius: 6px;
      }
      .date-label-hint {
        font-size: 8px;
        letter-spacing: 0.02em;
      }
      .date-label-val {
        font-size: 13px;
      }
      .date-native-input {
        max-width: 112px;
        padding: 4px 6px;
        font-size: 11px;
      }

      /* ALWAYS 1 HORIZONTAL ROW for 3 navigation buttons on mobile */
      .date-buttons-row {
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 5px;
        width: 100%;
        box-sizing: border-box;
      }
      .btn-nav {
        height: 34px;
        padding: 0 4px;
        font-size: 11px;
        gap: 4px;
      }
      .btn-nav .icon {
        width: 13px;
        height: 13px;
      }

      .btn-generate-hero {
        padding: 10px 12px;
        gap: 10px;
        box-sizing: border-box;
      }
      .hero-icon-pulse {
        width: 32px;
        height: 32px;
        border-radius: 8px;
      }
      .hero-icon-pulse .icon {
        width: 18px;
        height: 18px;
      }
      .hero-title {
        font-size: 12px;
        line-height: 1.25;
        white-space: normal;
        word-break: break-word;
      }
      .hero-subtitle {
        font-size: 10px;
      }

      /* Poster Box on Smartphone: full width, 1:1, strictly bounded */
      .poster-box {
        width: 100%;
        max-width: 100%;
        aspect-ratio: 1/1;
        box-sizing: border-box;
      }
      canvas#posterCanvas {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        aspect-ratio: 1/1;
        box-sizing: border-box;
      }
      .poster-empty-state {
        padding: 14px;
      }
      .empty-state-frame {
        padding: 20px 12px;
        gap: 8px;
      }
      .empty-state-icon {
        width: 40px;
        height: 40px;
      }
      .empty-state-title {
        font-size: 13px;
      }
      .empty-state-desc {
        font-size: 11px;
        line-height: 1.35;
      }

      .panel-body {
        padding: 12px 10px;
      }
      .actions-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
      }
      .actions-grid .btn {
        height: 38px;
        padding: 0 8px;
        font-size: 11.5px;
        gap: 6px;
      }
      .image-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }
