
  :root{
    --chord: #0000ff;
    --chord-new: #dc3545;
    --ink: #000000;
    --muted: #9a9a9a;
    --line: #e3e3e3;
    --bg: #ffffff;
    --panel: #17181b;
    --accent: #2457c9;
    --break: #e74c3c;
  }
  *{box-sizing:border-box; -webkit-tap-highlight-color: transparent;}
  html,body{margin:0;padding:0;background:var(--bg);}
  body{
    font-family:"Kanit",Arial,sans-serif;
    background-color:#f8f9fa;
    color:var(--ink);
    -webkit-font-smoothing:antialiased;
  }
  #app{
    max-width:1400px;
    margin:0 auto;
    padding:24px 24px 120px;
    background:#ffffff;
    border-radius:12px;
    box-shadow:0 4px 20px rgba(0,0,0,0.06);
  }

  .app-header{text-align:center;margin-bottom:12px;}
  .back-btn{
    display:inline-flex;
    align-items:center;
    gap:6px;
    color:#495057;
    text-decoration:none;
    font-size:13.5px;
    font-weight:600;
    padding:6px 14px;
    background:#f1f3f5;
    border-radius:20px;
    transition:background .2s, color .2s;
  }
  .back-btn:hover{
    background:#e9ecef;
    color:#111;
  }
  .song-meta-card{
    background:#f8f9fa;
    border:1px solid #e9ecef;
    border-radius:12px;
    padding:14px 18px;
    margin-bottom:12px;
    text-align:center;
    box-shadow:0 2px 8px rgba(0,0,0,0.03);
  }
  .song-title-display{
    font-size:20px !important;
    font-weight:700 !important;
    color:#1f4e78 !important;
    margin:0 0 6px 0 !important;
  }
  .song-artist-display{
    font-size:14px;
    color:#495057;
  }
  .song-artist-display strong{
    color:#5a5a5a;
    font-weight:700;
  }
  .instruction-text{
    font-size:12px !important;
    color:var(--muted) !important;
    margin:0 0 10px 0 !important;
    line-height:1.5 !important;
  }

  .save-btn{
    border:none;
    background:var(--accent);
    color:#fff;
    font-size:13px;
    font-weight:700;
    font-family:inherit;
    padding:8px 20px;
    border-radius:20px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    gap:6px;
    transition: background .2s, opacity .2s;
  }
  .save-btn:active{opacity:.85;}
  .save-btn:disabled{
    background:#cbd5e1;
    color:#64748b;
    cursor:not-allowed;
    opacity:.85;
  }

  .logout-btn{
    border:1px solid #ced4da;
    background:#ffffff;
    color:#495057;
    font-size:13px;
    font-weight:600;
    font-family:inherit;
    padding:7px 16px;
    border-radius:20px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    gap:6px;
    transition: background .2s, color .2s, border-color .2s;
  }
  .logout-btn:hover{
    background:#f8f9fa;
    color:#212529;
    border-color:#adb5bd;
  }
  .logout-btn:active{opacity:.85;}


  .content-area,
  .single-entry-content,
  #song{width:100%;}
  .single-entry-content-cord{
    display:flex;
    flex-wrap:wrap;
    font-family:Arial, sans-serif;
    user-select:none;
    justify-content:center;
    width:100%;
  }
  #song{margin-top:16px;}

  /* Multi-Column Grid Layout */
  .preview-chord-1 {
    width: 100%;
    font-family: Arial, sans-serif;
    column-count: 4;
    -webkit-column-count: 4;
    column-gap: 28px;
    -webkit-column-gap: 28px;
    column-fill: balance;
    -webkit-column-fill: balance;
    height: auto;
    margin: 0 auto;
    max-width: 100%;
    overflow: visible;
  }

  .preview-chord-1.text-center {
    text-align: center;
  }

  .cv-th,
  .lyric-line,
  .chordline-block,
  blockquote,
  .hr-block,
  hr {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
  }

  .hr-block, hr {
    margin: 15px;
    background-color: transparent;
    box-sizing: border-box;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 5px;
    width: 100%;
  }

  /* INTRO / INSTRU Section Blockquote & Chordline */
  blockquote,
  .chordline-block {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: #907166;
    background-color: #fcfdf3;
    margin: 10px 0 !important;
    padding: 10px 20px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: block;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    text-align: center;
    line-height: 2.2;
    min-height: 2.5em;
    border: none !important;
    box-shadow: none !important;
    letter-spacing: .2px;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    border-radius: 8px;
  }
  blockquote p,
  .chordline-block p,
  .cv-th {
    font-family: Arial, sans-serif;
    line-height: 2.2;
    margin-bottom: 0;
    margin-top: 0;
    padding-top: 0;
    color: inherit;
  }
  blockquote span,
  blockquote .c,
  blockquote .c_chord,
  .chordline-block span,
  .chordline-block .c {
    top: 0px;
    color: #607d8b;
    word-wrap: normal;
    position: relative;
    font-weight: bold;
    display: inline-block;
  }
  blockquote .c.c-new,
  .chordline-block .c.c-new {
    color: var(--chord-new);
  }
  .chordline-block.pressed{background:rgba(36,87,201,.08);}
  .chordline-block.editing{
    background:#fbfbfb;
    box-shadow:0 0 0 2px var(--accent) inset;
    user-select:text;
    -webkit-user-select:text;
  }

  .lyric-line{
    position:relative;
    text-align:center;
    margin:0;
    user-select:none;
    -webkit-user-select:none;
  }
  .line-inner {
    display: flex;
    width: 100%;
    align-items: flex-end;
    justify-content: center;
    max-width: 100%;
    overflow-x: visible;
    overflow-y: visible;
    padding-top: 28px;
    padding-right: 6px;
    scrollbar-width: none;
    position: relative;
  }
  .line-inner::before { content: ""; flex: 1; min-width: 0; }
  .line-inner::-webkit-scrollbar{display:none;}

  .text-wrap { flex: 0 0 auto; position: relative; white-space: nowrap; }
  .chords-layer{position:absolute; left:0; top:0; right:0; height:0; pointer-events:none;}
  .chord-chip{
    position:absolute;
    transform:translateX(-100%);
    margin-left:-1px;
    text-align:center;
    color:var(--chord);
    font-family:Arial, sans-serif;
    font-weight:bold;
    font-size:13pt;
    line-height:1;
    padding:3px 2px;
    border-radius:6px;
    cursor:pointer;
    pointer-events:auto;
    touch-action:pan-y;
    white-space:nowrap;
  }
  .chord-chip::after{
    content:"";
    position:absolute;
    top:-6px;
    bottom:-6px;
    left:50%;
    transform:translateX(-50%);
    min-width:25px;
    width:100%;
  }
  .chord-chip.chord-selected{
    z-index:15;
    cursor:grab;
    touch-action:none;
  }
  .chord-chip.chord-selected::before,
  .stub .chord-chip-inline.chord-selected::before{
    content:"";
    position:absolute;
    top:-3px;
    bottom:-3px;
    left:50%;
    transform:translateX(-50%);
    min-width:25px;
    width:calc(100% + 8px);
    background:rgba(36,87,201,.14);
    border:1.5px solid var(--accent);
    border-radius:8px;
    pointer-events:none;
    z-index:-1;
  }
  .chord-chip.chord-selected::after,
  .stub .chord-chip-inline.chord-selected::after{
    content:"";
    position:absolute;
    inset:-10px;
    left:-10px;
    transform:none;
    width:auto;
  }
  .chord-chip.dragging{
    background:rgba(36,87,201,.12);
    cursor:grabbing;
    z-index:20;
  }
  .chord-chip.chord-chip-active{
    background:transparent;
  }
  .chord-chip.chord-chip-new{
    color:var(--chord-new);
  }
  .chord-chip.chord-chip-new.dragging{
    background:rgba(220,53,69,.12);
  }
  .chord-chip.chord-chip-new.chord-selected::before{
    background:rgba(220,53,69,.12);
    border-color:var(--chord-new);
  }
  .chord-chip.chord-chip-ghost{
    color:var(--muted);
    background:transparent;
    border:1.3px dashed #b9b9b9;
    padding:1px 5px;
    cursor:pointer;
    font-weight:600;
  }
  /* Line break chip */
  .chord-chip.chord-chip-break{
    transform:translateX(-50%);
    color:var(--break);
    font-size:18px;
    padding:0 4px;
    cursor:grab;
  }
  .chord-chip.chord-chip-break.dragging{
    background:rgba(231,76,60,.15);
    cursor:grabbing;
    z-index:20;
  }
  .chord-chip.chord-chip-break.chord-chip-active{
    background:rgba(231,76,60,.10);
  }
  .chord-chip-inline.chord-chip-break{
    color:var(--break);
    font-size:18px;
    padding:0 4px;
    cursor:grab;
  }
  .chip-slot.dragging .chord-chip-inline.chord-chip-break{
    background:rgba(231,76,60,.15);
  }
  .chip-slot .chord-chip-inline.chord-chip-break.chord-chip-active{
    background:rgba(231,76,60,.10);
  }

  .line-inner.has-stack{padding-top:44px;}

  .text-layer{
    font-family:Arial, sans-serif;
    font-size:13pt;
    line-height:2.2;
    white-space:pre;
    color:#000000;
    outline:none;
    padding:1px 2px;
    border-radius:5px;
    cursor:pointer;
  }
  .text-layer.editing{
    background:#fbfbfb;
    box-shadow:0 0 0 2px var(--accent) inset;
  }
  .text-layer.pressed{background:rgba(36,87,201,.08);}

  .edit-type-legend{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:6px 10px;
    margin:0 0 12px;
    font-size:12px;
  }
  .edit-type-key{
    display:inline-flex;
    align-items:center;
    gap:4px;
    border:1px solid currentColor;
    border-radius:999px;
    padding:3px 7px;
    font-weight:600;
  }
  .edit-type-dot{
    width:7px;
    height:7px;
    border-radius:50%;
    background:currentColor;
  }
  .edit-type-chord,.chord-chip.edit-chord,.chord-chip-inline.edit-chord{color:#dc3545;}
  .edit-type-move,.chord-chip.edit-move,.chord-chip-inline.edit-move{color:#dc3545;}
  .edit-type-lyrics{color:#dc3545;}
  .edit-type-spacing,.chord-chip.edit-spacing,.chord-chip-inline.edit-spacing{color:#c56a00;}
  .edit-type-delete,.chord-chip.edit-delete,.chord-chip-inline.edit-delete{color:#dc3545;}
  .chord-chip.edit-chord,.chord-chip-inline.edit-chord,
  .chord-chip.edit-move,.chord-chip-inline.edit-move{
    background:transparent;
    border:none;
  }
  .chord-chip.edit-spacing,.chord-chip-inline.edit-spacing{
    background:#fff0d6;
    border:1px solid #f08c00;
  }
  .chord-chip.edit-delete,.chord-chip-inline.edit-delete{
    background:transparent;
    border:none;
    text-decoration:line-through;
  }
  .chord-chip.chord-chip-ghost.edit-delete,
  .stub .chord-chip-inline.chord-chip-ghost.edit-delete{
    color:var(--muted);
    background:transparent;
    border:1.3px dashed #b9b9b9;
    text-decoration:line-through;
  }
  .text-layer.edit-lyrics{
    color:#dc3545;
    background:transparent;
    box-shadow:none;
  }
  .chord-chip.edit-chord.chord-selected::before,
  .chord-chip.edit-move.chord-selected::before,
  .stub .chord-chip-inline.edit-chord.chord-selected::before,
  .stub .chord-chip-inline.edit-move.chord-selected::before{
    background:rgba(220,53,69,.12);
    border-color:var(--chord-new);
  }
  blockquote.chordline-block.edit-chordline,
  blockquote.chordline-block.edit-chordline p,
  blockquote.chordline-block.edit-chordline span,
  blockquote.chordline-block.edit-chordline .c,
  blockquote.chordline-block.edit-chordline .c_chord{
    color:var(--chord-new);
  }
  .lyric-ghost,
  blockquote.chordline-block .chordline-ghost,
  blockquote.chordline-block.edit-chordline .chordline-ghost,
  blockquote.chordline-block.edit-chordline .chordline-ghost span,
  blockquote.chordline-block.edit-chordline .chordline-ghost .c,
  blockquote.chordline-block.edit-chordline .chordline-ghost .c_chord{
    color:var(--muted);
    opacity:.72;
    text-decoration:line-through;
    font-size:.9em;
    line-height:1.5;
    user-select:none;
    -webkit-user-select:none;
    pointer-events:none;
  }
  .lyric-ghost{
    text-align:center;
    font-family:Arial, sans-serif;
    margin-top:2px;
    margin-bottom:4px;
    white-space:pre-wrap;
  }
  blockquote.chordline-block .chordline-ghost{
    margin-top:4px;
  }

  .extra-row {
    flex: 1;
    min-width: max-content;
    align-self: stretch;
    height: auto;
    display: inline-flex;
    align-items: flex-end;
    margin-left: 5px;
    gap: 12px;
    white-space: nowrap;
  }
  .stub.chip-slot,
  .stub {
    position: relative;
    min-width: 32px;
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    touch-action: pan-y;
    padding: 0 4px;
  }
  .stub .chord-chip-inline {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 25px;
    text-align: center;
    color: var(--chord);
    font-family: Arial, sans-serif;
    font-weight: 700;
    font-size: 13pt;
    line-height: 1;
    cursor: pointer;
    padding: 3px 2px;
    border-radius: 6px;
    white-space: nowrap;
    touch-action: pan-y;
  }
  .stub .chord-chip-inline.chord-selected {
    z-index: 15;
    cursor: grab;
    touch-action: none;
  }
  .stub .chord-chip-inline.chord-chip-new {
    color: var(--chord-new);
  }
  .stub .stub-text {
    color: transparent;
    font-family: Arial, sans-serif;
    font-size: 13pt;
    line-height: 2.2;
    user-select: none;
  }
  .stub.dragging .chord-chip-inline {
    background: rgba(36,87,201,.12);
    cursor: grabbing;
    z-index: 20;
  }
  .stub.dragging .chord-chip-inline.chord-chip-new {
    background: rgba(220,53,69,.12);
  }
  .stub .chord-chip-inline.chord-chip-active {
    top: -20px;
    background: transparent;
  }
  .stub .chord-chip-inline.chord-chip-active.chord-chip-new {
    background: rgba(220,53,69,.12);
    border-color: var(--chord-new);
  }
  .stub .chord-chip-inline.chord-chip-new.chord-selected::before {
    background: rgba(220,53,69,.12);
    border-color: var(--chord-new);
  }
  .stub .chord-chip-inline.chord-chip-ghost {
    top: -38px;
    color: var(--muted);
    background: transparent;
    border: 1.3px dashed #b9b9b9;
    padding: 1px 4px;
    cursor: pointer;
    font-weight: 600;
  }

  .add-end-btn {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: -20px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.4px dashed #c7c7c7;
    background: transparent;
    color: #b7b7b7;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
  }
  .add-end-btn:hover{border-color:var(--accent); color:var(--accent);}

  /* iOS style callout popup */
  .popup-menu{
    position:fixed;
    z-index:1000;
    background:rgba(28,28,30,.94);
    border-radius:11px;
    display:flex;
    box-shadow:0 6px 20px rgba(0,0,0,.25);
    transform:translate(-50%,-100%);
    margin-top:-12px;
    overflow:hidden;
    animation:pop-in .12s ease-out;
  }
  @keyframes pop-in{ from{opacity:0; transform:translate(-50%,-95%) scale(.92);} to{opacity:1; transform:translate(-50%,-100%) scale(1);} }
  .popup-menu button{
    appearance:none;border:none;background:transparent;
    color:#fff;font-size:14.5px;font-family:inherit;
    padding:10px 16px;
    cursor:pointer;
    white-space:nowrap;
  }
  .popup-menu button + button{border-left:1px solid rgba(255,255,255,.18);}
  .popup-menu button:active{background:rgba(255,255,255,.15);}
  .popup-arrow{
    position:fixed; z-index:1000;
    width:0;height:0;
    border-left:7px solid transparent;
    border-right:7px solid transparent;
    border-top:7px solid rgba(28,28,30,.94);
    transform:translate(-50%,0);
  }

  .float-input{
    position:fixed;
    z-index:1000;
    transform:translate(-50%,-100%);
    margin-top:-8px;
    background:#fff;
    border:1.5px solid var(--accent);
    border-radius:8px;
    box-shadow:0 6px 18px rgba(0,0,0,.18);
    padding:3px;
  }
  .float-input input{
    width:64px;
    border:none;outline:none;
    text-align:center;
    font-size:14px;
    font-weight:700;
    color:var(--chord);
    font-family:inherit;
  }

  .overlay-click-catcher{
    position:fixed; inset:0; z-index:900;
  }

  .hint-toast{
    position:fixed; left:50%; bottom:18px; transform:translateX(-50%);
    background:rgba(28,28,30,.92); color:#fff; font-size:12.5px;
    padding:8px 14px; border-radius:20px; z-index:1100;
    opacity:0; transition:opacity .25s; pointer-events:none;
  }
  .hint-toast.show{opacity:1;}

  /* ---------------------------------------------------------
     RESPONSIVE MEDIA QUERIES (PC, iPad, Mobile)
  --------------------------------------------------------- */

  /* Wide Desktop (>= 1600px) */
  @media (min-width: 1600px) {
    .preview-chord-1 {
      column-count: 4;
      -webkit-column-count: 4;
    }
  }

  /* Standard Desktop (1200px - 1599px) */
  @media (max-width: 1599px) and (min-width: 1200px) {
    .preview-chord-1 {
      column-count: 3;
      -webkit-column-count: 3;
    }
  }

  /* iPad / Tablet & Compact Desktop (768px - 1199px) */
  @media (max-width: 1199px) and (min-width: 768px) {
    #app {
      margin: 0 auto;
      padding: 20px 18px 100px;
      border-radius: 12px;
    }
    .preview-chord-1 {
      column-count: 2;
      -webkit-column-count: 2;
    }
    .song-title-display {
      font-size: 18px !important;
    }
    .song-artist-display {
      font-size: 13.5px;
    }
    .text-layer,
    .chord-chip,
    .stub .chord-chip-inline,
    .stub .stub-text {
      font-size: 12pt;
    }
  }

  /* Mobile (<= 767px) */
  @media (max-width: 767px) {
    #app {
      margin: 0 auto;
      padding: 16px 12px 80px;
      border-radius: 10px;
      box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    }
    .preview-chord-1 {
      column-count: 1;
      -webkit-column-count: 1;
      max-width: 600px;
      margin: 0 auto;
    }
    .app-header {
      margin-bottom: 10px;
    }
    .header-bar {
      flex-wrap: wrap;
      gap: 10px;
      justify-content: space-between;
    }
    .song-meta-card {
      padding: 12px 14px;
      margin-bottom: 10px;
    }
    .song-title-display {
      font-size: 17px !important;
    }
    .instruction-text {
      font-size: 11.5px !important;
      line-height: 1.4 !important;
      margin-bottom: 8px !important;
    }
    .text-layer,
    .chord-chip,
    .stub .chord-chip-inline,
    .stub .stub-text {
      font-size: 11pt;
    }
    blockquote,
    .chordline-block {
      font-size: 12px;
      padding: 8px 14px;
      margin: 8px 0 !important;
    }
    .edit-type-legend {
      gap: 5px 8px;
      margin-bottom: 10px;
      font-size: 11.5px;
    }
    .edit-type-key {
      padding: 2px 6px;
    }
  }

  /* Mobile Small (<= 480px) */
  @media (max-width: 480px) {
    #app {
      margin: 0 auto;
      padding: 14px 10px 70px;
      border-radius: 8px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }

    .back-btn,
    .logout-btn,
    .save-btn {
      font-size: 12.5px;
      padding: 5px 12px;
    }
    .song-meta-card {
      padding: 10px 10px;
    }
    .song-title-display {
      font-size: 16px !important;
    }
    .song-artist-display {
      font-size: 12.5px;
    }
    .instruction-text {
      font-size: 11px !important;
    }
    .text-layer,
    .chord-chip,
    .stub .chord-chip-inline,
    .stub .stub-text {
      font-size: 10.5pt;
    }
    blockquote,
    .chordline-block {
      font-size: 11.5px;
      padding: 6px 10px;
    }
    .hint-toast {
      max-width: 90vw;
      font-size: 12px;
      padding: 7px 12px;
    }
  }

  /* User Note & Submit Card */
  .user-note-card {
    max-width: 680px;
    margin: 24px auto 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 16px 20px;
  }
  .user-note-label {
    font-size: 14.5px;
    color: #343a40;
    margin-bottom: 8px;
  }
  .user-note-textarea {
    font-size: 14px;
    border-radius: 8px;
    resize: vertical;
  }
  .save-btn-submit {
    padding: 10px 28px;
    font-size: 15px;
    border-radius: 24px;
  }

  /* Success Confirmation View Styling */
  .success-card-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 20px 10px;
    animation: fadeInSuccess 0.35s ease-out;
  }

  .success-card {
    background: #ffffff;
    max-width: 500px;
    width: 100%;
    padding: 2.5rem 2rem;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  }

  .success-icon-wrapper {
    width: 72px;
    height: 72px;
    background: #ecfdf5;
    color: #10b981;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    box-shadow: 0 0 0 8px #f0fdf4;
  }

  .ticket-summary-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.25rem;
  }

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


