@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

:root {
    --paper-bg: #f7f4ed;
    --paper-card: #fefcf7;
    --ink-dark: #2b2825;
    --ink-muted: #6e6a64;
    --border-newspaper: #111111;
    --stamp-red: #8b2626;
    --accent-sepia: #e3d9c6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Courier Prime', monospace;
}

body {
    background-color: var(--paper-bg);
    color: var(--ink-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100dvh; /* Mobile viewport handling */
    width: 100vw;
}

.chat-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--paper-card);
    border-left: 2px solid var(--border-newspaper);
    border-right: 2px solid var(--border-newspaper);
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

.header {
    border-bottom: 2px double var(--border-newspaper);
    padding: 12px 16px;
    text-align: center;
    background: var(--paper-bg);
}

.masthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.pigeon-icon {
    width: 28px;
    height: 28px;
    fill: var(--ink-dark);
}

.header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.identity-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--accent-sepia);
    border-bottom: 1px solid var(--border-newspaper);
    font-size: 0.8rem;
}

.role-selector select {
    background: transparent;
    border: 1px solid var(--ink-dark);
    font-family: inherit;
    padding: 2px 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-image: radial-gradient(var(--accent-sepia) 0.75px, transparent 0.75px);
    background-size: 12px 12px;
}

.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.msg-wrapper.sent {
    align-self: flex-end;
}

.msg-wrapper.received {
    align-self: flex-start;
}

.msg-bubble {
    padding: 10px 12px;
    border: 1px solid var(--border-newspaper);
    position: relative;
    font-size: 0.92rem;
    line-height: 1.35;
    background: var(--paper-card);
}

.msg-wrapper.sent .msg-bubble {
    border-radius: 6px 0px 6px 6px;
    box-shadow: 2px 2px 0px var(--border-newspaper);
}

.msg-wrapper.received .msg-bubble {
    border-radius: 0px 6px 6px 6px;
    box-shadow: -2px 2px 0px var(--border-newspaper);
}

.msg-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--ink-muted);
    margin-top: 4px;
    text-transform: uppercase;
}

.input-area {
    padding: 10px 12px;
    border-top: 2px solid var(--border-newspaper);
    background: var(--paper-bg);
    display: flex;
    gap: 8px;
}

.input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-newspaper);
    background: var(--paper-card);
    padding: 8px;
    font-size: 0.95rem;
    height: 42px;
    outline: none;
}

.input-area textarea:focus {
    outline: 1px solid var(--ink-dark);
}

.send-btn {
    background: var(--ink-dark);
    color: var(--paper-card);
    border: 1px solid var(--border-newspaper);
    padding: 0 16px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:active {
    background: var(--stamp-red);
}