:root {
  --bg: #1a1a2e;
  --bg-surface: #16213e;
  --bg-elevated: #0f3460;
  --text: #eaeaea;
  --text-muted: #a0a0a0;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --success: #4ecca3;
  --warning: #ffc107;
  --border: #333;
  --radius: 8px;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

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

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  transition: none;
}

.inbox-panel {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  overflow-y: auto;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Task Details Panel */
.task-details-panel {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
}

/* Show panel when not hidden */
.task-details-panel:not(.hidden) {
  display: flex;
}

/* Wide screens (>900px): Split view when task details is open */
@media (min-width: 901px) {
  .app-layout.has-details .inbox-panel {
    flex: 0 0 50%;
    max-width: none;
    margin: 0;
    transition: flex 0.2s ease-out;
  }
  
  .app-layout.has-details .task-details-panel:not(.hidden) {
    flex: 0 0 50%;
    transition: flex 0.2s ease-out;
  }
}

/* Narrow screens (<=900px): Task details takes full screen when open */
@media (max-width: 900px) {
  .app-layout.has-details .inbox-panel {
    display: none;
  }
  
  .app-layout.has-details .task-details-panel:not(.hidden) {
    flex: 1 1 100%;
    border-left: none;
  }
}

.task-details-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.btn-close:hover {
  background: var(--bg-elevated);
}

.task-details-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

#task-details-body {
  max-width: 600px;
  margin: 0 auto;
}

/* Auth screen */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}

.auth-screen h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--accent);
}

.passphrase-input {
  width: 100%;
  max-width: 400px;
  padding: 16px 20px;
  font-size: 1.1rem;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
}

.passphrase-input:focus {
  outline: none;
  border-color: var(--accent);
}

.error-message {
  color: var(--accent);
  margin-top: 1rem;
  text-align: center;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 1.5rem;
  color: var(--text);
}

.btn-add {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Item list */
.item {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.item:hover {
  background: var(--bg-elevated);
}

.item-content {
  flex: 1;
  word-break: break-word;
  min-width: 0;
}

.item-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 4px;
  word-wrap: break-word;
  cursor: pointer;
}

.item-title {
  font-weight: 500;
}

.item-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: pre-wrap;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--success);
  color: var(--bg);
}

.btn-icon.delete:hover {
  background: var(--accent);
  color: white;
}

/* Summary */
.summary {
  text-align: center;
  color: var(--text-muted);
  padding: 16px;
  font-size: 0.9rem;
}

.summary-link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  margin-left: 4px;
}

.summary-link:hover {
  color: var(--accent-hover);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

/* Show all container */
#show-all-container {
  text-align: center;
  margin-top: 16px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
}

.title-input {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 500;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
}

.title-input:focus {
  outline: none;
  border-color: var(--accent);
}

.title-input::placeholder {
  color: var(--text-muted);
}

.description-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: none;
  min-height: 80px;
  font-family: inherit;
  margin-top: 12px;
}

.description-input:focus {
  outline: none;
  border-color: var(--accent);
}

.description-input::placeholder {
  color: var(--text-muted);
}

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

/* Edit modal */
.edit-fields {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-row label {
  width: 80px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.field-select,
.field-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}

.field-select:focus,
.field-input:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: auto;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.modal-actions-multi {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-actions-left,
.modal-actions-right {
  display: flex;
  gap: 8px;
}

.btn-danger {
  background: var(--accent);
  color: white;
}

.btn-danger:hover {
  background: var(--accent-hover);
}

.btn-warning {
  background: var(--warning);
  color: #1a1a2e;
}

.btn-warning:hover {
  background: #ffb300;
}

.btn-success {
  background: var(--success);
  color: var(--bg);
}

.btn-success:hover {
  opacity: 0.9;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* Task Details Styles */
.task-details {
  padding: 20px 0;
}

.task-details-field {
  margin-bottom: 20px;
}

.task-details-field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.task-details-input,
.task-details-textarea,
.task-details-select {
  width: 100%;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.task-details-input:focus,
.task-details-textarea:focus,
.task-details-select:focus {
  outline: none;
  border-color: var(--accent);
}

.task-details-textarea {
  resize: vertical;
  min-height: 100px;
}

.task-details-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

.task-details-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.task-details-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.task-details-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.task-details-actions .btn {
  width: 100%;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--success);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 16px;
  }

  .item {
    flex-direction: column;
  }

  .item-actions {
    align-self: flex-end;
  }
}
