:root{
    --bg-color: #ffffff;
    --text-color: #111827;
    --border-color: #c1c7d4;
    --nover-bg: #f3f4f6;
    --accent-black: #000000;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body{
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f9fafb;
    color: var(--text-color);
    margin: 0;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

#bg-canvas{
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

@keyframes slideUp{
    to { opacity: 1; transform: translateY(0);}
}

.stagger-1{opacity: 0; transform: translateY(30px); animation: slideUp 1.0s cubic-bezier(0.16, 1, 0.3, 1) 0.4s forwards;}
.stagger-2{opacity: 0; transform: translateY(30px); animation: slideUp 1.0s cubic-bezier(0.16, 1, 0.3, 1) 1.2s forwards;}
.stagger-3{opacity: 0; transform: translateY(30px); animation: slideUp 1.0s cubic-bezier(0.16, 1, 0.3, 1) 2.0s forwards;}
.stagger-4{opacity: 0; transform: translateY(30px); animation: slideUp 1.0s cubic-bezier(0.16, 1, 0.3, 1) 2.8s forwards;}

.cursor{
    display: inline-block;
    font-weight: bold;
    color: var(--text-color);
    animation: blink 1s step-end infinite;
}

@keyframes blink{
    50% {opacity: 0;}
}

#app-container{
    position: relative;
    z-index: 10;
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-color);
    padding: 40px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

h1{
    text-align: center;
    font-size: 2.5rem;
    letter-spacing: -1px;
    margin-top: 0;
    margin-bottom: 5px;
    font-weight: 800;
    font-family: 'Courier New', Courier, monospace;
}

.motto{
    text-align: center;
    color: #6b7280;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    margin-top: 0;
    margin-bottom: 30px;
    min-height: 20px;
    font-family: 'Courier New', Courier, monospace;
}

.btn{
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.btn:hover{
    background-color: var(--nover-bg);
    border-color: #d1d5db;
}

.success-btn {
    background-color: #10b981 !important;
    color: white !important;
    border-color: #10b981 !important;
}

.success-btn:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
}

.danger-btn{
    background-color: #ef4444 !important;
    color: white !important;
    border-color: #ef4444 !important;
}

.danger-btn:hover{
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
}

input[type="text"], input[type="password"]{
    padding: 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    width: 260px;
    max-width: 100;
    box-shadow: var(--shadow-sm);
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-row {
    display:flex;
    flex-wrap:wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.password-wrapper{
    position: relative;
    max-width: 100%;
    width: 260px;
}

.password-wrapper input{
    padding-right: 40px !important;
    margin-bottom: 0 !important;
    width: 100% !important;
}

.password-toggle{
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    opacity: 0.5;
    transition: opacity 0.2s;
    outline: none;
}

.password-toggle:hover{
    opacity:0.8;
}

#setup-screen{
    text-align: center;
    padding: 20px 0;
}

#setup-screen .stagger-2,
#setup-screen .stagger-4{
    margin: 25px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#editor-screen{
    display: none;
}

.header-top-row{
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 12px;
}

.header-group{
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

#role-group{
    align-items: flex-start;
}

.header-buttons{
    display: flex;
    gap: 8px;
}

#room-display, #users-display, #role-display {
    background-color: var(--nover-bg);
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
}

#users-display{
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

#main-workspace-flex{
    display: flex;
    width: 100%;
    height: 75vh;
    gap: 15px;
    box-sizing: border-box;
    min-width: 0;
}

#workspace-container{
    display: flex;
    flex: 1;
    height: 100%;
    gap: 15px;
    transition: all 0.3s ease;
    position: relative;
    min-width: 0;
}

#sticky-layer{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index:50;
    overflow: hidden;
}

.sticky-note{
    position:absolute;
    width: 160px;
    min-height: 160px;
    background-color: #fef08a;
    border: 1px solid #fde047;
    box-shadow: var(--shadow-md);
    box-sizing: border-box;
    pointer-events: auto;
    border-radius: 8px;
    border-bottom-right-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sticky-header{
    height: 24px;
    background-color: rgba(0,0,0,0.04);
    cursor: grab;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 8px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.sticky-delete-btn{
    background: transparent;
    border: none;
    color: var(--text-color);
    opacity: 0.4;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.sticky-delete-btn:hover{
    opacity: 1;
    color: #ef4444;
    transform: scale(1.1);
}

.sticky-text-area{
    flex: 1;
    padding: 12px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: #422006;
    outline: none;
    cursor: text;
}

.sticky-note:focus-within{
    box-shadow: var(--shadow-lg);
    border-color: #eab308;
}

#document-editor{
    flex: 1;
    height: 100%;
    padding: 24px;
    font-size: 16px;
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow-y: auto;
    box-sizing: border-box;
    outline: none;
    line-height: 1.6;
    text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#drawing-canvas{
    flex: 1;
    height: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: crosshair;
    display: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.mode-writing #document-editor { display: block; flex: 1 1 100%;}
.mode-writing #drawing-canvas{display: none;}

.mode-drawing #document-editor{display:none;}
.mode-drawing #drawing-canvas{display: block; flex: 1 1 100%}

.mode-both #document-editor{display: block; flex: 1; min-width: 0;}
.mode-both #drawing-canvas{display: block; flex: 1; min-width: 0;}

#document-editor:focus{
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), inset 0 2px 4px rgba(0,0,0,0.02);
}

#document-editor[contenteditable="false"]{
    background-color: #f9fafb;
    color: #9ca3af;
}

