/* Comment-create panel — dark "glass" language shared with the right panel
   (#infos) and popups (.sharePopup). */
#commentForm {
    /* JS (index-single-res.js, contextmenu handler) puts the top-left corner
       at the click point, clamped so the panel stays inside the viewport. */
    position: absolute;
    /* Grow to fit a resized textarea, but never below a comfortable width
       or beyond the viewport. */
    width: fit-content;
    min-width: 300px;
    max-width: 90vw;
    /* Short viewports (phone in landscape, tiny windows): scroll inside the
       panel rather than pushing the Create button off-screen. */
    max-height: calc(100vh - 16px); /* fallback for pre-dvh browsers */
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    z-index: 1000;

    padding: 18px;
    color: #e8e8ec;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;

    background: rgba(24, 24, 27, 0.82);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

#commentTextarea {
    width: 100%;
    min-width: 100%;
    min-height: 64px;
    max-width: 80vw;
    box-sizing: border-box;
    /* User can drag to enlarge in both directions for longer comments; the
       form panel (fit-content) grows along with the width. */
    resize: both;

    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    color: #f4f4f6;

    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
#commentTextarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}
#commentTextarea:focus-visible {
    outline: none;
    border-color: #e8e8ec;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

/* Phones: a click-anchored floating panel mostly ends up half off-screen,
   so pin it as a full-width sheet at the TOP instead (JS skips the inline
   top/left there). Top, not bottom, so the on-screen keyboard that opens
   for the textarea doesn't cover it. */
@media (max-width: 500px) {
    #commentForm {
        position: fixed;
        top: max(8px, env(safe-area-inset-top));
        left: 8px;
        right: 8px;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: calc(100vh - 16px - env(safe-area-inset-top));
        max-height: calc(100dvh - 16px - env(safe-area-inset-top));
        padding: 14px;
    }
    #commentTextarea {
        max-width: 100%;
        resize: vertical;
    }
}

/* Consistent vertical rhythm for the form's controls. */
#commentFormShow {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Label + control rows (Type / Colour). The label column is fixed-width so
   the two selects line up; each select fills the rest of the row. */
.comment-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.comment-row__label {
    flex: 0 0 56px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

/* Action row — right-aligned: [Close] [Create]. */
.comment-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.comment-actions .standardButton {
    gap: 6px;
}
/* Create is the primary action — light accent fill (dark text + plus icon
   via currentColor) so it reads as the default. */
#okButton {
    color: #1a1a1d;
    font-weight: 600;
    background-color: #e8e8ec;
    border-color: transparent;
}
#okButton:hover {
    background-color: #ffffff;
    border-color: transparent;
}

/* Type / Color pickers — rows of chips drawing the real marker shapes (built
   by sidebar.js from the hidden #commentType / #commentColor selects). Real
   CSS shapes so all options line up on one axis, unlike text glyphs. The Type
   row previews every shape in the chosen colour; the Color row previews the
   chosen shape in every colour. */
.shape-picker {
    display: flex;
    flex: 1 1 auto;
    gap: 6px;
}
.shape-chip {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease;
}
.shape-chip:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.26);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.22);
}
.shape-chip.is-selected {
    color: #fff;
    border-color: #e8e8ec;
    background-color: rgba(255, 255, 255, 0.16);
}

/* Shape glyphs (currentColor) — mirror .square20/.disc20/.triangleUp20/
   .triangleDown20/.task20 from the panorama markers. */
.shape-ic {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
}
/* `--marker-color` is set by sidebar.js from the chosen Color field, so every
   shape previews in the colour the marker will actually be (falls back to the
   chip's text colour before a colour is resolved). */
.shape-ic--square { background: var(--marker-color, currentColor); border-radius: 2px; }
.shape-ic--disc { background: var(--marker-color, currentColor); border-radius: 50%; }
.shape-ic--task { background: var(--marker-color, currentColor); border-radius: 2px; }
/* task = a square with the "completed" tick, so it reads distinctly from the
   plain square (on the panorama both are squares; task can be checked off). */
.shape-ic--task::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 2px;
    width: 3px;
    height: 7px;
    border: solid #1a1a1d;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.shape-ic--triangleUp {
    width: 0;
    height: 0;
    background: none;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 13px solid var(--marker-color, currentColor);
}
.shape-ic--triangleDown {
    width: 0;
    height: 0;
    background: none;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 13px solid var(--marker-color, currentColor);
}

/* File attach — hidden native <input>s, each triggered by a styled label
   button: [Attach files] [Take photo], then the pending-names readout [x] on
   its own line. */
.file-attach {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}
.file-attach__pick {
    display: flex;
    cursor: pointer;
}
/* Camera capture only makes sense where `capture` opens a camera app —
   phones / tablets (coarse primary pointer); desktop browsers just show the
   ordinary file picker, so hide it there. */
.file-attach__pick--camera {
    display: none;
}
@media (pointer: coarse) {
    .file-attach__pick--camera {
        display: flex;
    }
}
.file-attach input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.file-attach__btn {
    gap: 7px;
}
/* Readout + clear button on their own full-width line. `contain:
   inline-size` keeps a long filename from contributing to the panel's
   shrink-to-fit width (it just ellipsises within whatever width the panel
   has); without it one long name widened the whole form. */
