/* Base styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --color-bg: #d1d5db;
    --color-surface: #EBEFEE;
    --color-surface-input: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #666666;
    --color-primary: #a65d52;
    --color-primary-hover: #c01540;
    --color-border: #1a1a1a;
    --color-border-light: #e5e5e5;
    --color-focus: #9ca3af;
    --color-btn: #d1d5db;
    --color-btn-hover: #ffffff;
    --color-marker: rgba(230, 25, 75, 0.3);
    --color-marker-stroke: #a65d52;
    --shadow-solid-sm: 2px 2px 0 rgba(0, 0, 0, 0.15);
    --shadow-solid: 4px 4px 0 rgba(0, 0, 0, 0.15);
    --radius: 2px;
    --font-mono: 'Space Mono', monospace;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-mono);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
}


/* Landing page */
.landing {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--color-surface);
    background-image:
        linear-gradient(to right, #c5ccc9 1px, transparent 1px),
        linear-gradient(to bottom, #c5ccc9 1px, transparent 1px);
    background-size: 24px 24px;
}

.landing-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.landing-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    width: 100%;
    max-width: 34.375rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-solid);
}


.input-wrapper {
    width: 100%;
    max-width: 46.875rem;
}

.input-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    box-shadow: var(--shadow-solid);
    padding: 1.5rem;
    width: 100%;
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    max-width: 34.375rem;
    margin-bottom: 1.25rem;
    font-weight: bold;
}
h1.logo {
    margin-bottom: 0;
    padding: 0;
    line-height:1
}
.logo {
    color: var(--color-text);
}

.tagline-right {
    margin: 0;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    font-size: 1rem;
}

.logo img {
    height: 40px;
    width: auto;
}

.tagline {
    margin: 0 0 2.5rem 0;
    font-family: var(--font-mono);
    font-size: 1rem;
    text-align: left;
    align-self: stretch;
}

/* Input tabs */
.input-tabs {
    display: flex;
    gap: 0;
    align-self: flex-start;
    margin-left: 0;
    margin-bottom: -1px;
    position: relative;
    z-index: 2;
}

.input-tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-family: var(--font-mono);
    font-weight: 400;
    background: var(--color-btn);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    margin-right: -1px;
    position: relative;
}

.input-tab:not(.active) {
    padding: 0.675rem 1.25rem;
    margin-top: 1px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 1px;
}

.input-tab:hover {
    color: var(--color-text);
    background: var(--color-btn-hover);
}

.input-tab.active {
    color: var(--color-text);
    background: var(--color-surface);
    z-index: 1;
}

.url-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 43.75rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-row-inline {
    align-items: flex-end;
}

.url-field {
    flex: 2;
    min-width: 0;
}

.password-field {
    flex-shrink: 0;
    width: 7rem;
}

.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 0.375rem;
}

.password-input {
    width: 100%;
}

/* Upload form */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 43.75rem;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    width: 100%;
    background: var(--color-surface-input);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #4a7c59;
    background: #f0f5f1;
}

.upload-area.has-file {
    border-style: solid;
    border-color: var(--color-border);
}

.upload-icon {
    width: 32px;
    height: 32px;
    color: var(--color-text-muted);
}

.upload-text {
    font-size: 0.875rem;
    color: var(--color-text);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.upload-footer {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0.75rem;
}

.upload-field {
    flex-shrink: 0;
}

input.upload-width-input {
    width: 5rem;
    font-family: var(--font-mono);
}

.upload-error:empty {
    display: none;
}

.upload-error {
    font-size: 0.875rem;
    color: #a65d52;
}

/* Base input styles */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="url"],
textarea {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-input);
    color: var(--color-text);
    text-align: left;
    transition: border-color 0.15s ease;
    box-shadow: var(--shadow-solid);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-focus);
}

/* Hide number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input.url-input {
    width: 100%;
    font-family: var(--font-mono);
}

/* btn-lg used for submit buttons */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.footer {
    padding: 1.5rem 0;
    text-align: left;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-family: var(--font-mono);
    width: 100%;
    max-width: 34.375rem;
}

.footer a {
    color: var(--color-text);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}


/* Error message */
.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    color: #a65d52;
    border: 1px solid #a65d52;
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid-sm);
    font-size: 0.875rem;
}


/* Loading state */
.loading {
    display: none;
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    align-items: center;
    gap: 0.75rem;
}

.loading.active {
    display: flex;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
}

.loading-spinner span {
    background: var(--color-text-muted);
    animation: pixel-blink 0.8s steps(1) infinite;
}

