:root {
  --ctp-base: #2a2a2a;
  --ctp-mantle: #232323;
  --ctp-crust: #1a1a1a;
  --ctp-text: #e8e8e8;
  --ctp-subtext: #b8b8b8;
  --ctp-surface0: #363636;
  --ctp-surface1: #454545;
  --ctp-blue: #7aa2f7;
  --ctp-green: #9ece6a;
  --ctp-red: #f7768e;
  --ctp-yellow: #e0af68;
  --ctp-lavender: #bb9af7;

  /* Floating card shadows with depth */
  --neu-shadow-light: #353535;
  --neu-shadow-dark: #1a1a1a;
  --neu-glow: rgba(122, 162, 247, 0.15);
  --neu-raised:
    0 8px 16px rgba(0, 0, 0, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  --neu-raised-hover:
    0 16px 32px rgba(0, 0, 0, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 20px var(--neu-glow);
  --neu-pressed:
    inset 0 4px 8px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(0, 0, 0, 0.2);
  --neu-flat:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Prevent white flash on page load */
html {
  background-color: #2a2a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background: #2a2a2a;
  color: var(--ctp-text);
}

/* Page list styles */
.page-list {
  max-width: 600px;
  margin: 3rem auto;
  padding: 2.5rem;
  background: linear-gradient(145deg, #2e2e2e 0%, #282828 100%);
  border-radius: 24px;
  box-shadow: var(--neu-raised);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.page-list h1 {
  color: var(--ctp-lavender);
  margin-bottom: 1.5rem;
  text-shadow: 2px 2px 4px var(--neu-shadow-dark);
}

.page-list .no-pages {
  color: var(--ctp-subtext);
  text-align: center;
  margin: 3rem 0;
  font-size: 1rem;
}

.page-list ul {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0 0;
}

.page-list li {
  margin: 0.75rem 0;
}

.page-list a {
  color: var(--ctp-text);
  text-decoration: none;
  font-size: 1.125rem;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #323232 0%, #2c2c2c 100%);
  box-shadow: var(--neu-flat);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.page-list a .page-name {
  color: var(--ctp-text);
  font-weight: 500;
}

.page-list a .page-meta {
  color: var(--ctp-blue);
  font-size: 0.875rem;
  opacity: 0.8;
}

.page-list a:hover {
  box-shadow: var(--neu-raised);
  transform: translateY(-4px);
  border-color: rgba(122, 162, 247, 0.3);
}

.page-list a:hover .page-meta {
  opacity: 1;
}

.create-page {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  gap: 0.75rem;
}

.create-page input {
  flex: 1;
  padding: 1rem 1.5rem;
  background: var(--ctp-base);
  border: none;
  border-radius: 16px;
  color: var(--ctp-text);
  font-size: 1rem;
  box-shadow: var(--neu-pressed);
  transition: all 0.3s ease;
}

.create-page input:focus {
  outline: none;
  box-shadow:
    var(--neu-pressed),
    0 0 0 3px rgba(122, 162, 247, 0.3);
}

.create-page button {
  padding: 1rem 2rem;
  background: linear-gradient(145deg, #7aa2f7 0%, #668cd9 100%);
  color: #1a1a1a;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--neu-raised);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.create-page button:hover {
  box-shadow: var(--neu-raised-hover);
  transform: translateY(-4px);
}

.create-page button:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(-1px);
}

/* Floating edit button */
#tortiepad-edit-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #323232 0%, #2c2c2c 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--neu-raised);
  transition: all 0.3s ease;
  z-index: 9999;
}

#tortiepad-edit-btn:hover {
  box-shadow: var(--neu-raised-hover);
  transform: translateY(-6px);
  border-color: rgba(122, 162, 247, 0.3);
}

#tortiepad-edit-btn:active {
  box-shadow: var(--neu-flat);
  transform: translateY(-2px);
}

#tortiepad-edit-btn svg {
  width: 1.75rem;
  height: 1.75rem;
  fill: var(--ctp-blue);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Editor container */
#tortiepad-editor {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--ctp-base);
  z-index: 10000;
  display: none;
  flex-direction: column;
}

#tortiepad-editor.active {
  display: flex;
}

/* Editor toolbar */
.tortiepad-toolbar {
  background: linear-gradient(145deg, #2e2e2e 0%, #282828 100%);
  border-bottom: none;
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tortiepad-toolbar button {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(145deg, #323232 0%, #2c2c2c 100%);
  color: var(--ctp-text);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--neu-flat);
  transition: all 0.3s ease;
}

.tortiepad-toolbar button:hover {
  box-shadow: var(--neu-raised);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.tortiepad-toolbar button:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

.tortiepad-toolbar button.primary {
  background: linear-gradient(145deg, #7aa2f7 0%, #668cd9 100%);
  color: #1a1a1a;
  box-shadow: var(--neu-raised);
  border-color: rgba(255, 255, 255, 0.2);
}

.tortiepad-toolbar button.primary:hover {
  box-shadow: var(--neu-raised-hover);
}

.tortiepad-toolbar button.danger {
  background: linear-gradient(145deg, #f7768e 0%, #e05c78 100%);
  color: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.2);
}

.tortiepad-toolbar .spacer {
  flex: 1;
}

.tortiepad-toolbar .current-file {
  color: var(--ctp-subtext);
  font-size: 0.875rem;
}

/* Editor layout */
.tortiepad-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* File tree sidebar */
.tortiepad-sidebar {
  width: 280px;
  background: linear-gradient(145deg, #2a2a2a 0%, #262626 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow-y: auto;
  overflow-x: visible;
  padding: 1.5rem;
  box-shadow:
    4px 0 12px rgba(0, 0, 0, 0.4),
    2px 0 6px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 5;
}

.tortiepad-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: visible;
}

.tortiepad-tree li {
  margin: 0.25rem 0;
  overflow: visible;
}

.tortiepad-tree button {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  background: linear-gradient(145deg, #2e2e2e 0%, #292929 100%);
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--ctp-text);
  cursor: pointer;
  border-radius: 12px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--neu-flat);
  transition: all 0.3s ease;
  margin: 0.25rem 0;
}

.tortiepad-tree button:hover {
  box-shadow: var(--neu-raised);
  transform: translateX(4px);
  border-color: rgba(122, 162, 247, 0.2);
}

.tortiepad-tree button.active {
  color: var(--ctp-blue);
  font-weight: 600;
  box-shadow: var(--neu-pressed);
  background: linear-gradient(145deg, #262626 0%, #222222 100%);
}

.tortiepad-tree .folder {
  font-weight: 600;
}

.tortiepad-tree .root-folder {
  border-bottom: none;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--ctp-blue);
  box-shadow: var(--neu-raised);
  padding: 1rem 1.5rem;
  background: linear-gradient(145deg, #323232 0%, #2c2c2c 100%);
  border: 1px solid rgba(122, 162, 247, 0.15);
}

.tortiepad-tree .root-folder:hover {
  box-shadow: var(--neu-raised-hover);
  transform: translateY(-2px) translateX(4px);
}

.tortiepad-tree .root-folder.selected {
  box-shadow: var(--neu-pressed);
  color: var(--ctp-lavender);
  background: linear-gradient(145deg, #262626 0%, #222222 100%);
}

.tortiepad-tree .root-label {
  opacity: 0.9;
}

.tortiepad-tree .icon {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  opacity: 0.7;
  fill: currentColor;
}

.tortiepad-tree svg {
  flex-shrink: 0;
}

/* Nested folder styles */
.tortiepad-tree .nested {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tortiepad-tree li.expanded > .nested {
  display: block;
}

.tortiepad-tree .toggle {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  min-width: 0.75rem;
  transition: transform 0.2s;
  fill: currentColor;
  opacity: 0.6;
}

.tortiepad-tree .toggle-spacer {
  display: inline-block;
  width: 0.75rem;
  min-width: 0.75rem;
}

.tortiepad-tree li.expanded > button .toggle {
  transform: rotate(90deg);
}

/* Selection styles */
.tortiepad-tree button.selected {
  box-shadow: var(--neu-pressed);
  color: var(--ctp-blue);
  font-weight: 600;
  background: linear-gradient(145deg, #262626 0%, #222222 100%);
  border-color: rgba(122, 162, 247, 0.3);
}

/* Active (opened) file styles - creates visual connection to editor */
.tortiepad-tree button.active {
  position: relative;
  color: var(--ctp-lavender);
  font-weight: 700;
  background: linear-gradient(90deg, #323232 0%, #2c2c2c 50%, transparent 100%);
  border-color: rgba(187, 154, 247, 0.4);
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: -1.5rem;
  padding-right: 2.5rem;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.tortiepad-tree button.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg,
    rgba(187, 154, 247, 0.6) 0%,
    rgba(187, 154, 247, 0.8) 50%,
    rgba(187, 154, 247, 0.6) 100%);
  box-shadow: 0 0 10px rgba(187, 154, 247, 0.5);
}

.tortiepad-tree button.active:hover {
  transform: translateX(2px);
}

/* When a file is both active and selected */
.tortiepad-tree button.active.selected {
  border-color: rgba(187, 154, 247, 0.5);
}

.tortiepad-tree button.active.selected::after {
  background: linear-gradient(180deg,
    rgba(187, 154, 247, 0.7) 0%,
    rgba(187, 154, 247, 1) 50%,
    rgba(187, 154, 247, 0.7) 100%);
  box-shadow: 0 0 15px rgba(187, 154, 247, 0.7);
}

/* Drag and drop styles */
.tortiepad-tree button[draggable="true"] {
  cursor: grab;
}

.tortiepad-tree button.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.tortiepad-tree button.drag-over {
  background: var(--ctp-surface2) !important;
  outline: 2px solid var(--ctp-blue);
  outline-offset: -2px;
}

/* Editor area */
.tortiepad-editor-area {
  flex: 1;
  overflow: auto;
}

.tortiepad-editor-area .cm-editor {
  height: 100%;
  font-size: 14px;
}

/* Modal for file/folder creation */
.tortiepad-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  backdrop-filter: blur(8px);
}

.tortiepad-modal.active {
  display: flex;
}

.tortiepad-modal-content {
  background: linear-gradient(145deg, #2e2e2e 0%, #282828 100%);
  padding: 3rem;
  border-radius: 24px;
  min-width: 450px;
  box-shadow: var(--neu-raised-hover);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tortiepad-modal h3 {
  margin-top: 0;
  color: var(--ctp-lavender);
  text-shadow: 2px 2px 4px var(--neu-shadow-dark);
  font-size: 1.5rem;
}

.tortiepad-modal input {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--ctp-base);
  border: none;
  border-radius: 16px;
  color: var(--ctp-text);
  font-size: 1rem;
  margin: 1.5rem 0;
  box-shadow: var(--neu-pressed);
  transition: all 0.3s ease;
}

.tortiepad-modal input:focus {
  outline: none;
  box-shadow:
    var(--neu-pressed),
    0 0 0 3px rgba(122, 162, 247, 0.3);
}

.tortiepad-modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.tortiepad-modal button {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(145deg, #323232 0%, #2c2c2c 100%);
  color: var(--ctp-text);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--neu-flat);
  transition: all 0.3s ease;
}

.tortiepad-modal button.primary {
  background: linear-gradient(145deg, #7aa2f7 0%, #668cd9 100%);
  color: #1a1a1a;
  box-shadow: var(--neu-raised);
  border-color: rgba(255, 255, 255, 0.2);
}

.tortiepad-modal button:hover {
  box-shadow: var(--neu-raised);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.tortiepad-modal button.primary:hover {
  box-shadow: var(--neu-raised-hover);
}

.tortiepad-modal button:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* Ace Editor styling */
.ace_editor {
  height: 100%;
  width: 100%;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
}

/* Ace Vim mode status */
.ace_status-indicator {
  background: var(--ctp-mantle);
  color: var(--ctp-text);
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Login page styles */
.login-container {
  max-width: 450px;
  margin: 6rem auto;
  padding: 3rem;
  text-align: center;
  background: linear-gradient(145deg, #2e2e2e 0%, #282828 100%);
  border-radius: 24px;
  box-shadow: var(--neu-raised);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-container h1 {
  color: var(--ctp-lavender);
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px var(--neu-shadow-dark);
  font-size: 2rem;
}

.login-container p {
  color: var(--ctp-subtext);
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-form input {
  padding: 1rem 1.5rem;
  background: var(--ctp-base);
  border: none;
  border-radius: 16px;
  color: var(--ctp-text);
  font-size: 1rem;
  box-shadow: var(--neu-pressed);
  transition: all 0.3s ease;
}

.login-form input:focus {
  outline: none;
  box-shadow:
    var(--neu-pressed),
    0 0 0 3px rgba(122, 162, 247, 0.3);
}

.login-form button {
  padding: 1rem 1.5rem;
  background: linear-gradient(145deg, #7aa2f7 0%, #668cd9 100%);
  color: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--neu-raised);
  transition: all 0.3s ease;
}

.login-form button:hover:not(:disabled) {
  box-shadow: var(--neu-raised-hover);
  transform: translateY(-4px);
}

.login-form button:active:not(:disabled) {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}

.login-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: var(--neu-flat);
  filter: grayscale(0.5);
}

#loginMessage {
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 16px;
  font-size: 0.875rem;
  min-height: 2rem;
  font-weight: 600;
}

#loginMessage.success {
  background: linear-gradient(145deg, #262626 0%, #222222 100%);
  color: var(--ctp-green);
  box-shadow: var(--neu-pressed);
  border: 1px solid rgba(158, 206, 106, 0.2);
}

#loginMessage.error {
  background: linear-gradient(145deg, #262626 0%, #222222 100%);
  color: var(--ctp-red);
  box-shadow: var(--neu-pressed);
  border: 1px solid rgba(247, 118, 142, 0.2);
}
