/* Joornal — calm, readable light theme for long text */
:root {
  --bg: #f8f4eb;
  --bg-card: #ffffff;
  --text: #2c2522;
  --muted: #6b6359;
  --accent: #2f6d6d;
  --accent-light: #e6f0f0;
  --border: #d9d0c3;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 15px;
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

a { color: var(--accent); }

/* Top bar */
.top-bar {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(44,37,34,0.06);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.back-btn {
  font-size: 13px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  opacity: 0.8;
}
.back-btn:hover { opacity: 1; background: rgba(0,0,0,0.05); }

.journal-name {
  font-size: 15px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  cursor: text;
}
.journal-name:hover { background: rgba(0,0,0,0.04); }

.journal-name-input {
  font-size: 15px;
  font-weight: 600;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  outline: none;
  background: white;
}

.top-bar-space { flex: 1; }

/* Home */
.home-main {
  padding: 32px 16px;
  max-width: 960px;
  margin: 0 auto;
}

.journals-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 14px;
}

.journal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.journal-thumb-wrapper { position: relative; }

.journal-thumb {
  width: 192px;
  height: 92px;
  background: var(--accent);
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  box-shadow: var(--shadow);
  transition: transform .1s, filter .1s;
}
.journal-thumb:hover { transform: translateY(-1px); filter: brightness(1.08); }

.journal-delete-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0,0,0,0.3);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.journal-thumb-wrapper:hover .journal-delete-btn { opacity: 1; }

.journal-thumb--new {
  background: rgba(44,37,34,0.08);
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  box-shadow: none;
}

/* Journal view */
.journal-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.entries-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.entries-container {
  max-width: 720px;
  margin: 0 auto;
}

/* Composer — hyper efficient input */
.composer {
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.composer-row input[type="date"],
.composer-row input[type="time"] {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
}

.time-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.composer-text {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 15px;
  line-height: 1.5;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.composer-actions button {
  background: var(--accent);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.composer-actions button:hover { filter: brightness(1.1); }

.hint { font-size: 12px; color: var(--muted); }

/* Entry list — compact readable */
.entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.entry-header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.entry-date { font-weight: 600; color: var(--text); }
.entry-time { font-feature-settings: "tnum"; }
.entry-author { font-size: 12px; }

.entry-content {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.entry-content h1, .entry-content h2, .entry-content h3 { margin: .4em 0 .2em; font-size: 1.05em; }
.entry-content ul, .entry-content ol { padding-left: 1.3em; margin: .3em 0; }
.entry-content code { background: #f0e9df; padding: 1px 4px; border-radius: 3px; font-size: .9em; }
.entry-content a { text-decoration: underline; }

.entry-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.entry-actions button {
  font-size: 12px;
  padding: 2px 6px;
  color: var(--accent);
  border-radius: 3px;
}
.entry-actions button:hover { background: var(--accent-light); }

.frozen { font-size: 11px; color: var(--muted); margin-left: 6px; }

/* Members panel (reused pattern) */
.members-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  width: 280px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 20;
}

.members-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.members-body { padding: 12px; font-size: 14px; }

.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.member-avatar {
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.member-remove {
  margin-left: auto;
  color: #a33;
  font-size: 16px;
}

.member-role { font-size: 11px; color: var(--muted); }
.member-role--owner { color: var(--accent); font-weight: 600; }

.members-section { margin-bottom: 14px; }
.members-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
}

.invite-form { display: flex; flex-direction: column; gap: 6px; }
.invite-row { display: flex; gap: 6px; }
.invite-input, .role-select, .edit-window-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.role-select { flex: 0 0 auto; }
.invite-btn, .copy-btn {
  background: var(--accent);
  color: white;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.share-link-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.share-link-url {
  font-size: 11px;
  word-break: break-all;
  background: var(--accent-light);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.share-hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.edit-window-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.edit-window-input { width: 64px; flex: 0 0 auto; }
.modal--wide { width: 480px; max-width: 92vw; }
.modal-desc { min-height: 120px; resize: vertical; }

/* Modal (reused) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.modal {
  background: white;
  padding: 16px;
  border-radius: var(--radius);
  width: 320px;
  max-width: 90vw;
}
.modal h3 { margin-bottom: 10px; }
.modal-input, .modal-desc {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Lang + logout buttons */
.lang-toggle { display: flex; gap: 2px; }
.lang-btn { font-size: 11px; padding: 2px 6px; border-radius: 3px; }
.lang-btn--active { background: var(--accent); color: white; }

.logout-btn, .members-btn {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.06);
}
.logout-btn:hover, .members-btn:hover { background: rgba(0,0,0,0.1); }

/* Auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: white; padding: 28px; border-radius: var(--radius); width: 320px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card h2 { font-size: 15px; font-weight: 500; margin-bottom: 16px; color: var(--muted); }
.auth-form .form-group { margin-bottom: 12px; }
.auth-form label { display: block; font-size: 12px; margin-bottom: 3px; color: var(--muted); }
.form-input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.auth-submit { width: 100%; background: var(--accent); color: white; padding: 10px; border-radius: var(--radius-sm); font-weight: 600; margin-top: 8px; }
.auth-link { margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-error { color: #a33; font-size: 13px; margin-bottom: 8px; display: none; }
.auth-error--visible { display: block; }

/* Error toast */
.error-toast {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: #3a2f2a; color: #f8f4eb; padding: 8px 12px; border-radius: 6px;
  display: flex; gap: 10px; align-items: center; font-size: 13px; z-index: 50;
}
.error-toast-close { color: #f8f4eb; font-size: 16px; }

/* Responsive */
@media (max-width: 480px) {
  .composer-row { flex-direction: column; align-items: stretch; }
  .entries-container, .composer { max-width: 100%; padding-left: 8px; padding-right: 8px; }
  .journal-thumb { width: 100%; max-width: 100%; }
}

/* Loading / empty */
.loading { padding: 40px; text-align: center; color: var(--muted); }
.no-entries { color: var(--muted); font-size: 14px; padding: 20px 0; }
