:root {
    --text-font-size: 12;
    --chord-font-size: 12;
    --chord-color: green;
    --text-color: green;
    --column-count: 1;

}

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    background-color: white;
    font-family: sans-serif;
    font-size: 1rem;
    line-height: 1.3rem;
}

header.toolbar {
    padding: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 0.25rem;
    box-shadow: 0 4px 3px grey;
    background-color: #f5f5f5;
}


header label {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
    padding-left: 4px;
}

header label:hover {
    cursor: pointer;
    outline: solid 2px cadetblue;
}

header input[type=color] {
    height: 1.5rem;
    background-color: white;
}

header input[type=number] {
    width: 3rem;
    height: 1rem;
}

header .elastic {
    flex: 1;

}

header .button {
    text-align: right;
}

/* Settings dropdown */
.toolbar-settings {
    position: relative;
}

.settings-toggle {
    font-size: 1.5rem;
    height: 2.5rem;
    min-width: 3rem;
    cursor: pointer;
}

.settings-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 500;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 220px;
    animation: settings-slide-in 0.15s ease-out;
}

.settings-dropdown[hidden] {
    display: none;
}

@keyframes settings-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-dropdown label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.3rem 0.25rem;
    border-radius: 4px;
}

.settings-dropdown label:hover {
    background: #f0f0f0;
    outline: none;
}

.settings-dropdown input[type=number] {
    width: 3.5rem;
    height: 1.5rem;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.settings-dropdown input[type=color] {
    width: 2.5rem;
    height: 1.5rem;
    padding: 0;
    border: solid 1px #ccc;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
}

.settings-dropdown select {
    height: 1.5rem;
    font-size: 0.85rem;
    min-width: 7rem;
    box-sizing: border-box;
}

.settings-dropdown .settings-danger-btn {
    width: 100%;
    height: 1.8rem;
    min-width: unset;
    font-size: 0.8rem;
    border: solid 1px #ccc;
    border-radius: 4px;
    background: transparent;
    color: #888;
    cursor: pointer;
    margin: 0.25rem 0 0 0;
}

.settings-dropdown .settings-danger-btn:hover {
    border-color: #c0392b;
    color: #c0392b;
    background: #fdf0ef;
}

.sync-provider-config {
    height: 1.5rem;
    min-width: 1.5rem;
    font-size: 0.85rem;
    padding: 0;
    border: solid 1px #ccc;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    margin-left: 0;
}

.sync-provider-config:hover {
    border-color: #3b3bc8;
    background: #e8e8f8;
}

.sync-provider-config[hidden] {
    display: none;
}

.button-edit-save {
    position: relative;
}

.dirty-status {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e6a817;
    border: solid 2px white;
    pointer-events: none;
}

.dirty-status[hidden] {
    display: none;
}

.button-edit-gdownload {
    position: relative;
}

.gdrive-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    border: solid 2px white;
    pointer-events: none;
}

.gdrive-status.connected {
    background: #2ecc40;
}

.gdrive-status.disconnected {
    background: #ccc;
}



header.toolbar button {
    height: 2.5rem;
    min-width: 3rem;
    font-size: 1.5rem;
    margin-left: 1rem;
}


header select {
    height: 1.5rem;
    width: 3rem;
    padding: 3px;
}

header.chord-header {
    display: flex;
    justify-content: space-between;
}

select,
option {
    line-height: 1rem;
}

option.option-plus {
    font-weight: bold;
}

option.option-separator {
    background-color: grey;
    height: 2px;
    font-size: 1px;

}


button.active-read {
    border: solid 1px #3b3bc8;
    background-color: rgb(4, 79, 129);
    color: white;
}


button.active-write {
    border: solid 1px #c8bf3b;
    background-color: #dc8c58;
    color: white;
}

.dragover {
    outline: solid 3px orange;
    background-color: rgb(232, 214, 191);
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
}



.chord-name {
    font-family: monospace;
    border: solid 1px grey;
    border-bottom: none;
    flex: 1;
    padding: 0.3rem 0.5rem;
}

.song-write {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 9cm;
    margin: 0.5rem;
    box-shadow: 4px 5px 3px #c7c7c7;
}

.song-write textarea {
    flex: 1;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: scroll;
    resize: none;
}


.song-render {
    flex: var(--column-count);
    font-family: sans-serif;
    font-size: var(--text-font-size);
    box-sizing: border-box;
    font-weight: bold;
    overflow-y: auto;
    width: 100%;
    position: relative;
    min-width: calc(9.5cm * var(--column-count));
    padding-top: 1rem;
}

.song-meta-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: solid 1px #ccc;
}

.song-meta-title {
    display: block;
    font-size: 1.4em;
    color: var(--text-color);
    line-height: 1.1;
}

