/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: #fafafa;
  color: #333;
  -webkit-font-smoothing: antialiased;
}

/* ===== App Layout ===== */
.app {
  display: flex;
  flex-direction: column;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  font-size: 12px;
  color: #999;
  user-select: none;
}

.stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stats strong {
  font-weight: 600;
  color: #666;
}

.stats .sep {
  color: #ddd;
  margin: 0 2px;
}

.change-summary {
  font-size: 12px;
  color: #bbb;
  transition: color 0.2s;
}

/* ===== Editor ===== */
#editor {
  flex: none;
  height: 20vh;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  padding: 20px 0;
  font-size: 15px;
  line-height: 1.8;
  color: #333;
  font-family: inherit;
}

#editor::placeholder {
  color: #ccc;
}

/* ===== Bottom Bar ===== */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid #eee;
  gap: 12px;
}

.bottom-left {
  display: flex;
  gap: 8px;
}

.bottom-right {
  flex-shrink: 0;
}

.sync-status {
  font-size: 12px;
  color: #999;
  transition: color 0.3s;
}

/* ===== Buttons ===== */
.btn {
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.btn:active {
  background: #eee;
}

.btn-primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn-primary:hover {
  background: #444;
  border-color: #444;
}

.btn-success {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
}

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

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

.modal {
  background: #fff;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.modal-title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  color: #888;
}

.field-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.field-input:focus {
  border-color: #aaa;
}

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

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .app {
    padding: 0 16px;
  }

  .status-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .bottom-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-left {
    justify-content: stretch;
  }

  .bottom-left .btn {
    flex: 1;
    text-align: center;
  }

  .bottom-right {
    text-align: center;
  }
}