.loading-spinner span:nth-child(1) { animation-delay: 0s; }
.loading-spinner span:nth-child(2) { animation-delay: 0.2s; }
.loading-spinner span:nth-child(4) { animation-delay: 0.4s; }
.loading-spinner span:nth-child(3) { animation-delay: 0.6s; }

@keyframes pixel-blink {
    0%, 25% { opacity: 1; }
    26%, 100% { opacity: 0.2; }
}


/* History section */
.history-section {
    margin-top: 3rem;
    width: 100%;
    max-width: 37.5rem;
}

.history-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.75rem 0;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--color-surface-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid);
}

.history-item {
    border-bottom: 1px solid var(--color-border);
}

.history-item:last-child {
    border-bottom: none;
}

.history-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s ease;
}

.history-link:hover {
    background: var(--color-bg);
}

.history-type-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.history-url {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.history-lock {
    display: flex;
    align-items: center;
}

.history-lock svg {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

.history-contributors {
    display: flex;
    flex-direction: row-reverse;
}

.history-contributor {
    width: 18px;
    height: 18px;
    border-radius: 0.25rem;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-surface-input);
    margin-left: -6px;
}

.history-contributor:last-child {
    margin-left: 0;
}

.history-comments {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 9px;
}

.history-expiry,
.history-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}


/* Annotation page */
.annotate-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    background-image:
        linear-gradient(to right, #c5ccc9 1px, transparent 1px),
        linear-gradient(to bottom, #c5ccc9 1px, transparent 1px);
    background-size: 24px 24px;
}

.annotate-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.annotate-logo {
    color: var(--color-text);
    text-decoration: none;
    flex-shrink: 0;
}

.annotate-logo img {
    height: 24px;
    width: auto;
    display: block;
}

.header-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.url-wrapper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    flex-shrink: 1;
}

.annotate-url {
    font-size: 0.75rem;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    margin-right: .15rem;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
}

.annotate-url:hover {
    color: var(--color-text);
    background: var(--color-hover);
}

.url-wrapper .btn-icon {
    flex-shrink: 0;
}

.url-wrapper .btn-icon svg {
    width: 14px;
    height: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}


/* Active users */
.active-users {
    display: flex;
    align-items: center;
    position: relative;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 0.25rem;
    border: 2px solid var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    margin-left: -8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease;
}

.user-avatar:first-child {
    margin-left: 0;
}

.user-avatar:hover {
    transform: scale(1.1);
    z-index: 5;
}

.user-avatar.current-user {
    border-width: 1px;
    border-color: var(--color-border);
    box-shadow: var(--shadow-solid-sm);
}

.user-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 0.5rem;
}

.user-divider + .user-avatar {
    margin-left: 0;
}

.user-avatar:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    transform: scale(1.1);
    z-index: 5;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 16.25rem;
    max-height: 17.5rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid);
    z-index: 100;
    display: none;
}

.user-dropdown.active {
    display: block;
}