.song-meta-author {
    display: block;
    font-size: 0.9em;
    font-weight: normal;
    color: #888;
    font-style: italic;
    line-height: 1.2;
}

.song-render .capo {
    text-align: right;
}

.song-render .capo span {
    border: dotted 1px var(--chord-color);
    padding: 0.5rem;
}

.song-render ins {
    width: 0.9rem;
    display: inline-block;
    text-decoration: none;
}

.song-render p {
    margin: 0 0 0.3rem 0;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 2.5ex;
}

.song-render .song-text {
    padding-top: var(--chord-font-size);
    position: relative;
}

.song-render .song-text>span.chord {
    color: var(--chord-color);
    position: absolute;
    transform: translate(0, calc(var(--chord-font-size) * -1));
    font-size: var(--chord-font-size);
}


.song-render .song-text>span.inline-chord,
.song-render .inline-chord {
    color: var(--chord-color);
    position: unset;

}

.song-render sup {
    vertical-align: text-top;
    line-height: 1ex;
}


.song-render sup.notation {
   /* font-size: inherit;*/
    font-family: auto, sans-serif;
}

.song-render .solo-chord {
    color: var(--chord-color);
    margin-bottom: 0;
    font-size: var(--chord-font-size);

    font-family: monospace;
    line-height: 2ex;
}

.song-render .solo-chord sup {
   /* font-size: inherit; */
}

.song-render .solo-chord.solo-tab {
    font-weight: normal;
}

.song-render .solo-chord.solo-tab .tab-string {
    display: inline-block;
    width: 2rem;
    font-weight: bold;
    text-align: center;
}


.song-render .solo-text {
    color: var(--text-color);
    white-space: normal;
}

.song-render .solo-text.notation-text {
    font-style: italic;
    margin-left: 1rem;
}

.song-render .solo-chord+.song-text {
    margin-top: 0.6rem;
}



.song-render-inside.column {
    column-count: var(--column-count);
    column-fill: balance;
    column-rule: dashed 2px rgb(118, 118, 125);
    width: 100%;
}

.song-render-inside.column .page-break {
    break-after: column;
}

.page-break {
    width: 50%;
    border: dashed 2px sandybrown;
    break-after: page;
}

.page-footer {
    text-align: right;
}

.separator {
    display: flex;
    align-items: center;
    text-align: center;
    font-style: italic;
    font-size: 80%;
    font-weight: normal;
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--text-color);
}

.separator:not(:empty)::before {
    margin-right: .25em;
}

.separator:not(:empty)::after {
    margin-left: .25em;
}

/* ==============
   SONG LIST OVERLAY
================== */

.song-list-toggle {
    font-size: 1.5rem;
    min-width: 3rem;
    height: 2.5rem;
    cursor: pointer;
}

.song-list-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: song-list-fade-in 0.15s ease-out;
}

.song-list-overlay[hidden] {
    display: none;
}

@keyframes song-list-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes song-list-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.song-list-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 420px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: song-list-slide-in 0.2s ease-out;
}

.song-list-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: solid 1px #e0e0e0;
}

.song-list-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.song-list-group-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.song-list-group-filter:empty {
    display: none;
}

.song-list-group-chip {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border: solid 1px #ccc;
    border-radius: 1rem;
    background: white;
    cursor: pointer;
    color: #555;
    white-space: nowrap;
}

.song-list-group-chip:hover {
    border-color: #3b3bc8;
}

.song-list-group-chip.active {
    background: #3b3bc8;
    color: white;
    border-color: #3b3bc8;
}

.song-list-search {
    flex: 1;
    height: 2.2rem;
    font-size: 1rem;
    padding: 0 0.5rem;
    border: solid 1px #ccc;
    border-radius: 4px;
    outline: none;
}

.song-list-search:focus {
    border-color: #3b3bc8;
}

.song-list-close {
    font-size: 1.5rem;
    width: 2.2rem;
    height: 2.2rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: #666;
}

.song-list-close:hover {
    background: #eee;
}

