* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --container-bg: #ffffff;
    --header-bg: transparent;
    --header-text: #333333;
    --border-color: #e0e0e0;
    --search-bg: #f8f9fa;
    --day-bg: #dde0e2;
    --day-hover: #d8dbdd;
    --entry-bg: #f8f9fa;
    --user-entry-bg: #e0f7fa;
    --shadow: rgba(0, 0, 0, 0.1);
    --nav-btn-bg: #cad0e4;
    --nav-btn-hover: #a5acd1;
    --today-bg: #9fabe2;
    --selected-bg: #e6a0a0;
    --add-btn-bg: #76a982;
    --add-btn-hover: #3f824e;
    --save-btn-bg: #76a982;
    --save-btn-hover: #3f824e;
    --clear-btn-bg: #6c757d;
    --clear-btn-hover: #5a6268;
    --share-btn-color: #28a745;
    --share-btn-hover: #218838;
    --edit-btn-color: #ffc107;
    --edit-btn-hover: #e0a800;
    --delete-btn-color: #eb808a;
    --delete-btn-hover: #b8414d;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e0dcdc;
    --container-bg: #2d2d2d;
    --header-bg: transparent;
    --header-text: #d1cccc;
    --border-color: #6a6d77;
    --search-bg: #3a3a3a;
    --day-bg: #494949;
    --day-hover: #4a4a4a;
    --entry-bg: #3a3a3a;
    --user-entry-bg: #4a4a4a;
    --shadow: rgba(0, 0, 0, 0.3);
    --nav-btn-bg: #4a5568;
    --nav-btn-hover: #5a6578;
    --today-bg: #4a5568;
    --selected-bg: #a77878;
    --add-btn-bg: #5a7466;
    --add-btn-hover: #43705a;
    --save-btn-bg: #5a7466;
    --save-btn-hover: #43705a;
    --clear-btn-bg: #718096;
    --clear-btn-hover: #4a5568;
    --share-btn-color: #5ab581;
    --share-btn-hover: #2f9e4f;
    --edit-btn-color: #d69e2e;
    --edit-btn-hover: #b7791f;
    --delete-btn-color: #e17878;
    --delete-btn-hover: #c53030;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-color: #1a1a1a;
        --text-color: #e0dcdc;
        --container-bg: #2d2d2d;
        --header-bg: transparent;
        --header-text: #d1cccc;
        --border-color: #404040;
        --search-bg: #3a3a3a;
        --day-bg: #494949;
        --day-hover: #4a4a4a;
        --entry-bg: #3a3a3a;
        --user-entry-bg: #2a2a2a;
        --shadow: rgba(0, 0, 0, 0.3);
        --nav-btn-bg: #4a5568;
        --nav-btn-hover: #5a6578;
        --today-bg: #4a5568;
        --selected-bg: #a77878;
        --add-btn-bg: #5a7466;
        --add-btn-hover: #43705a;
        --save-btn-bg: #5a7466;
        --save-btn-hover: #43705a;
        --clear-btn-bg: #718096;
        --clear-btn-hover: #4a5568;
        --share-btn-color: #5ab581;
        --share-btn-hover: #2f9e4f;
        --edit-btn-color: #d69e2e;
        --edit-btn-hover: #b7791f;
        --delete-btn-color: #e17878;
        --delete-btn-hover: #c53030;
    }
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
    font-size: 1.3rem;
    font-weight: 400;
    line-height: 1.5;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100dvh;
    padding: 20px;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    body {
        background: var(--container-bg);
    }
}

/* Main App Styles */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--container-bg);
    border-radius: 10px;
    box-shadow: 0 20px 60px var(--shadow);
    overflow: hidden;
}

#mainContainer {
    min-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.header h1 {
    font-size: 3rem;
    font-weight: 500;
    margin-bottom: 10px;
}

.header-menu {
    position: absolute;
    top: 30px;
    right: 30px;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s;
}

.menu-toggle:hover {
    background: var(--day-hover);
}

.header-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1000;
    min-width: 290px;
    display: none;
    margin-top: 5px;
}

.header-dropdown.show {
    display: block;
}

.header-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: background 0.2s;
}

.header-menu-item:hover {
    background: var(--day-hover);
}

.header-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.header-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

.content {
    padding: 30px;
}

.sub-title {
    font-size: 1rem;
    color: var(--text-color);
}

.sub-title-small {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 5px;
}

#mainContainer .content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.entries-section {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.entry-form {
    margin: 0;
    width: 100%;
    justify-content: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.entry-input-wrap {
    position: relative;
    width: 100%;
}

.entry-textarea {
    width: 100%;
    padding: 15px 58px 15px 15px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 1.3rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    min-height: 120px;
    max-height: 60vh;
    overflow-y: hidden;
    outline: none;
    transition: all 0.3s;
    background: var(--entry-bg);
    color: var(--text-color);
}

.entry-textarea:focus {
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

.entry-submit-btn {
    position: absolute;
    right: 16px;
    bottom: 22px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--add-btn-bg);
    color: #edecec;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.entry-submit-btn:hover:not(:disabled) {
    background: var(--add-btn-hover);
    transform: translateY(-1px);
}

.entry-submit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.reply {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

/* AI Chat Styles */
.reply.ai-chat-thread {
  list-style: none;
  margin: 0 0 16px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  width: 100%;
}

.reply .ai-chat-entry {
  display: flex;
  width: 100%;
}

.reply .ai-chat-entry-user {
  justify-content: flex-end;
  width: 100%;
  display: flex;
}

.reply .ai-chat-entry-assistant {
  justify-content: flex-start;
  width: 100%;
}

.reply .ai-chat-entry-bubble {
  width: 100%;
  padding: 10px 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-color);
  /* font-size: 1.05rem; */
}

.reply .ai-chat-entry-user .ai-chat-entry-bubble {
  background: var(--user-entry-bg);
  border-color: var(--border-color);
  border-radius: 12px 12px 0 12px;
  color: var(--text-color);
  width: 80%;
  font-size: 1.4rem;
}

.reply .ai-chat-entry-bubble a {
  color: inherit;
  text-decoration: underline;
}

.reply .ai-chat-typing .ai-chat-entry-bubble span {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  margin-right: 5px;
  animation: ai-chat-typing 1.2s infinite ease-in-out;
}

.reply .ai-chat-typing .ai-chat-entry-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.reply .ai-chat-typing .ai-chat-entry-bubble span:nth-child(3) {
  animation-delay: 0.3s;
  margin-right: 0;
}

@keyframes ai-chat-typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 0.9; }
}

.footer {
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.6;
    margin: 10px 0 0 0;
    word-wrap: break-word;
    text-align: center;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.hidden {
    display: none;
}

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="light"] {
    color-scheme: light;
}

/* Tablet styles */
@media (max-width: 768px), (pointer: coarse), (-webkit-touch-callout: body) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 5px;
    }

    #mainContainer {
        min-height: 100dvh;
    }

    .header {
        padding: 20px;
    }

    .header-menu {
        top: 20px;
        right: 20px;
    }

    .header h1 {
        font-size: 2.5rem;
    }

    .content {
        padding: 20px;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .header {
        padding: 15px;
    }

    .header-menu {
        top: 15px;
        right: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .content {
        padding: 15px;
    }

    .entry-textarea {
        min-height: 100px;
    }

    .entry-submit-btn {
        right: 14px;
        bottom: 20px;
        width: 34px;
        height: 34px;
    }
}
