body {
    margin: 0;
    font-family: system-ui, -apple-system, Arial, sans-serif;
    background: #f5f7fa;
    color: #2d3436;
}

/* HEADER */
.header {
    background: #1e272e;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header a {
    color: white;
    text-decoration: none;
    margin-left: 15px;
    font-size: 14px;
}

/* MAIN GRID */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 70px);
    box-sizing: border-box;
    align-items: stretch;
}

/* LEFT COLUMN */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

/* CARDS */
.sidebar,
.main,
.chat,
.notes {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

.sidebar {
    flex: 1;
}

.notes {
    min-height: 180px;
    flex-shrink: 0;
}

/* CENTER */
.main {
    height: 100%;
    overflow-y: auto;
}

/* CHAT */
.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-box {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    background: #fafafa;
}

.chat-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chat-input input {
    flex: 1;
    padding: 8px;
    font-size: 14px;
}

.chat-input button {
    padding: 8px 12px;
    font-size: 14px;
}

/* CHAT MESSAGES */
.chat-message {
    margin-bottom: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    line-height: 1.35;
}

.chat-message-user {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-message div:last-child {
    font-size: 14px;
    font-weight: 400;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* HEADINGS */
h3 {
    margin-top: 0;
    color: #2c3e50;
}

/* GUIDE LINKS */
.guide-link {
    display: block;
    padding: 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #2d3436;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.guide-link:hover {
    background: #f0f3f7;
}

/* AUTH */
#auth-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

#login-form,
#register-form,
#user-panel {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

#login-form input,
#register-form input {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#login-form button,
#register-form button {
    padding: 5px 10px;
    cursor: pointer;
}

#user-panel {
    margin-left: auto;
}

#user-name {
    font-weight: 600;
    color: white;
}

/* MODAL */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    min-width: 400px;
}

.modal-content input {
    width: 100%;
    padding: 10px 12px;
    margin: 15px 0;
    border: 1px solid #dcdde1;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ADMIN PANEL */
.admin-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    height: 100%;
}

.admin-block {
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.admin-block h3 {
    margin-top: 0;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.admin-list {
    overflow-y: auto;
    flex: 1;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.admin-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    word-break: break-word;
}

.admin-user,
.admin-invite,
.admin-chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.admin-user-controls,
.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-chat-text {
    max-width: 400px;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 14px;
}

.admin-actions button {
    padding: 6px 10px;
    cursor: pointer;
}

.notes {
    display: flex;
    flex-direction: column;
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notes-list {
    margin-top: 10px;
    overflow-y: auto;
    flex: 1;
}

.note-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.note-item button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
}

.note-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.note-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
}

.note-view-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-view-content {
    flex: 1;
    white-space: pre-wrap;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

pre {
    background: #f6f8fa;
    padding: 12px;
    border-radius: 6px;
    overflow: auto;
    font-family: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

code {
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

.note-view-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.note-title {
    cursor: pointer;
}

.note-editor {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
}

.note-editor textarea {
    width: 100%;
    min-height: 400px;
    resize: vertical;
    padding: 12px;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #ccc;
    border-radius: 8px;

    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

.note-title-edit {
    padding: 8px 10px;
    font-size: 20px;
    font-weight: 600;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.note-title:hover {
    text-decoration: underline;
}

/* HELPERS */
.hidden {
    display: none !important;
}