:root {
  --bg-gradient: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 50%, #e0f2fe 100%);
  --bg-blob-1: #c7d2fe;
  --bg-blob-2: #f3d8fa;
  --card-glass: rgba(255, 255, 255, 0.45);
  --card-glass-hover: rgba(255, 255, 255, 0.7);
  --modal-glass: rgba(255, 255, 255, 0.75);
  --card-border: rgba(255, 255, 255, 0.6);
  --primary-color: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --text-color: #1f2937;
  --text-muted: #4b5563;
  --input-bg: rgba(255, 255, 255, 0.5);
  --input-border: rgba(255, 255, 255, 0.6);
  --header-bg: rgba(238, 242, 247, 0.65);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f2942 100%);
    --bg-blob-1: #312e81;
    --bg-blob-2: #4c1d95;
    --card-glass: rgba(30, 41, 59, 0.55);
    --card-glass-hover: rgba(30, 41, 59, 0.8);
    --modal-glass: rgba(15, 23, 42, 0.8);
    --card-border: rgba(255, 255, 255, 0.12);
    --primary-color: #818cf8;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --input-bg: rgba(15, 23, 42, 0.5);
    --input-border: rgba(255, 255, 255, 0.15);
    --header-bg: rgba(15, 23, 42, 0.7);
  }
}

body.dark-theme {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f2942 100%);
  --bg-blob-1: #312e81;
  --bg-blob-2: #4c1d95;
  --card-glass: rgba(30, 41, 59, 0.55);
  --card-glass-hover: rgba(30, 41, 59, 0.8);
  --modal-glass: rgba(15, 23, 42, 0.8);
  --card-border: rgba(255, 255, 255, 0.12);
  --primary-color: #818cf8;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  --text-color: #f3f4f6;
  --text-muted: #9ca3af;
  --input-bg: rgba(15, 23, 42, 0.5);
  --input-border: rgba(255, 255, 255, 0.15);
  --header-bg: rgba(15, 23, 42, 0.7);
}

body.light-theme {
  --bg-gradient: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 50%, #e0f2fe 100%);
  --bg-blob-1: #c7d2fe;
  --bg-blob-2: #f3d8fa;
  --card-glass: rgba(255, 255, 255, 0.45);
  --card-glass-hover: rgba(255, 255, 255, 0.7);
  --modal-glass: rgba(255, 255, 255, 0.75);
  --card-border: rgba(255, 255, 255, 0.6);
  --primary-color: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --text-color: #1f2937;
  --text-muted: #4b5563;
  --input-bg: rgba(255, 255, 255, 0.5);
  --input-border: rgba(255, 255, 255, 0.6);
  --header-bg: rgba(238, 242, 247, 0.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { background: var(--bg-gradient); color: var(--text-color); display: flex; justify-content: center; align-items: center; position: relative; transition: background 0.3s ease; }
body::before, body::after { content: ""; position: fixed; width: 350px; height: 350px; border-radius: 50%; filter: blur(90px); z-index: -1; opacity: 0.7; }
body::before { top: -60px; left: -60px; background: var(--bg-blob-1); }
body::after { bottom: -60px; right: -60px; background: var(--bg-blob-2); }

.container { width: 100%; max-width: 900px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; z-index: 10; position: relative; }
.card { background: var(--card-glass); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); padding: 32px 24px; border-radius: 24px; border: 1px solid var(--card-border); box-shadow: 0 10px 32px 0 rgba(0, 0, 0, 0.08); transition: all 0.5s cubic-bezier(0.76, 0, 0.24, 1); width: 100%; display: flex; flex-direction: column; align-items: center; }

#login-section, #signup-section { max-width: 380px; margin: auto; }
#login-section h2, #signup-section h2 { text-align: center; margin-bottom: 24px; width: 100%; }

.view-panel { position: relative; transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1), opacity 0.5s ease; width: 100%; display: flex; flex-direction: column; align-items: center; }
.view-panel.hidden { display: none !important; }
.view-panel.fly-up { transform: translateY(-120vh); opacity: 0; }
.view-panel.prepare-up { transform: translateY(100vh); opacity: 0; height: 100%; }
.view-panel.active-main { transform: translateY(0); opacity: 1; height: 100%; }
.view-panel.fly-down { transform: translateY(100vh); opacity: 0; }

.input-group { width: 100%; max-width: 310px; margin-bottom: 16px; display: flex; flex-direction: column; align-items: flex-start; }
.input-group label { font-size: 13px; margin-bottom: 5px; font-weight: 600; color: var(--text-muted); padding-left: 2px; }
.input-group input, .input-group textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--input-border); border-radius: 12px; font-size: 14px; background: var(--input-bg); color: var(--text-color); transition: border-color 0.25s, box-shadow 0.25s; }
.input-group input:focus, .input-group textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }
.input-group textarea { resize: vertical; min-height: 80px; height: 120px; max-height: 300px; }

