body { background: #0a0a0a; color: #ddd; font-family: 'Segoe UI', sans-serif; display: flex; flex-direction: column; align-items: center; min-height: 100vh; margin: 0; padding: 40px; box-sizing: border-box; position: relative; overflow-x: hidden; }
.app-background { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: #050505; pointer-events: none; }
.app-background-video { width: 100%; height: 100%; object-fit: cover; object-position: center center; transform: translateZ(0); backface-visibility: hidden; }
.app-background-youtube { position: absolute; top: 50%; left: 50%; width: max(177.78vh, 100vw); height: max(56.25vw, 100vh); min-width: 100vw; min-height: 100vh; transform: translate(-50%, -50%); border: 0; pointer-events: none; display: none; }
.app-background-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.3); }
.app-shell { position: relative; z-index: 1; width: 100%; display: flex; flex-direction: column; align-items: center; }
#main-form { width: 100%; max-width: 880px; display: flex; flex-direction: column; align-items: center; }
.box { width: 100%; background: #151515; padding: 40px; border-radius: 20px; border: 1px solid #333; box-shadow: 0 20px 40px rgba(0,0,0,0.5); box-sizing: border-box; }
h1 { color: #00cc88; margin: 0 0 10px; font-weight: 800; }
input, button, textarea { width: 100%; border-radius: 10px; margin-bottom: 20px; outline: none; box-sizing: border-box; }
input[type="file"] { background: #222; border: 1px solid #444; color: #888; padding: 15px; }
.flex-container { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
.flex-container > div { flex: 1; min-width: 120px; }
label { font-size: 12px; color: #777; margin-bottom: 5px; display: block; text-transform: uppercase; }

input[type="number"], select { background: #222; border: 1px solid #444; color: #fff; padding: 15px; width: 100%; border-radius: 10px; outline: none; box-sizing: border-box; margin-bottom: 20px; cursor: pointer; }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; margin-top: 10px;}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: #00ff88; cursor: pointer; margin-top: -6px; box-shadow: 0 0 10px rgba(0,255,136,0.5);}
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: #444; border-radius: 2px; }
input[type=range]:focus { outline: none; }

button { background: #00cc88; border: none; color: #fff; padding: 18px; font-weight: bold; cursor: pointer; transition: 0.2s; }
button:hover { background: #00ff88; }

.checkbox-wrapper { display: flex; align-items: center; gap: 8px; background: #1a1a1e; border: 1px solid #333; padding: 15px; border-radius: 10px; height: 100%; box-sizing: border-box; justify-content: center;}
.checkbox-wrapper input { width: auto; margin: 0; cursor: pointer; }
.checkbox-wrapper label { margin: 0; cursor: pointer; color: #00ff88; font-weight: bold; }

.sheet-container { width: 100%; margin-top: 30px; background: #111; padding: 20px; border-radius: 12px; border: 1px solid #222; box-sizing: border-box; }
.sheet-header { display: flex; justify-content: space-between; margin-bottom: 15px; font-weight: bold; align-items: center; position: relative; }
.remove-track-btn { position: absolute; top: -10px; right: -10px; width: 24px; height: 24px; background: #ff4747; color: #fff; border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); z-index: 10; transition: transform 0.2s; }
.remove-track-btn:hover { transform: scale(1.1); background: #ff6666; }
.centered-row { display: flex; align-items: center; gap: 10px; }
.view-wrapper { position: relative; width: 100%; height: 250px; resize: vertical; overflow: hidden; border: 1px solid #222; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
textarea { width: 100%; height: 100%; background: #000; color: #00ff88; border: none; padding: 20px; font-family: monospace; font-size: 14px; resize: none; display: block; box-sizing: border-box; margin: 0; outline: none; }
.copy-btn { background: #0066ff; color: #fff; margin: 0; padding: 12px; border-radius: 8px; cursor: pointer; min-height: 46px; }
.preview-btn { background: #ffaa00; color: #fff; margin: 0; padding: 12px; border-radius: 8px; cursor: pointer; transition: 0.2s; min-height: 46px; }
.echo-btn { margin: 0; padding: 12px; border-radius: 8px; cursor: pointer; transition: 0.2s; min-height: 46px; }
.mute-btn { margin: 0; padding: 12px; border-radius: 8px; cursor: pointer; transition: 0.2s; min-height: 46px; }
.track-card-toolbar { display: flex; gap: 20px; margin-bottom: 15px; align-items: center; background: #1a1a1e; padding: 10px 15px; border-radius: 8px; border: 1px solid #333; flex-wrap: wrap; justify-content: space-between; }
.track-card-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; min-height: 34px; }
.track-card-toolbar .custom-combo { align-self: center; margin: 0; }
.track-card-toolbar .custom-combo-display { min-height: 34px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.track-inline-field { display: inline-flex; align-items: center; gap: 10px; min-height: 34px; }
.track-inline-label { margin: 0; font-size: 12px; font-weight: bold; line-height: 1; }
.track-inline-input { margin: 0; padding: 6px 8px; width: 64px; height: 34px; background: #111; border: 1px solid #444; color: #fff; border-radius: 6px; text-align: center; font-weight: bold; font-size: 13px; }
.track-inline-check { color: #cc00ff; font-weight: bold; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; min-height: 34px; line-height: 1; }
.track-inline-btn { width: auto; margin: 0; padding: 0 14px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 12px; letter-spacing: 0.6px; font-weight: bold; line-height: 1; }
.track-split-btn { background: #22190f; color: #ffaa00; border: 1px dashed #ffaa00; }
.track-split-btn:hover { background: #362413; }
.track-stats-row { display: flex; gap: 20px; align-items: center; justify-content: center; background: #1a1a1e; padding: 12px; border: 1px solid #333; border-top: none; border-radius: 0 0 8px 8px; font-size: 14px; font-weight: bold; letter-spacing: 1px; flex-wrap: wrap; }
.track-minpoly-control { display: inline-flex; align-items: center; gap: 8px; color: #ffaa00; line-height: 1; }
.track-minpoly-input { margin: 0; width: 52px; height: 34px; padding: 4px 6px; background: #111; border: 1px solid #444; color: #ffaa00; border-radius: 6px; text-align: center; font-weight: bold; font-size: 13px; line-height: 1; }
.track-bottom-actions { display: flex; gap: 10px; margin-top: 10px; align-items: stretch; }
.card-optimize-btn { background: #241a29; color: #fff; border: 1px solid #6d2d86; margin: 0; padding: 12px; border-radius: 8px; cursor: pointer; transition: 0.2s; flex: 0.9; min-height: 46px; font-weight: bold; }
.card-optimize-btn:hover { background: #3a2147; }
.editable-card-label { cursor: pointer; display: inline-block; }
.editable-card-label:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.card-label-edit-input { min-width: 180px; background: #111; border: 1px solid #444; color: #fff; border-radius: 6px; padding: 6px 8px; font: inherit; font-weight: inherit; letter-spacing: inherit; }
.action-buttons { display: flex; gap: 10px; margin-top: 20px; }
.action-buttons button { width: auto; flex: 1; margin-bottom: 0; }
#midi_controls {
    position: relative;
    z-index: 900;
    margin-top: 12px;
    background: rgba(10, 10, 10, 0.94);
    backdrop-filter: blur(3px);
    border: 1px solid #2b2b2b;
    border-radius: 12px;
    padding: 12px;
}
.midi-controls-fixed {
    position: fixed !important;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(880px, calc(100vw - 80px));
    margin-top: 0 !important;
    z-index: 1200 !important;
}
#midi-settings-row { margin-bottom: 10px; }

#tracks-container { width: 100%; }
#export-panel { width: 100%; box-sizing: border-box; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.export-column { background: #111; border: 1px solid #2e2e2e; border-radius: 8px; padding: 12px; }
#transport-wrapper { display: none; width: 100%; margin-top: 25px; box-sizing: border-box; }
#transport-container { width: 100%; height: 18px; background: #1a1a1e; border-radius: 9px; cursor: pointer; overflow: hidden; position: relative; border: 1px solid #444; }
#playhead { width: 0%; height: 100%; background: #00ff88; position: absolute; top: 0; left: 0; pointer-events: none;}
#time-display { color: #888; font-size: 14px; text-align: center; margin-top: 8px; font-family: monospace; letter-spacing: 1px;}

.custom-combo { position: relative; width: 100%; margin-bottom: 0; background: #1a1a1e; border: 1px solid #333; border-top: none; border-radius: 0 0 8px 8px; color: #fff; }
.custom-combo-display { padding: 12px; cursor: pointer; text-align: center; font-weight: bold; letter-spacing: 1px; user-select: none; }
.custom-combo-display:hover { background: #222; }
.custom-combo-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #1a1a1e; border: 1px solid #444; z-index: 100; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.8); max-height: 300px; overflow: hidden; flex-direction: column; }
.custom-combo-search { width: 100%; padding: 12px; background: #111; border: none; border-bottom: 1px solid #444; color: #00ff88; font-weight: bold; outline: none; box-sizing: border-box; }
.custom-combo-list { overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.custom-combo-list li { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #333; transition: 0.1s; }
.custom-combo-list li:hover { background: #00cc88; color: #000; }

.stats-banner {
    position: static;
    transform: none;
    background: #00cc88;
    color: #111;
    padding: 8px 25px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(0,204,136,0.3);
    z-index: auto;
    margin: 0 auto 14px;
    letter-spacing: 0.5px;
}
.stats-banner b {
    font-weight: 900;
    font-size: 16px;
}

.tab-bar { display: flex; gap: 0; margin-bottom: 0; }
.tab-btn {
    flex: 1; padding: 12px 20px; text-align: center; font-weight: bold; font-size: 13px;
    letter-spacing: 1px; cursor: pointer; border: 1px solid #333; border-bottom: none;
    background: #111; color: #555; transition: background 0.2s, color 0.2s;
    border-radius: 8px 8px 0 0; margin-bottom: 0; user-select: none;
}
.tab-btn:hover { background: #1a1a1e; color: #888; }
.tab-btn.active { background: #1a1a1e; color: #00ff88; border-color: #444; }
.tab-panel {
    display: none; background: #1a1a1e; border: 1px solid #444; border-top: none;
    padding: 20px; border-radius: 0 0 8px 8px; margin-bottom: 20px;
}
.tab-panel.active { display: block; }

.app-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.app-title-row h1 { margin: 0; }
.top-auth-bar { display: flex; justify-content: flex-end; flex: 0 0 auto; margin-bottom: 0; margin-left: auto; position: relative; }
.top-auth-btn { min-width: 96px; min-height: 34px; height: 34px; padding: 0 12px; background: #1f5eff; color: #fff; border-radius: 999px; font-size: 12px; letter-spacing: 0.6px; }
.top-auth-btn.is-logged-in { background: #444; }
.top-auth-btn.user-icon-btn { min-width: 38px; width: 38px; padding: 0; font-size: 18px; border-radius: 999px; }
.top-auth-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 140px; background: rgba(20,20,24,0.98); border: 1px solid #34343c; border-radius: 12px; box-shadow: 0 18px 40px rgba(0,0,0,0.45); padding: 6px; z-index: 13000; }
.top-auth-menu-item { width: 100%; display: block; text-align: left; background: transparent; color: #e8e8ee; border: none; border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.top-auth-menu-item:hover { background: #2a2a31; }
.shared-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-top: 18px; }
.shared-panel-card { background: rgba(17, 17, 20, 0.92); border: 1px solid #2b2b33; border-radius: 12px; padding: 18px; box-sizing: border-box; }
.shared-panel-title { margin: 0 0 12px 0; color: #d8d8de; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.shared-muted { color: #9a9aa3; font-size: 13px; line-height: 1.5; }
.shared-login-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.shared-login-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border-radius: 8px; text-decoration: none; font-weight: bold; background: #1f5eff; color: #fff; border: none; cursor: pointer; }
.shared-auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.shared-auth-box { background: #121217; border: 1px solid #2b2b33; border-radius: 10px; padding: 12px; }
.shared-auth-stack { display: flex; flex-direction: column; gap: 10px; }
.shared-login-local-btn { background: #00aa66; }
.shared-logout-btn { background: #444; }
.shared-text-link-btn,
.shared-text-link-btn:focus,
.shared-text-link-btn:active,
.shared-text-link-btn:visited { display: inline-flex; align-items: center; justify-content: flex-start; padding: 0; margin: 0; background: transparent !important; border: none; color: #8fc7ff; font-size: 12px; font-weight: bold; cursor: pointer; text-decoration: none; line-height: 1.2; box-shadow: none; outline: none; appearance: none; -webkit-appearance: none; }
.shared-text-link-btn:hover { color: #ffdd33; }
.shared-link-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.shared-link-row .shared-text-link-btn:last-child { margin-left: auto; }
.shared-link-row-end { justify-content: flex-end; }
.shared-auth-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.78); z-index: 12000; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.shared-auth-modal-dialog { position: relative; width: min(460px, 100%); background: rgba(17, 17, 20, 0.98); border: 1px solid #30303a; border-radius: 16px; box-shadow: 0 30px 100px rgba(0,0,0,0.65); padding: 22px; }
.shared-auth-modal-panel { display: block; }
.shared-auth-modal-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 999px; border: none; background: #272730; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.shared-auth-modal-close:hover { background: #353540; }
.shared-label { display: block; color: #00ff88; font-size: 12px; font-weight: bold; margin: 14px 0 8px; letter-spacing: 0.7px; }
.shared-inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.shared-input { flex: 1; min-width: 170px; background: #111; border: 1px solid #333; color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.shared-action-btn { min-height: 40px; padding: 0 14px; background: #cc00ff; border: none; color: #fff; border-radius: 8px; font-weight: bold; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.shared-help-note { margin-top: 10px; color: #8a8a94; font-size: 12px; line-height: 1.5; }
.shared-song-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; min-height: 48px; }
.shared-scroll-list { max-height: 50vh; overflow-y: auto; padding-right: 4px; }
.shared-song-item { background: #121217; border: 1px solid #2b2b33; border-radius: 10px; padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 76px; }
.shared-song-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shared-song-title { color: #fff; font-weight: bold; }
.shared-song-title.is-editable { cursor: pointer; text-decoration: underline dotted rgba(255,255,255,0.25); text-underline-offset: 3px; background: transparent; border: none; padding: 0; text-align: left; font: inherit; }
.shared-song-title.is-editable:hover { color: #8fc7ff; }
.shared-song-title-edit { width: min(100%, 420px); min-height: 34px; padding: 6px 10px; border-radius: 8px; border: 1px solid #35506a; background: #0f141b; color: #fff; font-size: 14px; font-weight: bold; }
.shared-song-sub { color: #9b9ba5; font-size: 12px; }
.shared-song-meta-line { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
.shared-song-artist.is-editable { cursor: pointer; text-decoration: underline dotted rgba(143,199,255,0.28); text-underline-offset: 3px; background: transparent; border: none; padding: 0; text-align: left; font: inherit; color: inherit; }
.shared-song-artist.is-editable:hover { color: #8fc7ff; }
.shared-song-artist-edit { width: min(100%, 320px); min-height: 30px; padding: 5px 9px; border-radius: 8px; border: 1px solid #35506a; background: #0f141b; color: #fff; font-size: 12px; }
.shared-song-link { display: inline; min-height: 0; height: auto; padding: 0; margin: 0; border: none; border-radius: 0; background: transparent; color: #8fc7ff; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; vertical-align: baseline; line-height: inherit; }
.shared-song-link:hover { color: #ffcc00; background: transparent; }
.shared-song-actions { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; justify-content: flex-end; flex: 0 0 auto; }
.shared-song-open { background: #00aa66; }
.shared-song-private { color: #ffb24d; }
.shared-song-locked { background: #555; color: #ccc; cursor: not-allowed; }
.shared-song-detail-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.shared-song-detail-header .shared-action-btn { flex: 0 0 auto; width: 220px; max-width: 100%; height: 46px; min-height: 46px; padding: 0 14px; margin-left: auto; background: #ffaa00; color: #fff; text-align: center; justify-content: center; align-items: center; align-self: flex-start; }
.shared-song-list .shared-action-btn { min-height: 32px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; letter-spacing: 0.6px; }
.shared-song-list .shared-song-open { min-width: 78px; }
.shared-song-list .shared-delete-icon-btn { min-width: 32px; width: 32px; padding: 0; font-size: 14px; }
.shared-detail-panel { margin-top: 18px; }
.shared-track-card { border-color: #32404a; }
.shared-track-card .sheet-header { margin-bottom: 12px; }
.shared-track-card .track-card-toolbar { justify-content: flex-start; }
.shared-readonly-pill { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px; border-radius: 999px; background: #182028; color: #8fc7ff; border: 1px solid #35506a; font-size: 12px; font-weight: bold; letter-spacing: 0.8px; }
.download-auth-locked { background: #666 !important; color: #d9d9d9 !important; cursor: not-allowed !important; opacity: 0.7; }

@media (max-width: 900px) {
    .app-title-row { align-items: flex-start; flex-wrap: wrap; }
    .top-auth-bar { margin-bottom: 0; }
    .midi-controls-fixed {
        width: calc(100vw - 20px);
    }
    .shared-song-item { flex-direction: column; align-items: flex-start; }
    .shared-song-actions { width: 100%; justify-content: flex-start; overflow-x: auto; }
    .shared-song-detail-header { flex-direction: column; align-items: flex-start; }
}