#document-editor:empty:before{
    content: attr(placeholder);
    color: #9ca3af;
}

.command-bar{
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s;
}

.command-bar:hover {
    scrollbar-color: #9ca3af transparent;
}

.command-bar::-webkit-scrollbar {
    height: 6px;
}

.command-bar::-webkit-scrollbar-track{
    background: transparent;
}

.command-bar::-webkit-scrollbar-thumb{
    background-color: transparent;
    border-radius: 10px;
}

.command-bar:hover::-webkit-scrollbar-thumb {
    background-color: #9ca3af;
}

.toolbar-group{
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-divider{
    width: 1px;
    height: 18px;
    background: #d1d5db;
    margin: 0 12px;
    flex-shrink: 0;
}

.tool-btn{
    background: var(--bg-color);
    border: 1px solid transparent;
    border-radius: 6px;
    padding:8px 12px;
    cursor: pointer;
    font-family:inherit;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn:hover{
    background: var(--nover-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

input[type="color"]{
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
}

#toast-container{
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast{
    background: var(--text-color);
    color: var(--bg-color);
    padding: 14px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards, fadeOut 0.3s ease 5s forwards;
}

@keyframes slideInRight{
    from{ transform: translateX(100%); opacity: 0;}
    to{transform: translateX(0); opacity: 1;}
}

@keyframes fadeOut{
    to { opacity: 0; visibility: hidden;}
}

.dropdown{
    position: relative;
    display: inline-block;
}

.dropdown-content{
    display: none;
    position: absolute;
    background-color: var(--bg-color);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 200;
    padding: 8px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
}

.dropdown:hover .dropdown-content{
    display: block;
}

.dropdown-user{
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: #374151;
    border-radius: 6px;
}

.dropdown-user:hover{
    background-color: var(--nover-bg);
}

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

#chat-sidebar{
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-color);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

#chat-history{
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chat-input{
    border: none;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    background-color: transparent;
    color: var(--text-color);
    font-family: inherit;
    text-align: left;
    box-shadow: none;
}

.chat-message{
    position: relative;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    word-wrap: break-word;
    text-align: left;
    max-width: 85%;
    width: fit-content;
    line-height: 1.5;
}

.msg-other{
    align-self: flex-start;
    background-color: var(--nover-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.msg-self{
    align-self: flex-end;
    background-color: #3b82f6;
    color: #ffffff;
    border: 1px solid #2563eb;
    border-bottom-right-radius: 4px;
}

.chat-message .sender-name{
    font-weight: 600;
    font-size: 11px;
    margin-bottom: 4px;
    color: #6b7280;
    letter-spacing: 0.5px;
}

.reply-btn{
    position: absolute;
    top: 6px;
    right: -28px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 14px;
    padding: 4px;
    color: #9ca3af;
    border-radius: 50%;
}

.msg-self .reply-btn{
    right: auto;
    left: -28px;
}

.chat-message:hover .reply-btn{
    opacity: 0.8;
}

.reply-btn:hover{
    opacity: 1 !important;
    background-color: var(--nover-bg);
}

.quoted-reply{
    background-color: rgba(0,0,0,0.04);
    border-left: 3px solid #9ca3af;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 12px;
    color: inherit;
}

.msg-self .quoted-reply{
    background-color: rgba(255,255,255, 0.15);
    border-left: 3px solid rgba(255,255,255, 0.5);
}

.quoted-reply .quote-sender{
    color: inherit;
    opacity: 0.9;
    font-weight: 600;
}

#reply-preview{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background-color: var(--nover-bg);
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: #4b5563;
    text-align: left;
}

#cancel-reply-btn{
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
    opacity: 0.7;
    padding: 4px;
    border-radius: 50%;
}

#cancel-reply-btn:hover{
    opacity:1;
    background-color: #e5e7eb;
}

#import-modal{
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100w;
    height: 100vh;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(4px);
    z-index: 300;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.remote-cursor{
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.1s linear;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.remote-cursor svg{
    width: 18px;
    height: 18px;
    fill: #ef4444;
    stroke: #ffffff;
    stroke-width: 2px;
    transform: rotate(-20deg);
}

.remote-cursor .cursor-name{
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-top: 2px;
    margin-left: 8px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.floating-image-wrapper{
    position: absolute;
    box-sizing: border-box;
    cursor: grab;
    pointer-events: auto;
}

.floating-image-wrapper:active{
    cursor: grabbing;
}

.floating-image-wrapper.focused{
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.floating-image{
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
    border-radius: 4px;
}

.resize-handle{
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #ffffff;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    display: none;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
}

.floating-image-wrapper.focused .resize-handle{
    display: block;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nwse-resize;}
.resize-handle.n { top: -6px; left: calc(50% - 5px); cursor: ns-resize;}
.resize-handle.ne { top: -6px; right: -6px; cursor: nesw-resize;}
.resize-handle.e { top: calc(50% - 5px); right: -6px; cursor: ew-resize;}
.resize-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize;}
.resize-handle.s { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize;}
.resize-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize;}
.resize-handle.w { top: calc(50% - 5px); left: -6px; cursor: ew-resize;}

.context-menu {
    display: none;
    position: absolute;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    padding: 8px 0;
    min-width: 160px;
    font-family: inherit;
    font-size:14px;
    font-weight: 500;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: #374151;
}

.context-menu-item:hover {
    background-color: var(--nover-bg);
}

.context-menu-item.delete {
    color: #ef4444;
}

.context-menu-item.delete:hover {
    background-color: #fef2f2;
}