.checkbox-group { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; width: 100%; max-width: 310px; cursor: pointer; justify-content: flex-start; }
.checkbox-group input { width: 18px; height: 18px; accent-color: var(--primary-color); }
.checkbox-group label { font-size: 14px; font-weight: 600; color: var(--text-muted); }

button { width: 100%; max-width: 310px; padding: 14px; background: var(--primary-gradient); color: white; border: none; border-radius: 14px; font-weight: 600; cursor: pointer; transition: all 0.25s ease; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.2); margin-top: 8px; }
button:hover { opacity: 0.9; transform: translateY(-1px); }
button:active { transform: translateY(1px); }

.sub-btn { width: auto; min-width: 100px; margin: 12px auto 0 auto; padding: 8px 16px; background: rgba(255, 255, 255, 0.1); color: var(--text-muted); border: 1px solid var(--card-border); font-size: 12px; border-radius: 10px; box-shadow: none; }

.header-bar { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 12px 18px; background: var(--header-bg); backdrop-filter: blur(25px) saturate(180%); -webkit-backdrop-filter: blur(25px) saturate(180%); border-radius: 20px; border: 1px solid var(--card-border); box-shadow: 0 8px 24px rgba(0,0,0,0.05); width: 100%; }
.header-title-area { display: flex; align-items: center; gap: 10px; }
.header-bar h2 { margin: 0; color: var(--text-color); font-size: 18px; font-weight: 800; }

.app-logo { width: 22px; height: 24px; background: var(--primary-gradient); border-radius: 5px; position: relative; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3); }
.app-logo::before { content: ""; position: absolute; top: 4px; left: 4px; right: 4px; height: 2px; background: rgba(255,255,255,0.6); border-radius: 1px; }
.app-logo::after { content: ""; position: absolute; top: 9px; left: 4px; right: 8px; height: 2px; background: rgba(255,255,255,0.4); border-radius: 1px; }

.header-right { display: flex; align-items: center; gap: 8px; }
.user-greeting { font-size: 11px; color: var(--text-muted); font-weight: 700; white-space: nowrap; opacity: 0.8; }
.theme-toggle-btn { width: 34px; height: 34px; padding: 0; margin: 0; background: rgba(255,255,255,0.15); border: 1px solid var(--card-border); font-size: 15px; border-radius: 10px; box-shadow: none; display: flex; align-items: center; justify-content: center; }
.logout-btn { width: auto; margin: 0; padding: 7px 12px; background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); font-size: 11px; border-radius: 8px; font-weight: bold; }

.memo-list-wrapper { flex-grow: 1; overflow-y: auto; width: 100%; padding: 4px 2px 100px 2px; -webkit-overflow-scrolling: touch; }
.memo-grid { display: grid; grid-template-columns: 1fr; gap: 16px; width: 100%; }
@media (min-width: 600px) { .memo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .memo-grid { grid-template-columns: repeat(3, 1fr); } }

.memo-card { position: relative; background: var(--card-glass); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border-radius: 18px; border: 1px solid var(--card-border); overflow: hidden; cursor: pointer; transition: all 0.3s ease; display: flex; flex-direction: column; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03); }
.memo-card:hover { background: var(--card-glass-hover); border-color: rgba(255, 255, 255, 0.8); transform: translateY(-3px); }

.memo-thumb { width: 100%; height: 140px; object-fit: cover; background: rgba(255, 255, 255, 0.1); }
.memo-info { padding: 16px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.memo-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; color: var(--text-color); }
.memo-preview { font-size: 13px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.memo-meta { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--text-muted); border-top: 1px solid var(--card-border); padding-top: 10px; }
.memo-writer { font-weight: 800; color: var(--primary-color); }

.private-badge { display: inline-flex; align-items: center; background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%); color: white; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 6px; margin-right: 4px; box-shadow: 0 2px 6px rgba(124, 58, 237, 0.2); flex-shrink: 0; }
.img-count-tag { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); color: white; font-size: 11px; font-weight: bold; padding: 3px 8px; border-radius: 12px; display: flex; align-items: center; gap: 4px; z-index: 5; }

