:root {
  /* Light Theme (湲곕낯: ?곗깋 諛곌꼍, 二쇳솴???ъ씤?? */
  --surface: #ffffff;
  --surface-bright: #f5f5f5;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f8f9fa;
  --surface-container: #f1f3f4;
  --surface-container-high: #e8eaed;
  --surface-container-highest: #dadce0;

  --on-surface: #202124;
  --on-surface-variant: #5f6368;

  --primary: #f97316;
  /* 二쇳솴???ъ씤??*/
  --on-primary: #ffffff;
  --primary-container: #ffedd5;

  --outline: #303030;
  --outline-variant: #e8eaed;

  --error: #ea4335;
  --error-container: #fce8e6;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;

  --sidebar-width: 260px;
  --explorer-width: 320px;
}

[data-theme="dark"] {
  /* Dark Theme */
  --surface: #121212;
  --surface-bright: #2d2d2d;
  --surface-container-lowest: #000000;
  --surface-container-low: #1e1e1e;
  --surface-container: #242424;
  --surface-container-high: #2c2c2c;
  --surface-container-highest: #333333;

  --on-surface: #e8eaed;
  --on-surface-variant: #9aa0a6;

  --primary: #fb923c;
  /* 二쇳솴???ъ씤??*/
  --on-primary: #000000;
  --primary-container: #431407;

  --outline: #5f6368;
  --outline-variant: #3c4043;

  --error: #f28b82;
  --error-container: #681f19;
}

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

body {
  font-family: 'Geist', sans-serif;
  background-color: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  overflow: hidden;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--outline-variant);
}

.hidden {
  display: none !important;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100vw;
  height: 100vh;
}

/* === Login Screen === */
#login-screen {
  background-color: var(--surface-container-lowest);
}

.login-box {
  background-color: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.logo-icon {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: var(--space-sm);
}

.login-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.login-header p {
  color: var(--on-surface-variant);
  font-size: 14px;
}

.input-group {
  margin-bottom: var(--space-md);
}

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-bottom: var(--space-xs);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  transition: all 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-bottom: 2px solid var(--primary);
  background-color: var(--surface-container);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px var(--space-md);
  border-radius: var(--radius-md);
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
  width: 100%;
  padding: 12px;
  margin-top: var(--space-sm);
}

.btn-primary:hover {
  background-color: #d8e2ff;
  /* primary-fixed */
}

.error-msg {
  color: var(--error);
  font-size: 12px;
  margin-top: var(--space-sm);
  text-align: center;
  min-height: 18px;
}

/* === Main App Layout === */
#app-screen {
  display: flex;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface-container-lowest);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: var(--space-lg);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--on-surface-variant);
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-sm);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 8px var(--space-md);
  border-radius: var(--radius-md);
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.menu-item:hover {
  background-color: var(--surface-container-highest);
}

.menu-item.active {
  color: var(--primary);
  border-left: 2px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background-color: rgba(173, 198, 255, 0.05);
}

.folder-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-md) var(--space-xs);
  font-size: 12px;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  padding: 4px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: var(--surface-container-high);
  color: var(--on-surface);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--outline-variant);
}

.text-danger {
  color: var(--error);
}

/* === Editor Panel === */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-container-low);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.editor-empty,
.editor-bulk {
  flex: 1;
  display: flex;
  flex-direction: column;
  color: var(--on-surface-variant);
}

.editor-bulk {
  background-color: var(--surface-container-lowest);
}

/* === Explorer === */
.explorer {
  width: var(--explorer-width);
  background-color: var(--surface-container-low);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
}

.explorer-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--outline);
  font-size: 20px;
}

.search-bar input {
  width: 100%;
  background-color: var(--surface-container);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  padding: 8px 10px 8px 36px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.icon-text-btn {
  width: 100%;
  justify-content: center;
  padding: 8px;
}

.memo-list {
  flex: 1;
  overflow-y: auto;
}

.memo-item-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--outline-variant);
  transition: background-color 0.2s;
}

