* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #F7F5EF;
  color: #2D2A26;
  min-height: 100vh;
}

#app {
  display: grid;
  grid-template-columns: 240px 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  background: #1B2A4A;
  color: #E8E4DC;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-family: Georgia, serif;
  font-size: 1.15rem;
  color: #F7F5EF;
  margin: 0;
}

.btn-logout {
  color: #8B9BBF;
  text-decoration: none;
  font-size: 1.2rem;
  opacity: 0.7;
}

.btn-logout:hover {
  opacity: 1;
}

#categoryList {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.category-item {
  padding: 10px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-item:hover {
  background: rgba(255,255,255,0.05);
}

.category-item.active {
  background: rgba(255,255,255,0.1);
  border-left-color: #C97A0B;
  color: #FFFFFF;
  font-weight: 600;
}

.category-count {
  background: rgba(255,255,255,0.15);
  color: #8B9BBF;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.btn-sidebar-action {
  background: none;
  border: 1px dashed rgba(255,255,255,0.2);
  color: #8B9BBF;
  padding: 10px;
  margin: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85rem;
}

.btn-sidebar-action:hover {
  border-color: #C97A0B;
  color: #C97A0B;
}

/* Template Pane */
#templatePane {
  background: #F7F5EF;
  border-right: 1px solid #E0DACE;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  padding: 16px 20px;
  border-bottom: 1px solid #E0DACE;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pane-header h2 {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  color: #1B2A4A;
  margin: 0;
}

#templateList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.template-card {
  background: white;
  border: 1px solid #E0DACE;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.template-card:hover {
  border-color: #C97A0B;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.template-card.active {
  border-color: #C97A0B;
  background: #FFFBF3;
  box-shadow: 0 2px 8px rgba(201,122,11,0.15);
}

.template-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1B2A4A;
  margin: 0;
}

.template-tag {
  display: inline-block;
  background: #FFF3E0;
  color: #C97A0B;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-new-template {
  background: none;
  border: 1px dashed #C97A0B30;
  color: #C97A0B;
  padding: 10px;
  margin: 8px 12px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85rem;
}

.btn-new-template:hover {
  border-color: #C97A0B;
}

/* Editor Pane */
#editorPane {
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#editorContent {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.placeholder-message {
  color: #8B8680;
  text-align: center;
  margin-top: 40%;
  font-size: 0.95rem;
}

/* Editor View Mode */
.editor-heading {
  font-family: Georgia, serif;
  font-size: 1.3rem;
  color: #1B2A4A;
  margin: 0 0 16px;
}

.editor-var-group {
  margin-bottom: 16px;
}

.editor-var-group label {
  display: block;
  font-size: 0.8rem;
  color: #6B6560;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.editor-var-input {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid #D0CBC0;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: Consolas, monospace;
}

.editor-var-input:focus {
  border-color: #C97A0B;
  outline: none;
  box-shadow: 0 0 0 2px rgba(201,122,11,0.15);
}

.editor-preview {
  background: #FFFDF7;
  border: 1px solid #E8E4DC;
  border-radius: 6px;
  padding: 16px 20px;
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #2D2A26;
  min-height: 120px;
}

.token-highlight {
  background: #FFF3E0;
  color: #C97A0B;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: Consolas, monospace;
}

.value-inserted {
  color: #C97A0B;
  font-weight: 600;
}

.editor-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #E8E4DC;
}

/* Editor Edit Mode */
.edit-form-group {
  margin-bottom: 12px;
}

.edit-form-group label {
  display: block;
  font-size: 0.8rem;
  color: #6B6560;
  margin-bottom: 4px;
  font-weight: 600;
}

.edit-form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #D0CBC0;
  border-radius: 4px;
  font-size: 0.95rem;
}

.edit-form-group textarea {
  width: 100%;
  min-height: 200px;
  padding: 10px 12px;
  border: 1px solid #D0CBC0;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: Consolas, monospace;
  line-height: 1.5;
  resize: vertical;
}

.edit-token-hint {
  font-size: 0.8rem;
  color: #8B8680;
  margin-top: 4px;
}

/* Buttons */
.btn-primary {
  background: #C97A0B;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: #B06A00;
}

.btn-secondary {
  background: none;
  border: 1px solid #D0CBC0;
  color: #6B6560;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: #999;
}

.btn-danger {
  color: #C0392B;
}

.btn-danger:hover {
  color: #E74C3C;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  opacity: 0.6;
}

.btn-icon:hover {
  opacity: 1;
}

.btn-copy {
  background: #1B2A4A;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy.copied {
  background: #27AE60;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: white;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-box h3 {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  color: #1B2A4A;
  margin: 0 0 16px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #2D2A26;
  margin-bottom: 4px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #D0CBC0;
  border-radius: 4px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.form-group .hint {
  font-weight: 400;
  color: #8B8680;
  font-size: 0.8rem;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Login Page */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F7F5EF;
}

.login-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  width: 360px;
  overflow: hidden;
}

.login-header {
  background: #1B2A4A;
  color: #F7F5EF;
  padding: 20px 24px;
  text-align: center;
}

.login-header h1 {
  font-family: Georgia, serif;
  font-size: 1.3rem;
  margin: 0;
}

.login-body {
  padding: 24px;
}

.login-body input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #D0CBC0;
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.login-body button {
  width: 100%;
  background: #C97A0B;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.login-body button:hover {
  background: #B06A00;
}

.login-error {
  color: #C0392B;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #D0CBC0;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #B0A99A;
}
