h1, h2, h3, h4, h5, h6 { margin: 0; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: #222;
    background: #f2f2f2;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

html { font-size: 16px; }

canvas#whiteboard {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* Toolbar */
.toolbar {
    position: fixed;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

.tool-button, .icon-button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #444;
    font-size: 1.05rem;
    text-decoration: none;
    padding: 0;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.tool-button:hover, .icon-button:hover {
    background-color: #f0f2f7;
    color: #222;
}

.tool-button.active {
    background-color: #d9dffc;
    color: #3859ff;
}

.toolbar-divider {
    height: 1px;
    background: #e6e6e6;
    margin: 4px 4px;
}

/* Pen sidebar */
#pen-sidebar {
    position: fixed;
    background: white;
    border-radius: 12px;
    width: 180px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 6;
}

#pen-sidebar h5 {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 4px;
    margin-top: 8px;
    font-weight: 600;
}

#pen-sidebar h5:first-of-type { margin-top: 0; }

#pen-sidebar input[type="range"] {
    width: 100%;
}

#pen-sidebar .colorPicker ul {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

#pen-sidebar li button.color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #ccc;
    cursor: pointer;
    padding: 0;
}

#pen-sidebar li button.color.active {
    box-shadow: 0 0 0 2px #3859ff;
}

#pen-sidebar input[type="color"] {
    width: 100%;
    height: 28px;
    margin-top: 8px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Top bar (identity + share) */
#topbar {
    position: fixed;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 6px 8px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

#identity {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px;
    border-right: 1px solid #e6e6e6;
}

#identity .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3859ff;
    flex-shrink: 0;
}

#identity input[type="text"] {
    border: none;
    outline: none;
    font: inherit;
    color: #222;
    font-weight: 600;
    width: 110px;
    padding: 4px 6px;
    border-radius: 6px;
    background: transparent;
}

#identity input[type="text"]:hover,
#identity input[type="text"]:focus {
    background: #f0f2f7;
}

#identity input[type="color"] {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

/* Zoom controls */
#zoombar {
    position: fixed;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    padding: 6px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

#zoomReset {
    width: auto;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #444;
}

/* Status indicator (saving / connecting) */
#status {
    position: fixed;
    bottom: 12px;
    left: 12px;
    padding: 6px 12px;
    background: white;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #666;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

.hidden { display: none !important; }

/* Cursors */
#cursors { position: fixed; inset: 0; pointer-events: none; z-index: 4; }

.cursor {
    position: fixed;
    pointer-events: none;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
    transform: translate(2px, 2px);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cursor .cursor-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 8px solid transparent;
    transform: rotate(-45deg);
    transform-origin: 0 0;
}

.cursor .cursor-name {
    background: currentColor;
    color: white;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 8px;
    margin-top: 8px;
    font-size: 10px;
    line-height: 1.4;
    white-space: nowrap;
}

/* Inline text editor (for text + sticky note) */
#text-editor-layer { position: fixed; inset: 0; pointer-events: none; z-index: 6; }

.text-edit {
    position: absolute;
    pointer-events: auto;
    border: 1px dashed #3859ff;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 6px;
    outline: none;
    font-family: sans-serif;
    color: #222;
    min-width: 40px;
    min-height: 1em;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 4px;
}

.sticky-edit {
    position: absolute;
    pointer-events: auto;
    border: 1px dashed rgba(0, 0, 0, 0.3);
    padding: 8px;
    outline: none;
    font-family: sans-serif;
    color: #222;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 4px;
}

/* Modal */
.modal-window {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 999;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s;
}

.modal-window:target {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-window > div {
    position: absolute;
    width: 90%;
    max-width: 540px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 2em;
    background: white;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal-window h1 {
    font-size: 1.4rem;
    margin: 0 0 12px;
}

.modal-window > div > div {
    margin-bottom: 10px;
}

.modal-window small { color: #888; font-size: 0.7rem; }

.copy-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px !important;
}

.copy-row input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.8rem;
    background: #fafafa;
    color: #444;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-copy {
    padding: 8px 12px;
    background: #3859ff;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-copy:hover { background: #2844db; }
.btn-copy.copied { background: #1abc9c; }

.modal-close {
    color: #aaa;
    font-size: 0.7rem;
    position: absolute;
    right: 14px;
    top: 14px;
    text-decoration: none;
    cursor: pointer;
}
.modal-close:hover { color: #222; }

.get-started {
    display: inline-block;
    padding: 10px 24px;
    background-color: #3859ff;
    color: white;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s;
    margin-top: 10px;
}
.get-started:hover { background-color: #2844db; }

.text-center { text-align: center; }