.user-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-dropdown-avatar {
    width: 24px;
    height: 24px;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-dropdown-name {
    font-size: 0.875rem;
    font-weight: 600;
    flex: 1;
}

/* user-dropdown-change uses .btn .btn-sm */

.user-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.user-comment-item {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-comment-item:last-child {
    border-bottom: none;
}

.user-comment-item:hover,
.user-comment-item:focus {
    background: var(--color-bg);
    outline: none;
}

.user-comment-item:focus {
    box-shadow: inset 2px 0 0 var(--color-primary);
}

.user-comment-content {
    font-size: 0.75rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-comment-time {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-top: 0.125rem;
}


/* Notifications */
.notifications-wrapper {
    position: relative;
}

.notifications-btn {
    position: relative;
}

.notifications-btn.active {
    transform: translate(2px, 2px);
    box-shadow: none;
    background: var(--color-btn-hover);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #a65d52;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
}

.notification-badge.active {
    display: flex;
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 17.5rem;
    max-height: 20rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid);
    z-index: 100;
    display: none;
}

.notifications-dropdown.active {
    display: block;
}

.notifications-header {
    display: none;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
}

.notifications-header.active {
    display: block;
}

/* clear-notifications-btn uses .btn .btn-sm */

.notifications-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover,
.notification-item:focus {
    background: var(--color-bg);
    outline: none;
}

.notification-item:focus {
    box-shadow: inset 2px 0 0 var(--color-primary);
}

.notification-item.unread {
    background: #eff6ff;
}

.notification-item.unread:focus {
    background: #dbeafe;
}

.notification-author {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-author-dot {
    width: 14px;
    height: 14px;
    border-radius: 0.25rem;
    flex-shrink: 0;
    font-size: 0.4375rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.notification-content {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-time {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}


/* Expiry display */
.expiry-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.expiry-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.expiry-time.warning {
    color: #ea580c;
}

.expiry-time.expired {
    color: #a65d52;
    font-weight: 600;
}

/* extend-btn, lock-btn use .btn .btn-sm */
/* delete-page-btn uses .btn .btn-sm .btn-danger */

.modal-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}


/* Password page */
.password-box {
    width: 100%;
    max-width: 25rem;
    text-align: center;
}

.password-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.password-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0 0 1.5rem 0;
}

.password-form {
    display: flex;
    gap: 0.75rem;
}

.password-field {
    flex: 1;
}

.password-error {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #a65d52;
    min-height: 1.25rem;
}


/* Action buttons */
/* goto-btn, share-btn use .btn */
a.btn {
    text-decoration: none;
}


/* Main container */
.annotate-container {
    flex: 1;
    overflow: auto;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.screenshot-wrapper {
    position: relative;
    display: inline-block;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-solid);
    border-radius: var(--radius);
    overflow: hidden;
}

.screenshot-image {
    display: block;
    max-width: 100%;
    height: auto;
}

.annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}


/* Annotation markers */
.annotation-marker {
    position: absolute;
    background: var(--marker-color, rgba(37, 99, 235, 0.3));
    border: 2px solid var(--marker-stroke, #2563eb);
    border-radius: 2px;
    cursor: grab;
    transition: background 0.15s ease;
}

.annotation-marker.dragging {
    cursor: grabbing;
    opacity: 0.9;
    z-index: 100;
    transition: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.annotation-marker.resizing {
    z-index: 100;
    transition: none;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid var(--marker-stroke, #2563eb);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.annotation-marker:hover .resize-handle,
.annotation-marker.resizing .resize-handle {
    opacity: 1;
}

/* Corner handles */
.resize-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resize-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

/* Side handles */
.resize-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-e { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.resize-w { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.annotation-marker:hover {
    filter: brightness(0.9);
}

.annotation-marker:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.annotation-marker.point {
    width: 24px;
    height: 24px;
    border-radius: 0.25rem;
    transform: translate(-50%, -50%);
}

.annotation-marker.point:focus {
    outline-offset: 4px;
}

/* Restored annotation highlight animation */
.annotation-marker.restored-highlight {
    animation: restored-pulse 2s ease-in-out;
}

@keyframes restored-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(100, 100, 100, 0.6);
        transform: scale(1);
    }
    15% {
        box-shadow: 0 0 0 15px rgba(120, 120, 120, 0.5);
        transform: scale(1.08);
    }
    30% {
        box-shadow: 0 0 0 8px rgba(100, 100, 100, 0.4);
        transform: scale(1.02);
    }
    45% {
        box-shadow: 0 0 0 20px rgba(140, 140, 140, 0.35);
        transform: scale(1.06);
    }
    60% {
        box-shadow: 0 0 0 12px rgba(120, 120, 120, 0.25);
        transform: scale(1.01);
    }
    75% {
        box-shadow: 0 0 0 25px rgba(150, 150, 150, 0.15);
        transform: scale(1.03);
    }
    100% {
        box-shadow: 0 0 0 30px rgba(150, 150, 150, 0);
        transform: scale(1);
    }
}

.annotation-marker.point.restored-highlight {
    animation: restored-pulse-point 2s ease-in-out;
}

@keyframes restored-pulse-point {
    0% {
        box-shadow: 0 0 0 0 rgba(100, 100, 100, 0.6);
        transform: translate(-50%, -50%) scale(1);
    }
    15% {
        box-shadow: 0 0 0 15px rgba(120, 120, 120, 0.5);
        transform: translate(-50%, -50%) scale(1.15);
    }
    30% {
        box-shadow: 0 0 0 8px rgba(100, 100, 100, 0.4);
        transform: translate(-50%, -50%) scale(1.05);
    }
    45% {
        box-shadow: 0 0 0 20px rgba(140, 140, 140, 0.35);
        transform: translate(-50%, -50%) scale(1.12);
    }
    60% {
        box-shadow: 0 0 0 12px rgba(120, 120, 120, 0.25);
        transform: translate(-50%, -50%) scale(1.03);
    }
    75% {
        box-shadow: 0 0 0 25px rgba(150, 150, 150, 0.15);
        transform: translate(-50%, -50%) scale(1.08);
    }
    100% {
        box-shadow: 0 0 0 30px rgba(150, 150, 150, 0);
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Profile circles stack */
.marker-profiles {
    position: absolute;
    top: -10px;
    left: -10px;
    display: flex;
    flex-direction: row-reverse;
    pointer-events: none;
}

.marker-profile {
    width: 20px;
    height: 20px;
    border-radius: 0.25rem;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    margin-left: -8px;
}

.marker-profile:last-child {
    margin-left: 0;
}

.annotation-marker.point .marker-profiles {
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
}

.annotation-marker.point .marker-profile {
    margin-left: 0;
    margin-right: -8px;
}

.annotation-marker.point .marker-profile:last-child {
    margin-right: 0;
}

/* Comment counter badge */
.comment-counter {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.annotation-marker.point .comment-counter {
    top: -32px;
    right: -12px;
    transform: none;
}

/* Dim other markers when popup is open */
.annotation-layer.popup-open .annotation-marker {
    opacity: 0.1;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.annotation-layer.popup-open .annotation-marker.active-marker {
    opacity: 1;
    pointer-events: auto;
}


/* Active selection indicator (other users) */
.active-selection {
    position: absolute;
    border: 2px dashed;
    border-radius: var(--radius-sm);
    pointer-events: none;
    animation: pulse 1.5s ease-in-out infinite;
    z-index: 10;
}

.active-selection::after {
    content: attr(data-author);
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
    background: var(--selection-color);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Composing state - rotating dashed border */
.active-selection.composing {
    animation: none;
    border-style: dashed;
    border-width: 3px;
}

.composing-indicator {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 0.25rem;
    border: 3px dashed white;
    animation: rotate-border 2s linear infinite;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.active-selection.point .composing-indicator {
    top: -30px;
    right: 50%;
    transform: translateX(50%);
}

@keyframes rotate-border {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 25rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-solid);
}

.modal-title {
    margin: 0 0 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-field {
    margin-bottom: 1rem;
}

.modal-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.modal-input,
.modal-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-input);
    color: var(--color-text);
    text-align: left;
    box-shadow: var(--shadow-solid);
}

.modal-input:focus,
.modal-textarea:focus {
    outline: none;
    border-color: var(--color-focus);
}

.modal-textarea {
    min-height: 6.25rem;
    resize: vertical;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}


/* Color picker */
.color-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-row {
    display: flex;
    gap: 0.5rem;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 0.25rem;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--color-text);
}


/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-family: var(--font-mono);
    font-weight: 400;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
    text-transform: none;
    box-shadow: var(--shadow-solid-sm);
    background: var(--color-btn);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn:hover {
    background: var(--color-btn-hover);
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
}

.btn-lg {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    box-shadow: var(--shadow-solid);
}

.btn-lg:active {
    transform: translate(4px, 4px);
}

.btn-icon {
    padding: 0.5rem;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.btn-danger {
    color: #a65d52;
    border-color: #a65d52;
}


/* Comment popup */
.comment-popup {
    position: absolute;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-solid);
    width: 18.75rem;
    z-index: 300;
    display: none;
}

.comment-popup.active {
    display: block;
}

.comment-popup {
    cursor: grab;
}

.comment-popup.dragging {
    cursor: grabbing;
    user-select: none;
}

.comment-popup button,
.comment-popup textarea,
.comment-popup input,
.comment-popup a {
    cursor: auto;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 -1rem 0.5rem -1rem;
    padding: 0 1rem;
}

.comment-author {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.comment-author-dot {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    margin-top: 0.125rem;
}

.comment-author-btn {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.comment-author-btn:hover {
    color: var(--color-primary);
}

.comment-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.popup-comment-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 9px;
}

.popup-comment-count:empty {
    display: none;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.comment-header-right .delete-link {
    display: inline;
    position: static;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.comment-header:hover .delete-link {
    opacity: 1;
}

.comment-content {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text);
    padding: 0 1rem 0.75rem 1rem;
    margin: 0 -1rem;
}

.comment-content p {
    margin: 0 0 0.5rem 0;
}

.comment-content p:last-child {
    margin-bottom: 0;
}

.delete-link {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 0;
    background: none;
    border: none;
    font-size: 0.6875rem;
    font-family: inherit;
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.delete-link:hover {
    color: #a65d52;
}

.comment-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}


/* Popup compose mode */
.popup-view,
.popup-compose {
    display: none;
}

.comment-popup.mode-view .popup-view {
    display: block;
}

.comment-popup.mode-compose .popup-compose {
    display: block;
}

.popup-textarea {
    width: 100%;
    min-height: 5rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
    text-align: left;
    box-shadow: var(--shadow-solid-sm);
    
}

.popup-textarea:focus {
    outline: none;
    border-color: var(--color-focus);
}

.popup-compose-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}


/* Comment replies */
.comment-replies {
    margin: 0 -1rem;
    padding: 0.5rem 0;
    max-height: 12.5rem;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.reply-item {
    padding: 1rem;
    border-bottom: 1px solid #C5CCC9;
}

.reply-item:last-child {
    border-bottom: none;
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.reply-author {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
}

.reply-author-dot {
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
    font-size: 0.4375rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    margin-top: 0.0625rem;
}

.reply-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reply-header-right .delete-link {
    display: inline;
    position: static;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.reply-header:hover .delete-link {
    opacity: 1;
}

.reply-time {
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

.reply-body {
    position: relative;
}

.reply-content {
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--color-text);
}

.reply-content p {
    margin: 0 0 0.5rem 0;
}

.reply-content p:last-child {
    margin-bottom: 0;
}

/* Flash animation for new comments */
.reply-item.flash {
    animation: flash-highlight 1.5s ease-out;
}

@keyframes flash-highlight {
    0% {
        background-color: rgba(37, 99, 235, 0.2);
    }
    100% {
        background-color: transparent;
    }
}


/* Typing indicator */
.typing-indicator {
    display: none;
    padding: 1rem 0 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    align-items: center;
    gap: 0.5rem;
    margin-bottom: -0.5rem;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--typing-color, #4a7c59);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.typing-avatar {
    width: 16px;
    height: 16px;
    border-radius: 0.25rem;
    font-size: 0.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

.typing-text {
    color: var(--color-text-muted);
}

.reply-item.highlight {
    background: rgba(37, 99, 235, 0.1);
    animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
    0% { background: rgba(37, 99, 235, 0.2); }
    100% { background: transparent; }
}


/* Inline reply form */
.inline-reply-form {
    margin: 4px -1rem -1rem -1rem;
    padding: 1rem;
}

.inline-reply-header {
    display: none;
}


/* Toast notification */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 20rem;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(1rem);
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
    position: relative;
    pointer-events: auto;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.toast.removing {
    transform: translateY(-1rem);
    opacity: 0;
}

.toast-message {
    flex: 1;
}

.toast-progress {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: var(--color-border);
    opacity: 0.15;
    transform-origin: left;
    z-index: -1;
}

.toast.countdown .toast-progress {
    animation: toast-countdown linear forwards;
}

@keyframes toast-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}


/* Mark as done button */
.mark-done-btn {
    margin-right: auto;
}


/* Done items panel */
.done-items-wrapper {
    position: relative;
}

.done-items-btn {
    position: relative;
}

.done-items-btn.active {
    transform: translate(2px, 2px);
    box-shadow: none;
    background: var(--color-btn-hover);
}

.done-items-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #4a7c59;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
}

.done-items-badge.active {
    display: flex;
}

.done-items-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 18.75rem;
    max-height: 21.875rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-solid);
    z-index: 100;
    display: none;
}

.done-items-dropdown.active {
    display: block;
}

.done-items-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.done-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.done-item:last-child {
    border-bottom: none;
}

.done-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.done-item-author {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.done-item-author-dot {
    width: 14px;
    height: 14px;
    border-radius: 0.25rem;
    flex-shrink: 0;
    font-size: 0.4375rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.done-item-restore {
    flex-shrink: 0;
}

.done-item-content {
    font-size: 0.75rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.done-item-meta {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}


/* Responsive styles */
@media (max-width: 40rem) {
    .landing-main {
        padding: 1rem;
    }

    .logo img {
        height: 32px;
    }

    .url-form .form-row-inline {
        flex-direction: column;
    }

    .url-form .url-field {
        width: 100%;
    }

    .submit-btn {
        width: 100%;
    }


    .annotate-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-left {
        order: 3;
        width: 100%;
        flex: none;
    }

    .annotate-container {
        padding: 1rem;
    }

    .comment-popup {
        width: 16.25rem;
    }

    .notifications-dropdown {
        width: 16.25rem;
        right: -60px;
    }

    .done-items-dropdown {
        width: 16.25rem;
        right: -30px;
    }
}


/* Utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