.file-attach__info {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    gap: 6px;
    min-width: 0;
    contain: inline-size;
}
.file-attach__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Drops all pending attachments (shown only while there are any). */
.file-attach__clear {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    background: none;
    border: 0;
    border-radius: 6px;
}
.file-attach__clear:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

/* Optional e-mail notification of project members — a toggle button that
   expands into a scrollable checkbox list of member names. */
#commentNotifyToggle {
    gap: 7px;
}
#commentNotifyToggle[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.26);
}
.comment-notify__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    margin-top: 8px;
    padding: 8px 10px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
}
.comment-notify__user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
}
.comment-notify__user input {
    flex: 0 0 auto;
    margin: 0;
    accent-color: #e8e8ec;
}
.comment-notify__user span {
    min-width: 0;
    overflow-wrap: anywhere;
}

#commentForm button {
    font-size: 13px;
}

#commentFormWait {
    color: rgba(255, 255, 255, 0.8);
}

.square20 {
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
}
.disc20 {
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border-radius: 50%;
}
.triangleUp20 {
    width: 0;
    height: 0;
    margin-left: -10px;
    border-left: 10px solid transparent!important;
    border-right: 10px solid transparent!important;
    border-bottom: 20px solid;
    background-color: transparent!important;
}
.triangleDown20 {
    width: 0;
    height: 0;
    margin-top: -20px;
    margin-left: -10px;
    border-left: 10px solid transparent!important;
    border-right: 10px solid transparent!important;
    border-top: 20px solid;
    background-color: transparent!important;
}
.triangleDown20 div {
    top: -23px;
}
.task20 {
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
}

.bg-red { background-color: #f25f5c; border-color: #f25f5c; }
.bg-orange { background-color: #ff5722; border-color: #ff5722; }
.bg-yellow { background-color: #ffe066; border-color: #ffe066; }
.bg-blue { background-color: #247ba0; border-color: #247ba0; }
.bg-green { background-color: #70c1b3; border-color: #70c1b3; }

.comment {
    position: absolute;
    left: 30px;
    top: -3px;
    width: 220px;
    color: #e8e8ec;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 12px;
    background: rgba(24, 24, 27, 0.85);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.comment-text a {
  text-decoration: underline;
}
.comment-text {
    margin-right: 5px;
}

/* Thread window: messages stacked oldest → newest; long threads scroll
   inside the window instead of growing without bound. */
.comment-thread {
    max-height: 40vh;
    overflow-y: auto;
}
.comment-message {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.comment-message:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.comment-author {
    margin-bottom: 2px;
    color: #BBB;
    font-size: 12px;
    font-style: italic;
}

/* Reply controls under the thread — a "+" button that expands into
   input + send on one row, with the notify checkbox below it. */
.comment-reply {
    margin-top: 8px;
}
.comment-reply__row {
    display: flex;
    gap: 6px;
}
.comment-reply:not(.comment-reply--open) .comment-reply__input,
.comment-reply:not(.comment-reply--open) .comment-reply__send,
.comment-reply:not(.comment-reply--open) .comment-reply__notify {
    display: none;
}
.comment-reply__notify {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
}
.comment-reply__notify input {
    margin: 0;
}
.comment-reply__toggle svg {
    transition: transform 0.15s ease;
}
.comment-reply--open .comment-reply__toggle svg {
    transform: rotate(45deg); /* the "+" becomes an "x" (close) */
}
.comment-reply__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12px;
    color: #f4f4f6;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
}
.comment-reply__input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}
.comment-reply__input:focus-visible {
    outline: none;
    border-color: #e8e8ec;
}
.comment-reply__toggle,
.comment-reply__send {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    cursor: pointer;
    color: #e8e8ec;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    transition: background-color 0.15s ease;
}
.comment-reply__toggle:hover,
.comment-reply__send:hover {
    background: rgba(255, 255, 255, 0.2);
}
.comment-reply__send:disabled {
    opacity: 0.5;
    cursor: default;
}
textarea {
    -moz-user-select: text;
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.delete-comment-button {
    display: none;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}
.delete-comment-button:hover {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.7));
}

/* Task "mark complete" tick — shrink the 30px source to icon size. */
.comment img[src$="check-lg.svg"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}
.comment img[src$="check-lg.svg"]:hover {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(112, 230, 130, 0.8));
}

[data-mqtt][data-mqtt-stale="1"] {
    color: orange;
}

/* Traffic-light dot rendered before the value when data-mqtt-red/yellow/green
   ranges are set on the span. Sized in em so it scales with the comment font. */
.mqtt-indicator {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-right: 0.35em;
    border-radius: 50%;
    vertical-align: baseline;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.mqtt-indicator[data-mqtt-indicator="red"] { background-color: #dc3545; }
.mqtt-indicator[data-mqtt-indicator="yellow"] { background-color: #ffc107; }
.mqtt-indicator[data-mqtt-indicator="green"] { background-color: #28a745; }