.song-list-items {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.song-list-items li {
    padding: 0.7rem 1rem;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    cursor: pointer;
    border-bottom: solid 1px #f0f0f0;
    box-sizing: border-box;
}

.song-list-items li:hover {
    background: #f5f5f5;
}

.song-list-items li.song-list-current {
    background: #3b3bc8;
    color: white;
}

.song-list-items li.song-list-current:hover {
    background: #2a2aab;
}

.song-list-match {
    background: #fff3b0;
    border-radius: 2px;
}

.song-list-current .song-list-match {
    background: rgba(255, 255, 255, 0.3);
}

.song-list-items li.song-group-header {
    background: #e8e8e8;
    font-weight: bold;
    font-size: 0.85rem;
    color: #555;
    cursor: default;
    padding: 0.4rem 0.75rem;
    min-height: unset;
    gap: 0.4rem;
}

.song-list-items li.song-group-header:hover {
    background: #e8e8e8;
}

.song-list-items li.song-list-dirty .song-list-name::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #e6a817;
    border-radius: 50%;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.song-list-items li.song-list-dirty.song-list-current .song-list-name::after {
    background: #ffd966;
}

.song-list-items li.song-grouped {
    padding-left: 1.5rem;
}

.song-list-name {
    font-weight: 500;
}

.song-list-author {
    font-size: 0.8rem;
    color: #888;
}

.song-list-current .song-list-author {
    color: rgba(255, 255, 255, 0.7);
}

.song-list-items:empty::after {
    content: "No songs found";
    display: block;
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
    font-style: italic;
}

.song-list-footer {
    padding: 0.5rem 0.75rem;
    border-top: solid 1px #e0e0e0;
}

.song-list-new {
    width: 100%;
    height: 2.5rem;
    font-size: 1rem;
    font-weight: bold;
    border: dashed 2px #ccc;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
}

.song-list-new:hover {
    border-color: #3b3bc8;
    color: #3b3bc8;
}

/* ==============
   METADATA DIALOG
================== */

.metadata-btn {
    font-size: 1.5rem;
    min-width: 3rem;
    height: 2.5rem;
    cursor: pointer;
}

.metadata-panel {
    max-width: 400px;
}

.metadata-form {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metadata-form label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
    display: block;
    padding: 0;
    border-radius: 0;
}

.metadata-form label:hover {
    outline: none;
    cursor: default;
}

.metadata-form input[type="text"] {
    width: 100%;
    height: 2.2rem;
    font-size: 1rem;
    padding: 0 0.5rem;
    border: solid 1px #ccc;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
}

.metadata-form input[type="text"]:focus {
    border-color: #3b3bc8;
}

.metadata-cat-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-height: 1.5rem;
}

.metadata-cat-picker:empty::after {
    content: "No categories yet";
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

.metadata-cat-chip {
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
    border: solid 1px #ccc;
    border-radius: 1rem;
    background: white;
    cursor: pointer;
    color: #555;
    transition: all 0.15s;
}

.metadata-cat-chip:hover {
    border-color: #3b3bc8;
    color: #3b3bc8;
}

.metadata-cat-chip.selected {
    background: #3b3bc8;
    color: white;
    border-color: #3b3bc8;
}

.metadata-cat-chip.selected:hover {
    background: #2a2aab;
    border-color: #2a2aab;
}

.metadata-new-cat-row {
    display: flex;
    gap: 0.3rem;
}

.metadata-new-cat-row input {
    flex: 1;
}

.metadata-new-cat-btn {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.3rem;
    font-weight: bold;
    border: solid 1px #ccc;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metadata-new-cat-btn:hover {
    border-color: #3b3bc8;
    color: #3b3bc8;
    background: #e8e8f8;
}

.metadata-save-btn {
    width: 100%;
    height: 2.5rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    background: #3b3bc8;
    color: white;
    cursor: pointer;
    margin-top: 0.5rem;
}

.metadata-save-btn:hover {
    background: #2a2aab;
}

/* ==============
   WEB SEARCH
================== */

.web-search-btn {
    font-size: 1.2rem;
    width: 2.5rem;
    height: 2.2rem;
    border: solid 1px #ccc;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
}

.web-search-btn:hover {
    border-color: #3b3bc8;
    background: #e8e8f8;
}

.web-search-status {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
    border-bottom: solid 1px #e0e0e0;
}

.web-search-status[hidden] {
    display: none;
}

.web-search-status.web-search-loading::before {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #ccc;
    border-top-color: #3b3bc8;
    border-radius: 50%;
    animation: web-search-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

@keyframes web-search-spin {
    to { transform: rotate(360deg); }
}

.web-search-status.web-search-error {
    color: #c0392b;
    background: #fdf0ef;
}

.web-search-result-item {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.2rem;
    transition: background 0.15s;
}

.web-search-result-item.web-search-importing {
    background: #e8e8f8;
    opacity: 0.7;
    pointer-events: none;
}

.web-search-result-title {
    font-weight: bold;
}

.web-search-result-info {
    font-size: 0.8rem;
    color: #888;
    display: flex;
    gap: 0.75rem;
}

.web-search-result-info .web-search-rating {
    color: #e6a817;
}

.web-search-panel .song-list-items:empty::after {
    content: "";
}

.app-footer {
    text-align: center;
    padding: 0.4rem;
    font-size: 0.75rem;
    color: #999;
    background: #f5f5f5;
    border-top: solid 1px #e0e0e0;
}

.app-footer a {
    color: #888;
    text-decoration: none;
}

.app-footer a:hover {
    color: #3b3bc8;
    text-decoration: underline;
}

.ug-credentials-form {
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.ug-credentials-form[hidden] {
    display: none;
}

.ug-credentials-form p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #555;
    text-align: center;
}

.ug-credentials-form input {
    width: 100%;
    max-width: 280px;
    height: 2.2rem;
    font-size: 1rem;
    padding: 0 0.5rem;
    border: solid 1px #ccc;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
}

.ug-credentials-form input:focus {
    border-color: #3b3bc8;
}

.ug-credentials-form button {
    width: 100%;
    max-width: 280px;
    height: 2.5rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    background: #3b3bc8;
    color: white;
    cursor: pointer;
    margin-top: 0.3rem;
}

.ug-credentials-form button:hover {
    background: #2a2aab;
}

.web-search-footer {
    padding: 0.5rem 0.75rem;
    text-align: center;
}

.ug-logout {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border: solid 1px #ccc;
    border-radius: 4px;
    background: transparent;
    color: #888;
    cursor: pointer;
}

.ug-logout:hover {
    border-color: #c0392b;
    color: #c0392b;
}

.ug-logout[hidden] {
    display: none;
}

/* ==============
   SYNC TOAST
================== */

.sync-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: 2000;
    background: #333;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    min-width: 260px;
    max-width: 90vw;
    overflow: hidden;
    animation: sync-toast-in 0.25s ease-out;
}

.sync-toast[hidden] {
    display: none;
}

.sync-toast.sync-toast-success {
    background: #1a7a2e;
}

.sync-toast.sync-toast-error {
    background: #a82020;
}

@keyframes sync-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes sync-toast-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(1rem); }
}