.fab-btn { display: none; position: fixed; bottom: 28px; right: 28px; width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: white; border: none; font-size: 32px; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3); cursor: pointer; transition: 0.2s; z-index: 900; }
.fab-btn:active { transform: scale(0.9); }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 20px; opacity: 0; transition: opacity 0.2s ease; }
.modal.active { display: flex !important; opacity: 1; }
.modal-content { background: var(--modal-glass); backdrop-filter: blur(30px) saturate(190%); -webkit-backdrop-filter: blur(30px) saturate(190%); width: 100%; max-width: 500px; border-radius: 28px; position: relative; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--card-border); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15); transform: scale(0.92); transition: 0.25s; }
.modal.active .modal-content { transform: scale(1); }

.modal-header { padding: 20px 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--card-border); gap: 16px; }
.modal-header h2 { font-size: 18px; margin: 0; color: var(--text-color); font-weight: 800; line-height: 1.3; }

.modal-close { width: 32px !important; height: 32px !important; min-width: 32px; padding: 0 !important; margin: 0 !important; font-size: 18px; border: none; background: rgba(0,0,0,0.05); cursor: pointer; color: var(--text-color); display: flex !important; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }

.modal-scroll-area { padding: 20px 24px; overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; align-items: center; }
.modal-body { width: 100%; font-size: 14px; color: var(--text-color); white-space: pre-wrap; line-height: 1.6; word-break: break-all; }

/* 📌 메타 정보 (작성자/작성일자) 박스 스타일 */
.modal-meta-box {
  width: 100%;
  font-size: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--card-border);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meta-label {
  font-weight: 700;
  color: var(--text-color);
}
#modal-writer {
  font-weight: bold;
  color: var(--primary-color);
}

.modal-actions { display: flex; gap: 12px; margin-top: 20px; border-top: 1px solid var(--card-border); padding-top: 16px; width: 100%; justify-content: center; }
.modal-actions button { width: 120px; margin: 0; padding: 12px; font-size: 13px; font-weight: bold; border-radius: 12px; }

.carousel-wrapper { position: relative; width: 100%; margin-top: 18px; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,0.05); border: 1px solid var(--card-border); }
.carousel-track-container { width: 100%; max-height: 280px; overflow: hidden; position: relative; }
.carousel-track { display: flex; transition: transform 0.35s ease-in-out; width: 100%; }
.carousel-slide { min-width: 100%; height: 260px; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.carousel-slide img { width: 100%; height: 100%; object-fit: contain; }

.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; min-width: 32px; background: rgba(0,0,0,0.4); color: white; border: none; border-radius: 50%; font-size: 14px; cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 0; margin: 0; transition: 0.2s; }
.carousel-btn:hover { background: rgba(0,0,0,0.7); }
.carousel-btn.prev-btn { left: 8px; }
.carousel-btn.next-btn { right: 8px; }
.carousel-counter { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,0.6); color: white; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: bold; backdrop-filter: blur(4px); }

.zoom-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.92); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); z-index: 3000; display: none; flex-direction: column; justify-content: space-between; opacity: 0; transition: opacity 0.25s ease; touch-action: none; }
.zoom-modal.active { display: flex !important; opacity: 1; }

.zoom-header { position: absolute; top: 0; left: 0; width: 100%; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; z-index: 3100; background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent); }
.zoom-counter { color: white; font-size: 14px; font-weight: bold; letter-spacing: 1px; }
.zoom-close { width: 36px; height: 36px; min-width: 36px; border-radius: 50%; background: rgba(255,255,255,0.2); color: white; border: none; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; margin: 0; padding: 0; }
.zoom-close:hover { background: rgba(255,255,255,0.4); }

.zoom-viewport { width: 100%; height: 100%; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
.zoom-viewport img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center center; cursor: grab; transition: transform 0.05s ease-out; }
.zoom-viewport img:active { cursor: grabbing; }

.zoom-nav-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; min-width: 44px; border-radius: 50%; background: rgba(255,255,255,0.15); color: white; border: none; font-size: 20px; cursor: pointer; z-index: 3100; display: flex; align-items: center; justify-content: center; padding: 0; margin: 0; backdrop-filter: blur(4px); transition: 0.2s; }
.zoom-nav-btn:hover { background: rgba(255,255,255,0.3); }
.zoom-prev { left: 16px; }
.zoom-next { right: 16px; }

.version-badge { position: fixed; bottom: 10px; left: 10px; background: #1f2937; color: #fff; padding: 3px 7px; border-radius: 5px; font-size: 9px; font-weight: bold; opacity: 0.5; z-index: 2000; pointer-events: none; transition: 1.5s; }
.count-badge { position: fixed; bottom: 32px; left: 10px; background: var(--card-glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text-color); padding: 4px 9px; border-radius: 6px; font-size: 11px; font-weight: bold; border: 1px solid var(--card-border); box-shadow: 0 4px 12px rgba(0,0,0,0.05); z-index: 1999; pointer-events: none; display: none; }