.memo-item-wrapper:hover {
  background-color: var(--surface-container-highest);
}

.memo-item-wrapper.active {
  background-color: var(--primary-container);
}

.memo-checkbox {
  margin-top: 4px;
  cursor: pointer;
}

.memo-item {
  flex: 1;
  cursor: pointer;
  min-width: 0;
  /* for text truncation */
}

.memo-item.active {
  background-color: var(--surface-container-highest);
  border-left-color: var(--primary);
}

.memo-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memo-item-preview {
  font-size: 12px;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.memo-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--outline);
}

.memo-item-folder {
  background-color: var(--primary);
  color: var(--on-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* === Editor === */
.editor-container {
  flex: 1;
  background-color: var(--surface);
  display: flex;
  flex-direction: column;
  position: relative;
}

.editor-empty {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--outline);
  text-align: center;
}

.editor-empty .material-symbols-outlined {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.editor-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--outline-variant);
}

.editor-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.folder-select {
  background-color: transparent;
  color: var(--on-surface-variant);
  border: 1px solid var(--outline-variant);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  cursor: pointer;
}

.folder-select option {
  background-color: var(--surface-container-high);
}

.meta-date {
  font-size: 12px;
  color: var(--outline);
}

.editor-actions {
  display: flex;
  gap: var(--space-sm);
}

.editor-content-area {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.editor-title {
  font-size: 32px;
  font-weight: 600;
  color: var(--on-surface);
  background: transparent;
  border: none;
  outline: none;
  margin-bottom: var(--space-md);
  font-family: 'Geist', sans-serif;
  width: 100%;
}

.toolbar {
  display: flex;
  gap: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: var(--space-md);
}

.editor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.tag-chip {
  background-color: var(--primary);
  color: var(--on-primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-chip .remove-tag-btn {
  background: none;
  border: none;
  color: var(--on-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  opacity: 0.7;
}

.tag-chip .remove-tag-btn:hover {
  opacity: 1;
}

.editor-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--on-surface);
  font-family: 'Geist', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  resize: none;
  outline: none;
  min-height: 200px;
  overflow-y: auto;
}

.editor-textarea[contenteditable]:empty::before {
  content: attr(placeholder);
  color: var(--outline);
  pointer-events: none;
  display: block;
}

.editor-textarea img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: var(--space-sm) 0;
  cursor: pointer;
}

.editor-images {
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.editor-image-container {
  position: relative;
  max-width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--outline-variant);
}

.editor-image-container img {
  width: 100%;
  display: block;
  height: auto;
}

.remove-img-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px;
  cursor: pointer;
}

/* === Loading Overlay === */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 19, 38, 0.8);
  z-index: 9999;
}

.spinner {
  border: 4px solid var(--surface-container-high);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* === Mobile Responsive === */
#mobile-back-btn,
#bulk-mobile-back-btn {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 200;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
  }

  .explorer {
    width: 100%;
    border-right: none;
  }

  .editor-container {
    display: none;
  }

  .editor-container.mobile-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
  }

  #mobile-back-btn,
  #bulk-mobile-back-btn {
    display: inline-flex;
  }

  .login-box {
    border-radius: 0;
    border: none;
    box-shadow: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

/* === Custom Modal === */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.custom-modal-overlay.hidden {
  display: none !important;
}

.custom-modal-box {
  background-color: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  padding: var(--space-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  border: 1px solid var(--outline-variant);
}

.custom-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--on-surface);
}

.custom-modal-message {
  font-size: 14px;
  color: var(--on-surface-variant);
  line-height: 1.5;
  white-space: pre-wrap;
}

.custom-modal-input {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  padding: 10px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
}

.custom-modal-input:focus {
  outline: none;
  border-color: var(--primary);
}

.custom-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.custom-modal-actions .btn {
  margin-top: 0;
  width: auto;
  padding: 8px 16px;
}

.btn-secondary {
  background-color: transparent;
  color: var(--on-surface);
  border: 1px solid var(--outline);
}

.btn-secondary:hover {
  background-color: var(--surface-container);
}