.sync-toast-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
}

.sync-toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sync-toast-icon.spin {
    display: inline-block;
    animation: web-search-spin 0.6s linear infinite;
}

.sync-toast-progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.sync-toast-progress[hidden] {
    display: none;
}

.sync-toast-bar {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 0 8px 8px;
}

/* ==============
   WRITE ONLY MODE
================== */

body.write-only main {
    flex-direction: column;
}


body.write-only .song-render {
    display: none;
}


body.write-only main textarea {
    padding: 0.5rem;
}

body.write-only header > label,
body.write-only header .button-edit-print {
    display: none;
}


/* ==============
   READ ONLY MODE
================== */


body.read-only main {
    flex-direction: column;
}

body.read-only .song-write {
    flex: 0;
}

body.read-only .song-render {
    width: 100%;
    padding: 1rem;
    flex: 1;
}


body.read-only main textarea {
    display: none;
}

body.read-only .button-edit {
    display: none;
}

body.read-only .song-list-footer {
    display: none;
}

body.read-only .song-list-toggle {
    flex: 1;
    text-align: left;
    font-size: 1rem;
    height: auto;
    padding: 0.25rem 0.5rem;
}

body.read-only main .chord-name {
    border-bottom: solid 1px grey;
    pointer-events: none;
    display: none;
}

body.read-only main header select {
    width: 100%;
}

body.read-only main .song-render-inside.column {
    width: auto;
    height: 100%
}

body.read-only main .song-render-inside.column .page-break,
body.read-only main .page-break {
    display: none;
    break-after: unset;
}


/* ==============
   READ WRITE MODE
================== */
body.read-write header .button-edit-only {
    display: none;
}


main .option-fake,
body.read-only main .option-edit {
    display: none;
}

main option:disabled {
    background-color: rgb(9, 123, 180);
    color: white;
}

footer.print-footer {
    display: none;
}



@page {
    margin: 1.5cm;
}


@media print {

    .song-render {
        width: 100%;
    }

    .song-render,
    main {
        overflow: visible;
    }

    .page-break {
        visibility: hidden;
    }

    header,
    header.toolbar,
    .song-write {
        display: none;
    }

    .song-list-overlay,
    .web-search-overlay,
    #web-search-overlay,
    #pcloud-settings-overlay,
    #metadata-overlay,
    .song-list-toggle,
    .metadata-btn,
    .sync-toast,
    .app-footer {
        display: none !important;
    }


    .song-render-inside {
        width: unset;
        border: none;
    }

    .song-render-inside.column {
        column-count: var(--column-count);
        column-rule: solid 1px rgb(118, 118, 125);
        border: none;
        max-width: 100vw;
        /*width: calc( 100% / var(--column-count));*/
    }


    .song-render {
        width: auto;
        min-width: unset;
        padding-top: 0;
        border-right: none;
    }

    .song-render p.page-footer {
        position: fixed;
        bottom: -0.6rem;
        right: 1rem;
        font-size: 80%;
        color: grey;
        font-weight: normal;
    }
}