:root {
    --line-green: #06C755;
    --line-bg: #8cabd0;
    --bubble-bg: #ffffff;
    --text-color: #111111;
    --time-color: #666666;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --ios-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Arial, sans-serif;
    background-color: #f0f0f0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 450px;
    height: 100%;
    background-color: var(--line-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header Styles */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.glass-header h1 {
    font-size: 1.2rem;
    color: #333;
    font-weight: 700;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.platform-label {
    font-size: 0.8rem;
    color: white;
    /* Changed from #666 to white for better visibility on blue background */
    font-weight: 500;
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--line-green);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Chat Area */
/* Chat Area - Added enough padding to clear ANY URL bar or notch */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    background-color: #8fa0be;
    /* Reduced margin-top slightly to move everything up as suggested */
    padding-top: 30px;
}

#sticky-preview-area {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: rgba(143, 160, 190, 0.95);
    padding: 10px 10px 5px;
    border-bottom: none;
    box-shadow: none;
}

/* ... existing button styles ... */

.delete-msg-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #555;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0 8px;
    margin-left: 8px;
    line-height: 1;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-msg-btn:active {
    background: #ffcccc;
    color: #cc0000;
}

/* History Display Area */
#history-container {
    padding: 10px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Message Wrapper - Ensure Row Layout */
.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 90%;
    flex-wrap: nowrap;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 40%;
    overflow: hidden;
    background-color: transparent;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bubble-content-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    min-width: 0;
    flex: 0 1 auto;
    /* Do not stretch */
}

/* User wants to see how it looks on the LEFT (receiver side) */
.message-wrapper.self {
    align-self: flex-start;
}

/* Message Bubbles - Compactized as requested */
.bubble {
    background-color: var(--bubble-bg);
    color: var(--text-color);
    padding: 7px 12px;
    border-radius: 15px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: left !important;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    cursor: pointer;
    transition: background-color 0.2s;
    /* Use display: table to strictly fit content width on mobile */
    display: table;
    width: auto;
    margin-right: auto;
    max-width: 75vw;
}

.bubble:active {
    background-color: #f0f0f0;
}

.bubble.copying::after {
    content: "コピー完了！";
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
}

.draft .bubble {
    opacity: 0.7;
    cursor: default;
}

/* LINE style tail */
.message-wrapper.self .bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 10px;
    border-right: 8px solid var(--bubble-bg);
    border-bottom: 6px solid transparent;
}

.time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2px;
}

/* Emoji images */
.emoji {
    height: 1.25em;
    width: 1.25em;
    margin: 0 0.1em;
    vertical-align: -0.2em;
}

/* Input Area */
/* Input Area */
.input-area {
    background: white;
    padding: 5px 15px calc(15px + env(safe-area-inset-bottom, 5px));
    /* Reduced top/bottom padding and added safe-area */
    border-top: 1px solid #ddd;
}

/* Footer Toggle Styles */
.toggle-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
    /* Reduced margin */
    padding-top: 5px;
}

.input-container {
    display: flex;
    align-items: flex-end;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 5px 12px;
    margin-bottom: 8px;
}

/* ... (rest of input styles) ... */

/* RE-APPLYING DATE DIVIDER STYLES */
.date-divider {
    text-align: center;
    font-size: 0.75rem;
    /* Slightly larger text */
    color: white;
    background: rgba(0, 0, 0, 0.2);
    /* Darker background for better contrast */
    padding: 4px 12px;
    border-radius: 12px;
    align-self: center;
    margin: 15px auto;
    /* Centered with vertical spacing */
    width: fit-content;
    display: inline-block;
}

.bubble-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    /* Explicit spacing between message groups */
}

.input-actions {
    display: flex;
    gap: 5px;
    padding-bottom: 5px;
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    padding: 2px 0;
    /* Tight padding for 1-line height */
    resize: none;
    outline: none;
    font-family: inherit;
    /* Strict 1-line baseline */
    min-height: 1.25em;
    height: 1.25em;
    max-height: 150px;
    line-height: 1.25;
    overflow: hidden;
}

.icon-btn {
    background: none;
    border: none;
    outline: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:focus,
.icon-btn:active {
    outline: none !important;
    box-shadow: none !important;
}

.icon-btn.primary {
    color: var(--line-green);
    font-size: 1.8rem;
}

.icon-btn:active {
    opacity: 0.6;
}

.hint-text {
    font-size: 0.7rem;
    color: #888;
    text-align: center;
}

/* Android vs iOS Specific Tweaks */
.ios-mode .bubble {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

.android-mode .bubble {
    font-family: "Roboto", "Noto Sans JP", sans-serif;
}